UNPKG

578 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 = 350);
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 });
99var Disposable;
100(function (Disposable) {
101 function create(func) {
102 return {
103 dispose: func
104 };
105 }
106 Disposable.create = create;
107})(Disposable = exports.Disposable || (exports.Disposable = {}));
108var Event;
109(function (Event) {
110 const _disposable = { dispose() { } };
111 Event.None = function () { return _disposable; };
112})(Event = exports.Event || (exports.Event = {}));
113class CallbackList {
114 add(callback, context = null, bucket) {
115 if (!this._callbacks) {
116 this._callbacks = [];
117 this._contexts = [];
118 }
119 this._callbacks.push(callback);
120 this._contexts.push(context);
121 if (Array.isArray(bucket)) {
122 bucket.push({ dispose: () => this.remove(callback, context) });
123 }
124 }
125 remove(callback, context = null) {
126 if (!this._callbacks) {
127 return;
128 }
129 var foundCallbackWithDifferentContext = false;
130 for (var i = 0, len = this._callbacks.length; i < len; i++) {
131 if (this._callbacks[i] === callback) {
132 if (this._contexts[i] === context) {
133 // callback & context match => remove it
134 this._callbacks.splice(i, 1);
135 this._contexts.splice(i, 1);
136 return;
137 }
138 else {
139 foundCallbackWithDifferentContext = true;
140 }
141 }
142 }
143 if (foundCallbackWithDifferentContext) {
144 throw new Error('When adding a listener with a context, you should remove it with the same context');
145 }
146 }
147 invoke(...args) {
148 if (!this._callbacks) {
149 return [];
150 }
151 var ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);
152 for (var i = 0, len = callbacks.length; i < len; i++) {
153 try {
154 ret.push(callbacks[i].apply(contexts[i], args));
155 }
156 catch (e) {
157 console.error(e);
158 }
159 }
160 return ret;
161 }
162 isEmpty() {
163 return !this._callbacks || this._callbacks.length === 0;
164 }
165 dispose() {
166 this._callbacks = undefined;
167 this._contexts = undefined;
168 }
169}
170class Emitter {
171 constructor(_options) {
172 this._options = _options;
173 }
174 /**
175 * For the public to allow to subscribe
176 * to events from this Emitter
177 */
178 get event() {
179 if (!this._event) {
180 this._event = (listener, thisArgs, disposables) => {
181 if (!this._callbacks) {
182 this._callbacks = new CallbackList();
183 }
184 if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {
185 this._options.onFirstListenerAdd(this);
186 }
187 this._callbacks.add(listener, thisArgs);
188 let result;
189 result = {
190 dispose: () => {
191 this._callbacks.remove(listener, thisArgs);
192 result.dispose = Emitter._noop;
193 if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {
194 this._options.onLastListenerRemove(this);
195 }
196 }
197 };
198 if (Array.isArray(disposables)) {
199 disposables.push(result);
200 }
201 return result;
202 };
203 }
204 return this._event;
205 }
206 /**
207 * To be kept private to fire an event to
208 * subscribers
209 */
210 fire(event) {
211 if (this._callbacks) {
212 this._callbacks.invoke.call(this._callbacks, event);
213 }
214 }
215 dispose() {
216 if (this._callbacks) {
217 this._callbacks.dispose();
218 this._callbacks = undefined;
219 }
220 }
221}
222Emitter._noop = function () { };
223exports.Emitter = Emitter;
224
225
226/***/ }),
227
228/***/ 11:
229/***/ (function(module, exports, __webpack_require__) {
230
231"use strict";
232/* --------------------------------------------------------------------------------------------
233 * Copyright (c) Microsoft Corporation. All rights reserved.
234 * Licensed under the MIT License. See License.txt in the project root for license information.
235 * ------------------------------------------------------------------------------------------ */
236
237Object.defineProperty(exports, "__esModule", { value: true });
238const events_1 = __webpack_require__(10);
239const Is = __webpack_require__(7);
240let ContentLength = 'Content-Length: ';
241let CRLF = '\r\n';
242var MessageWriter;
243(function (MessageWriter) {
244 function is(value) {
245 let candidate = value;
246 return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) &&
247 Is.func(candidate.onError) && Is.func(candidate.write);
248 }
249 MessageWriter.is = is;
250})(MessageWriter = exports.MessageWriter || (exports.MessageWriter = {}));
251class AbstractMessageWriter {
252 constructor() {
253 this.errorEmitter = new events_1.Emitter();
254 this.closeEmitter = new events_1.Emitter();
255 }
256 dispose() {
257 this.errorEmitter.dispose();
258 this.closeEmitter.dispose();
259 }
260 get onError() {
261 return this.errorEmitter.event;
262 }
263 fireError(error, message, count) {
264 this.errorEmitter.fire([this.asError(error), message, count]);
265 }
266 get onClose() {
267 return this.closeEmitter.event;
268 }
269 fireClose() {
270 this.closeEmitter.fire(undefined);
271 }
272 asError(error) {
273 if (error instanceof Error) {
274 return error;
275 }
276 else {
277 return new Error(`Writer recevied error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
278 }
279 }
280}
281exports.AbstractMessageWriter = AbstractMessageWriter;
282class StreamMessageWriter extends AbstractMessageWriter {
283 constructor(writable, encoding = 'utf8') {
284 super();
285 this.writable = writable;
286 this.encoding = encoding;
287 this.errorCount = 0;
288 this.writable.on('error', (error) => this.fireError(error));
289 this.writable.on('close', () => this.fireClose());
290 }
291 write(msg) {
292 let json = JSON.stringify(msg);
293 let contentLength = Buffer.byteLength(json, this.encoding);
294 let headers = [
295 ContentLength, contentLength.toString(), CRLF,
296 CRLF
297 ];
298 try {
299 // Header must be written in ASCII encoding
300 this.writable.write(headers.join(''), 'ascii');
301 // Now write the content. This can be written in any encoding
302 this.writable.write(json, this.encoding);
303 this.errorCount = 0;
304 }
305 catch (error) {
306 this.errorCount++;
307 this.fireError(error, msg, this.errorCount);
308 }
309 }
310}
311exports.StreamMessageWriter = StreamMessageWriter;
312class IPCMessageWriter extends AbstractMessageWriter {
313 constructor(process) {
314 super();
315 this.process = process;
316 this.errorCount = 0;
317 this.queue = [];
318 this.sending = false;
319 let eventEmitter = this.process;
320 eventEmitter.on('error', (error) => this.fireError(error));
321 eventEmitter.on('close', () => this.fireClose);
322 }
323 write(msg) {
324 if (!this.sending && this.queue.length === 0) {
325 // See https://github.com/nodejs/node/issues/7657
326 this.doWriteMessage(msg);
327 }
328 else {
329 this.queue.push(msg);
330 }
331 }
332 doWriteMessage(msg) {
333 try {
334 if (this.process.send) {
335 this.sending = true;
336 this.process.send(msg, undefined, undefined, (error) => {
337 this.sending = false;
338 if (error) {
339 this.errorCount++;
340 this.fireError(error, msg, this.errorCount);
341 }
342 else {
343 this.errorCount = 0;
344 }
345 if (this.queue.length > 0) {
346 this.doWriteMessage(this.queue.shift());
347 }
348 });
349 }
350 }
351 catch (error) {
352 this.errorCount++;
353 this.fireError(error, msg, this.errorCount);
354 }
355 }
356}
357exports.IPCMessageWriter = IPCMessageWriter;
358class SocketMessageWriter extends AbstractMessageWriter {
359 constructor(socket, encoding = 'utf8') {
360 super();
361 this.socket = socket;
362 this.queue = [];
363 this.sending = false;
364 this.encoding = encoding;
365 this.errorCount = 0;
366 this.socket.on('error', (error) => this.fireError(error));
367 this.socket.on('close', () => this.fireClose());
368 }
369 write(msg) {
370 if (!this.sending && this.queue.length === 0) {
371 // See https://github.com/nodejs/node/issues/7657
372 this.doWriteMessage(msg);
373 }
374 else {
375 this.queue.push(msg);
376 }
377 }
378 doWriteMessage(msg) {
379 let json = JSON.stringify(msg);
380 let contentLength = Buffer.byteLength(json, this.encoding);
381 let headers = [
382 ContentLength, contentLength.toString(), CRLF,
383 CRLF
384 ];
385 try {
386 // Header must be written in ASCII encoding
387 this.sending = true;
388 this.socket.write(headers.join(''), 'ascii', (error) => {
389 if (error) {
390 this.handleError(error, msg);
391 }
392 try {
393 // Now write the content. This can be written in any encoding
394 this.socket.write(json, this.encoding, (error) => {
395 this.sending = false;
396 if (error) {
397 this.handleError(error, msg);
398 }
399 else {
400 this.errorCount = 0;
401 }
402 if (this.queue.length > 0) {
403 this.doWriteMessage(this.queue.shift());
404 }
405 });
406 }
407 catch (error) {
408 this.handleError(error, msg);
409 }
410 });
411 }
412 catch (error) {
413 this.handleError(error, msg);
414 }
415 }
416 handleError(error, msg) {
417 this.errorCount++;
418 this.fireError(error, msg, this.errorCount);
419 }
420}
421exports.SocketMessageWriter = SocketMessageWriter;
422
423
424/***/ }),
425
426/***/ 12:
427/***/ (function(module, exports, __webpack_require__) {
428
429"use strict";
430/*---------------------------------------------------------------------------------------------
431 * Copyright (c) Microsoft Corporation. All rights reserved.
432 * Licensed under the MIT License. See License.txt in the project root for license information.
433 *--------------------------------------------------------------------------------------------*/
434
435Object.defineProperty(exports, "__esModule", { value: true });
436const events_1 = __webpack_require__(10);
437const Is = __webpack_require__(7);
438var CancellationToken;
439(function (CancellationToken) {
440 CancellationToken.None = Object.freeze({
441 isCancellationRequested: false,
442 onCancellationRequested: events_1.Event.None
443 });
444 CancellationToken.Cancelled = Object.freeze({
445 isCancellationRequested: true,
446 onCancellationRequested: events_1.Event.None
447 });
448 function is(value) {
449 let candidate = value;
450 return candidate && (candidate === CancellationToken.None
451 || candidate === CancellationToken.Cancelled
452 || (Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested));
453 }
454 CancellationToken.is = is;
455})(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));
456const shortcutEvent = Object.freeze(function (callback, context) {
457 let handle = setTimeout(callback.bind(context), 0);
458 return { dispose() { clearTimeout(handle); } };
459});
460class MutableToken {
461 constructor() {
462 this._isCancelled = false;
463 }
464 cancel() {
465 if (!this._isCancelled) {
466 this._isCancelled = true;
467 if (this._emitter) {
468 this._emitter.fire(undefined);
469 this._emitter = undefined;
470 }
471 }
472 }
473 get isCancellationRequested() {
474 return this._isCancelled;
475 }
476 get onCancellationRequested() {
477 if (this._isCancelled) {
478 return shortcutEvent;
479 }
480 if (!this._emitter) {
481 this._emitter = new events_1.Emitter();
482 }
483 return this._emitter.event;
484 }
485}
486class CancellationTokenSource {
487 get token() {
488 if (!this._token) {
489 // be lazy and create the token only when
490 // actually needed
491 this._token = new MutableToken();
492 }
493 return this._token;
494 }
495 cancel() {
496 if (!this._token) {
497 // save an object by returning the default
498 // cancelled token when cancellation happens
499 // before someone asks for the token
500 this._token = CancellationToken.Cancelled;
501 }
502 else {
503 this._token.cancel();
504 }
505 }
506 dispose() {
507 this.cancel();
508 }
509}
510exports.CancellationTokenSource = CancellationTokenSource;
511
512
513/***/ }),
514
515/***/ 13:
516/***/ (function(module, exports, __webpack_require__) {
517
518"use strict";
519
520/*---------------------------------------------------------------------------------------------
521 * Copyright (c) Microsoft Corporation. All rights reserved.
522 * Licensed under the MIT License. See License.txt in the project root for license information.
523 *--------------------------------------------------------------------------------------------*/
524Object.defineProperty(exports, "__esModule", { value: true });
525var Touch;
526(function (Touch) {
527 Touch.None = 0;
528 Touch.First = 1;
529 Touch.Last = 2;
530})(Touch = exports.Touch || (exports.Touch = {}));
531class LinkedMap {
532 constructor() {
533 this._map = new Map();
534 this._head = undefined;
535 this._tail = undefined;
536 this._size = 0;
537 }
538 clear() {
539 this._map.clear();
540 this._head = undefined;
541 this._tail = undefined;
542 this._size = 0;
543 }
544 isEmpty() {
545 return !this._head && !this._tail;
546 }
547 get size() {
548 return this._size;
549 }
550 has(key) {
551 return this._map.has(key);
552 }
553 get(key) {
554 const item = this._map.get(key);
555 if (!item) {
556 return undefined;
557 }
558 return item.value;
559 }
560 set(key, value, touch = Touch.None) {
561 let item = this._map.get(key);
562 if (item) {
563 item.value = value;
564 if (touch !== Touch.None) {
565 this.touch(item, touch);
566 }
567 }
568 else {
569 item = { key, value, next: undefined, previous: undefined };
570 switch (touch) {
571 case Touch.None:
572 this.addItemLast(item);
573 break;
574 case Touch.First:
575 this.addItemFirst(item);
576 break;
577 case Touch.Last:
578 this.addItemLast(item);
579 break;
580 default:
581 this.addItemLast(item);
582 break;
583 }
584 this._map.set(key, item);
585 this._size++;
586 }
587 }
588 delete(key) {
589 const item = this._map.get(key);
590 if (!item) {
591 return false;
592 }
593 this._map.delete(key);
594 this.removeItem(item);
595 this._size--;
596 return true;
597 }
598 shift() {
599 if (!this._head && !this._tail) {
600 return undefined;
601 }
602 if (!this._head || !this._tail) {
603 throw new Error('Invalid list');
604 }
605 const item = this._head;
606 this._map.delete(item.key);
607 this.removeItem(item);
608 this._size--;
609 return item.value;
610 }
611 forEach(callbackfn, thisArg) {
612 let current = this._head;
613 while (current) {
614 if (thisArg) {
615 callbackfn.bind(thisArg)(current.value, current.key, this);
616 }
617 else {
618 callbackfn(current.value, current.key, this);
619 }
620 current = current.next;
621 }
622 }
623 forEachReverse(callbackfn, thisArg) {
624 let current = this._tail;
625 while (current) {
626 if (thisArg) {
627 callbackfn.bind(thisArg)(current.value, current.key, this);
628 }
629 else {
630 callbackfn(current.value, current.key, this);
631 }
632 current = current.previous;
633 }
634 }
635 values() {
636 let result = [];
637 let current = this._head;
638 while (current) {
639 result.push(current.value);
640 current = current.next;
641 }
642 return result;
643 }
644 keys() {
645 let result = [];
646 let current = this._head;
647 while (current) {
648 result.push(current.key);
649 current = current.next;
650 }
651 return result;
652 }
653 /* JSON RPC run on es5 which has no Symbol.iterator
654 public keys(): IterableIterator<K> {
655 let current = this._head;
656 let iterator: IterableIterator<K> = {
657 [Symbol.iterator]() {
658 return iterator;
659 },
660 next():IteratorResult<K> {
661 if (current) {
662 let result = { value: current.key, done: false };
663 current = current.next;
664 return result;
665 } else {
666 return { value: undefined, done: true };
667 }
668 }
669 };
670 return iterator;
671 }
672
673 public values(): IterableIterator<V> {
674 let current = this._head;
675 let iterator: IterableIterator<V> = {
676 [Symbol.iterator]() {
677 return iterator;
678 },
679 next():IteratorResult<V> {
680 if (current) {
681 let result = { value: current.value, done: false };
682 current = current.next;
683 return result;
684 } else {
685 return { value: undefined, done: true };
686 }
687 }
688 };
689 return iterator;
690 }
691 */
692 addItemFirst(item) {
693 // First time Insert
694 if (!this._head && !this._tail) {
695 this._tail = item;
696 }
697 else if (!this._head) {
698 throw new Error('Invalid list');
699 }
700 else {
701 item.next = this._head;
702 this._head.previous = item;
703 }
704 this._head = item;
705 }
706 addItemLast(item) {
707 // First time Insert
708 if (!this._head && !this._tail) {
709 this._head = item;
710 }
711 else if (!this._tail) {
712 throw new Error('Invalid list');
713 }
714 else {
715 item.previous = this._tail;
716 this._tail.next = item;
717 }
718 this._tail = item;
719 }
720 removeItem(item) {
721 if (item === this._head && item === this._tail) {
722 this._head = undefined;
723 this._tail = undefined;
724 }
725 else if (item === this._head) {
726 this._head = item.next;
727 }
728 else if (item === this._tail) {
729 this._tail = item.previous;
730 }
731 else {
732 const next = item.next;
733 const previous = item.previous;
734 if (!next || !previous) {
735 throw new Error('Invalid list');
736 }
737 next.previous = previous;
738 previous.next = next;
739 }
740 }
741 touch(item, touch) {
742 if (!this._head || !this._tail) {
743 throw new Error('Invalid list');
744 }
745 if ((touch !== Touch.First && touch !== Touch.Last)) {
746 return;
747 }
748 if (touch === Touch.First) {
749 if (item === this._head) {
750 return;
751 }
752 const next = item.next;
753 const previous = item.previous;
754 // Unlink the item
755 if (item === this._tail) {
756 // previous must be defined since item was not head but is tail
757 // So there are more than on item in the map
758 previous.next = undefined;
759 this._tail = previous;
760 }
761 else {
762 // Both next and previous are not undefined since item was neither head nor tail.
763 next.previous = previous;
764 previous.next = next;
765 }
766 // Insert the node at head
767 item.previous = undefined;
768 item.next = this._head;
769 this._head.previous = item;
770 this._head = item;
771 }
772 else if (touch === Touch.Last) {
773 if (item === this._tail) {
774 return;
775 }
776 const next = item.next;
777 const previous = item.previous;
778 // Unlink the item.
779 if (item === this._head) {
780 // next must be defined since item was not tail but is head
781 // So there are more than on item in the map
782 next.previous = undefined;
783 this._head = next;
784 }
785 else {
786 // Both next and previous are not undefined since item was neither head nor tail.
787 next.previous = previous;
788 previous.next = next;
789 }
790 item.next = undefined;
791 item.previous = this._tail;
792 this._tail.next = item;
793 this._tail = item;
794 }
795 }
796}
797exports.LinkedMap = LinkedMap;
798
799
800/***/ }),
801
802/***/ 14:
803/***/ (function(module, exports, __webpack_require__) {
804
805"use strict";
806/* --------------------------------------------------------------------------------------------
807 * Copyright (c) Microsoft Corporation. All rights reserved.
808 * Licensed under the MIT License. See License.txt in the project root for license information.
809 * ------------------------------------------------------------------------------------------ */
810
811Object.defineProperty(exports, "__esModule", { value: true });
812const path_1 = __webpack_require__(15);
813const os_1 = __webpack_require__(16);
814const crypto_1 = __webpack_require__(17);
815const net_1 = __webpack_require__(18);
816const messageReader_1 = __webpack_require__(9);
817const messageWriter_1 = __webpack_require__(11);
818function generateRandomPipeName() {
819 const randomSuffix = crypto_1.randomBytes(21).toString('hex');
820 if (process.platform === 'win32') {
821 return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`;
822 }
823 else {
824 // Mac/Unix: use socket file
825 return path_1.join(os_1.tmpdir(), `vscode-${randomSuffix}.sock`);
826 }
827}
828exports.generateRandomPipeName = generateRandomPipeName;
829function createClientPipeTransport(pipeName, encoding = 'utf-8') {
830 let connectResolve;
831 let connected = new Promise((resolve, _reject) => {
832 connectResolve = resolve;
833 });
834 return new Promise((resolve, reject) => {
835 let server = net_1.createServer((socket) => {
836 server.close();
837 connectResolve([
838 new messageReader_1.SocketMessageReader(socket, encoding),
839 new messageWriter_1.SocketMessageWriter(socket, encoding)
840 ]);
841 });
842 server.on('error', reject);
843 server.listen(pipeName, () => {
844 server.removeListener('error', reject);
845 resolve({
846 onConnected: () => { return connected; }
847 });
848 });
849 });
850}
851exports.createClientPipeTransport = createClientPipeTransport;
852function createServerPipeTransport(pipeName, encoding = 'utf-8') {
853 const socket = net_1.createConnection(pipeName);
854 return [
855 new messageReader_1.SocketMessageReader(socket, encoding),
856 new messageWriter_1.SocketMessageWriter(socket, encoding)
857 ];
858}
859exports.createServerPipeTransport = createServerPipeTransport;
860
861
862/***/ }),
863
864/***/ 15:
865/***/ (function(module, exports) {
866
867module.exports = require("path");
868
869/***/ }),
870
871/***/ 16:
872/***/ (function(module, exports) {
873
874module.exports = require("os");
875
876/***/ }),
877
878/***/ 17:
879/***/ (function(module, exports) {
880
881module.exports = require("crypto");
882
883/***/ }),
884
885/***/ 18:
886/***/ (function(module, exports) {
887
888module.exports = require("net");
889
890/***/ }),
891
892/***/ 19:
893/***/ (function(module, exports, __webpack_require__) {
894
895"use strict";
896/* --------------------------------------------------------------------------------------------
897 * Copyright (c) Microsoft Corporation. All rights reserved.
898 * Licensed under the MIT License. See License.txt in the project root for license information.
899 * ------------------------------------------------------------------------------------------ */
900
901Object.defineProperty(exports, "__esModule", { value: true });
902const net_1 = __webpack_require__(18);
903const messageReader_1 = __webpack_require__(9);
904const messageWriter_1 = __webpack_require__(11);
905function createClientSocketTransport(port, encoding = 'utf-8') {
906 let connectResolve;
907 let connected = new Promise((resolve, _reject) => {
908 connectResolve = resolve;
909 });
910 return new Promise((resolve, reject) => {
911 let server = net_1.createServer((socket) => {
912 server.close();
913 connectResolve([
914 new messageReader_1.SocketMessageReader(socket, encoding),
915 new messageWriter_1.SocketMessageWriter(socket, encoding)
916 ]);
917 });
918 server.on('error', reject);
919 server.listen(port, '127.0.0.1', () => {
920 server.removeListener('error', reject);
921 resolve({
922 onConnected: () => { return connected; }
923 });
924 });
925 });
926}
927exports.createClientSocketTransport = createClientSocketTransport;
928function createServerSocketTransport(port, encoding = 'utf-8') {
929 const socket = net_1.createConnection(port, '127.0.0.1');
930 return [
931 new messageReader_1.SocketMessageReader(socket, encoding),
932 new messageWriter_1.SocketMessageWriter(socket, encoding)
933 ];
934}
935exports.createServerSocketTransport = createServerSocketTransport;
936
937
938/***/ }),
939
940/***/ 2:
941/***/ (function(module, exports, __webpack_require__) {
942
943"use strict";
944
945Object.defineProperty(exports, "__esModule", { value: true });
946exports.sortTexts = {
947 one: "00001",
948 two: "00002",
949 three: "00003",
950 four: "00004",
951};
952exports.projectRootPatterns = [".git", "autoload", "plugin"];
953
954
955/***/ }),
956
957/***/ 20:
958/***/ (function(module, __webpack_exports__, __webpack_require__) {
959
960"use strict";
961__webpack_require__.r(__webpack_exports__);
962/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Position", function() { return Position; });
963/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Range", function() { return Range; });
964/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Location", function() { return Location; });
965/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocationLink", function() { return LocationLink; });
966/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return Color; });
967/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorInformation", function() { return ColorInformation; });
968/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPresentation", function() { return ColorPresentation; });
969/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRangeKind", function() { return FoldingRangeKind; });
970/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRange", function() { return FoldingRange; });
971/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticRelatedInformation", function() { return DiagnosticRelatedInformation; });
972/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticSeverity", function() { return DiagnosticSeverity; });
973/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Diagnostic", function() { return Diagnostic; });
974/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Command", function() { return Command; });
975/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextEdit", function() { return TextEdit; });
976/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentEdit", function() { return TextDocumentEdit; });
977/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CreateFile", function() { return CreateFile; });
978/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenameFile", function() { return RenameFile; });
979/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeleteFile", function() { return DeleteFile; });
980/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceEdit", function() { return WorkspaceEdit; });
981/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceChange", function() { return WorkspaceChange; });
982/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentIdentifier", function() { return TextDocumentIdentifier; });
983/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VersionedTextDocumentIdentifier", function() { return VersionedTextDocumentIdentifier; });
984/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentItem", function() { return TextDocumentItem; });
985/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupKind", function() { return MarkupKind; });
986/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupContent", function() { return MarkupContent; });
987/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemKind", function() { return CompletionItemKind; });
988/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InsertTextFormat", function() { return InsertTextFormat; });
989/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItem", function() { return CompletionItem; });
990/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionList", function() { return CompletionList; });
991/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkedString", function() { return MarkedString; });
992/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hover", function() { return Hover; });
993/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParameterInformation", function() { return ParameterInformation; });
994/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SignatureInformation", function() { return SignatureInformation; });
995/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlightKind", function() { return DocumentHighlightKind; });
996/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlight", function() { return DocumentHighlight; });
997/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolKind", function() { return SymbolKind; });
998/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolInformation", function() { return SymbolInformation; });
999/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentSymbol", function() { return DocumentSymbol; });
1000/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionKind", function() { return CodeActionKind; });
1001/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionContext", function() { return CodeActionContext; });
1002/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeAction", function() { return CodeAction; });
1003/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeLens", function() { return CodeLens; });
1004/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormattingOptions", function() { return FormattingOptions; });
1005/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentLink", function() { return DocumentLink; });
1006/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EOL", function() { return EOL; });
1007/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocument", function() { return TextDocument; });
1008/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentSaveReason", function() { return TextDocumentSaveReason; });
1009/* --------------------------------------------------------------------------------------------
1010 * Copyright (c) Microsoft Corporation. All rights reserved.
1011 * Licensed under the MIT License. See License.txt in the project root for license information.
1012 * ------------------------------------------------------------------------------------------ */
1013
1014/**
1015 * The Position namespace provides helper functions to work with
1016 * [Position](#Position) literals.
1017 */
1018var Position;
1019(function (Position) {
1020 /**
1021 * Creates a new Position literal from the given line and character.
1022 * @param line The position's line.
1023 * @param character The position's character.
1024 */
1025 function create(line, character) {
1026 return { line: line, character: character };
1027 }
1028 Position.create = create;
1029 /**
1030 * Checks whether the given liternal conforms to the [Position](#Position) interface.
1031 */
1032 function is(value) {
1033 var candidate = value;
1034 return Is.objectLiteral(candidate) && Is.number(candidate.line) && Is.number(candidate.character);
1035 }
1036 Position.is = is;
1037})(Position || (Position = {}));
1038/**
1039 * The Range namespace provides helper functions to work with
1040 * [Range](#Range) literals.
1041 */
1042var Range;
1043(function (Range) {
1044 function create(one, two, three, four) {
1045 if (Is.number(one) && Is.number(two) && Is.number(three) && Is.number(four)) {
1046 return { start: Position.create(one, two), end: Position.create(three, four) };
1047 }
1048 else if (Position.is(one) && Position.is(two)) {
1049 return { start: one, end: two };
1050 }
1051 else {
1052 throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
1053 }
1054 }
1055 Range.create = create;
1056 /**
1057 * Checks whether the given literal conforms to the [Range](#Range) interface.
1058 */
1059 function is(value) {
1060 var candidate = value;
1061 return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
1062 }
1063 Range.is = is;
1064})(Range || (Range = {}));
1065/**
1066 * The Location namespace provides helper functions to work with
1067 * [Location](#Location) literals.
1068 */
1069var Location;
1070(function (Location) {
1071 /**
1072 * Creates a Location literal.
1073 * @param uri The location's uri.
1074 * @param range The location's range.
1075 */
1076 function create(uri, range) {
1077 return { uri: uri, range: range };
1078 }
1079 Location.create = create;
1080 /**
1081 * Checks whether the given literal conforms to the [Location](#Location) interface.
1082 */
1083 function is(value) {
1084 var candidate = value;
1085 return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
1086 }
1087 Location.is = is;
1088})(Location || (Location = {}));
1089/**
1090 * The LocationLink namespace provides helper functions to work with
1091 * [LocationLink](#LocationLink) literals.
1092 */
1093var LocationLink;
1094(function (LocationLink) {
1095 /**
1096 * Creates a LocationLink literal.
1097 * @param targetUri The definition's uri.
1098 * @param targetRange The full range of the definition.
1099 * @param targetSelectionRange The span of the symbol definition at the target.
1100 * @param originSelectionRange The span of the symbol being defined in the originating source file.
1101 */
1102 function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
1103 return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };
1104 }
1105 LocationLink.create = create;
1106 /**
1107 * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.
1108 */
1109 function is(value) {
1110 var candidate = value;
1111 return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)
1112 && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))
1113 && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
1114 }
1115 LocationLink.is = is;
1116})(LocationLink || (LocationLink = {}));
1117/**
1118 * The Color namespace provides helper functions to work with
1119 * [Color](#Color) literals.
1120 */
1121var Color;
1122(function (Color) {
1123 /**
1124 * Creates a new Color literal.
1125 */
1126 function create(red, green, blue, alpha) {
1127 return {
1128 red: red,
1129 green: green,
1130 blue: blue,
1131 alpha: alpha,
1132 };
1133 }
1134 Color.create = create;
1135 /**
1136 * Checks whether the given literal conforms to the [Color](#Color) interface.
1137 */
1138 function is(value) {
1139 var candidate = value;
1140 return Is.number(candidate.red)
1141 && Is.number(candidate.green)
1142 && Is.number(candidate.blue)
1143 && Is.number(candidate.alpha);
1144 }
1145 Color.is = is;
1146})(Color || (Color = {}));
1147/**
1148 * The ColorInformation namespace provides helper functions to work with
1149 * [ColorInformation](#ColorInformation) literals.
1150 */
1151var ColorInformation;
1152(function (ColorInformation) {
1153 /**
1154 * Creates a new ColorInformation literal.
1155 */
1156 function create(range, color) {
1157 return {
1158 range: range,
1159 color: color,
1160 };
1161 }
1162 ColorInformation.create = create;
1163 /**
1164 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
1165 */
1166 function is(value) {
1167 var candidate = value;
1168 return Range.is(candidate.range) && Color.is(candidate.color);
1169 }
1170 ColorInformation.is = is;
1171})(ColorInformation || (ColorInformation = {}));
1172/**
1173 * The Color namespace provides helper functions to work with
1174 * [ColorPresentation](#ColorPresentation) literals.
1175 */
1176var ColorPresentation;
1177(function (ColorPresentation) {
1178 /**
1179 * Creates a new ColorInformation literal.
1180 */
1181 function create(label, textEdit, additionalTextEdits) {
1182 return {
1183 label: label,
1184 textEdit: textEdit,
1185 additionalTextEdits: additionalTextEdits,
1186 };
1187 }
1188 ColorPresentation.create = create;
1189 /**
1190 * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
1191 */
1192 function is(value) {
1193 var candidate = value;
1194 return Is.string(candidate.label)
1195 && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))
1196 && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
1197 }
1198 ColorPresentation.is = is;
1199})(ColorPresentation || (ColorPresentation = {}));
1200/**
1201 * Enum of known range kinds
1202 */
1203var FoldingRangeKind;
1204(function (FoldingRangeKind) {
1205 /**
1206 * Folding range for a comment
1207 */
1208 FoldingRangeKind["Comment"] = "comment";
1209 /**
1210 * Folding range for a imports or includes
1211 */
1212 FoldingRangeKind["Imports"] = "imports";
1213 /**
1214 * Folding range for a region (e.g. `#region`)
1215 */
1216 FoldingRangeKind["Region"] = "region";
1217})(FoldingRangeKind || (FoldingRangeKind = {}));
1218/**
1219 * The folding range namespace provides helper functions to work with
1220 * [FoldingRange](#FoldingRange) literals.
1221 */
1222var FoldingRange;
1223(function (FoldingRange) {
1224 /**
1225 * Creates a new FoldingRange literal.
1226 */
1227 function create(startLine, endLine, startCharacter, endCharacter, kind) {
1228 var result = {
1229 startLine: startLine,
1230 endLine: endLine
1231 };
1232 if (Is.defined(startCharacter)) {
1233 result.startCharacter = startCharacter;
1234 }
1235 if (Is.defined(endCharacter)) {
1236 result.endCharacter = endCharacter;
1237 }
1238 if (Is.defined(kind)) {
1239 result.kind = kind;
1240 }
1241 return result;
1242 }
1243 FoldingRange.create = create;
1244 /**
1245 * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.
1246 */
1247 function is(value) {
1248 var candidate = value;
1249 return Is.number(candidate.startLine) && Is.number(candidate.startLine)
1250 && (Is.undefined(candidate.startCharacter) || Is.number(candidate.startCharacter))
1251 && (Is.undefined(candidate.endCharacter) || Is.number(candidate.endCharacter))
1252 && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
1253 }
1254 FoldingRange.is = is;
1255})(FoldingRange || (FoldingRange = {}));
1256/**
1257 * The DiagnosticRelatedInformation namespace provides helper functions to work with
1258 * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
1259 */
1260var DiagnosticRelatedInformation;
1261(function (DiagnosticRelatedInformation) {
1262 /**
1263 * Creates a new DiagnosticRelatedInformation literal.
1264 */
1265 function create(location, message) {
1266 return {
1267 location: location,
1268 message: message
1269 };
1270 }
1271 DiagnosticRelatedInformation.create = create;
1272 /**
1273 * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.
1274 */
1275 function is(value) {
1276 var candidate = value;
1277 return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
1278 }
1279 DiagnosticRelatedInformation.is = is;
1280})(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
1281/**
1282 * The diagnostic's severity.
1283 */
1284var DiagnosticSeverity;
1285(function (DiagnosticSeverity) {
1286 /**
1287 * Reports an error.
1288 */
1289 DiagnosticSeverity.Error = 1;
1290 /**
1291 * Reports a warning.
1292 */
1293 DiagnosticSeverity.Warning = 2;
1294 /**
1295 * Reports an information.
1296 */
1297 DiagnosticSeverity.Information = 3;
1298 /**
1299 * Reports a hint.
1300 */
1301 DiagnosticSeverity.Hint = 4;
1302})(DiagnosticSeverity || (DiagnosticSeverity = {}));
1303/**
1304 * The Diagnostic namespace provides helper functions to work with
1305 * [Diagnostic](#Diagnostic) literals.
1306 */
1307var Diagnostic;
1308(function (Diagnostic) {
1309 /**
1310 * Creates a new Diagnostic literal.
1311 */
1312 function create(range, message, severity, code, source, relatedInformation) {
1313 var result = { range: range, message: message };
1314 if (Is.defined(severity)) {
1315 result.severity = severity;
1316 }
1317 if (Is.defined(code)) {
1318 result.code = code;
1319 }
1320 if (Is.defined(source)) {
1321 result.source = source;
1322 }
1323 if (Is.defined(relatedInformation)) {
1324 result.relatedInformation = relatedInformation;
1325 }
1326 return result;
1327 }
1328 Diagnostic.create = create;
1329 /**
1330 * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
1331 */
1332 function is(value) {
1333 var candidate = value;
1334 return Is.defined(candidate)
1335 && Range.is(candidate.range)
1336 && Is.string(candidate.message)
1337 && (Is.number(candidate.severity) || Is.undefined(candidate.severity))
1338 && (Is.number(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))
1339 && (Is.string(candidate.source) || Is.undefined(candidate.source))
1340 && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
1341 }
1342 Diagnostic.is = is;
1343})(Diagnostic || (Diagnostic = {}));
1344/**
1345 * The Command namespace provides helper functions to work with
1346 * [Command](#Command) literals.
1347 */
1348var Command;
1349(function (Command) {
1350 /**
1351 * Creates a new Command literal.
1352 */
1353 function create(title, command) {
1354 var args = [];
1355 for (var _i = 2; _i < arguments.length; _i++) {
1356 args[_i - 2] = arguments[_i];
1357 }
1358 var result = { title: title, command: command };
1359 if (Is.defined(args) && args.length > 0) {
1360 result.arguments = args;
1361 }
1362 return result;
1363 }
1364 Command.create = create;
1365 /**
1366 * Checks whether the given literal conforms to the [Command](#Command) interface.
1367 */
1368 function is(value) {
1369 var candidate = value;
1370 return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
1371 }
1372 Command.is = is;
1373})(Command || (Command = {}));
1374/**
1375 * The TextEdit namespace provides helper function to create replace,
1376 * insert and delete edits more easily.
1377 */
1378var TextEdit;
1379(function (TextEdit) {
1380 /**
1381 * Creates a replace text edit.
1382 * @param range The range of text to be replaced.
1383 * @param newText The new text.
1384 */
1385 function replace(range, newText) {
1386 return { range: range, newText: newText };
1387 }
1388 TextEdit.replace = replace;
1389 /**
1390 * Creates a insert text edit.
1391 * @param position The position to insert the text at.
1392 * @param newText The text to be inserted.
1393 */
1394 function insert(position, newText) {
1395 return { range: { start: position, end: position }, newText: newText };
1396 }
1397 TextEdit.insert = insert;
1398 /**
1399 * Creates a delete text edit.
1400 * @param range The range of text to be deleted.
1401 */
1402 function del(range) {
1403 return { range: range, newText: '' };
1404 }
1405 TextEdit.del = del;
1406 function is(value) {
1407 var candidate = value;
1408 return Is.objectLiteral(candidate)
1409 && Is.string(candidate.newText)
1410 && Range.is(candidate.range);
1411 }
1412 TextEdit.is = is;
1413})(TextEdit || (TextEdit = {}));
1414/**
1415 * The TextDocumentEdit namespace provides helper function to create
1416 * an edit that manipulates a text document.
1417 */
1418var TextDocumentEdit;
1419(function (TextDocumentEdit) {
1420 /**
1421 * Creates a new `TextDocumentEdit`
1422 */
1423 function create(textDocument, edits) {
1424 return { textDocument: textDocument, edits: edits };
1425 }
1426 TextDocumentEdit.create = create;
1427 function is(value) {
1428 var candidate = value;
1429 return Is.defined(candidate)
1430 && VersionedTextDocumentIdentifier.is(candidate.textDocument)
1431 && Array.isArray(candidate.edits);
1432 }
1433 TextDocumentEdit.is = is;
1434})(TextDocumentEdit || (TextDocumentEdit = {}));
1435var CreateFile;
1436(function (CreateFile) {
1437 function create(uri, options) {
1438 var result = {
1439 kind: 'create',
1440 uri: uri
1441 };
1442 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
1443 result.options = options;
1444 }
1445 return result;
1446 }
1447 CreateFile.create = create;
1448 function is(value) {
1449 var candidate = value;
1450 return candidate && candidate.kind === 'create' && Is.string(candidate.uri) &&
1451 (candidate.options === void 0 ||
1452 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
1453 }
1454 CreateFile.is = is;
1455})(CreateFile || (CreateFile = {}));
1456var RenameFile;
1457(function (RenameFile) {
1458 function create(oldUri, newUri, options) {
1459 var result = {
1460 kind: 'rename',
1461 oldUri: oldUri,
1462 newUri: newUri
1463 };
1464 if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
1465 result.options = options;
1466 }
1467 return result;
1468 }
1469 RenameFile.create = create;
1470 function is(value) {
1471 var candidate = value;
1472 return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) &&
1473 (candidate.options === void 0 ||
1474 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
1475 }
1476 RenameFile.is = is;
1477})(RenameFile || (RenameFile = {}));
1478var DeleteFile;
1479(function (DeleteFile) {
1480 function create(uri, options) {
1481 var result = {
1482 kind: 'delete',
1483 uri: uri
1484 };
1485 if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
1486 result.options = options;
1487 }
1488 return result;
1489 }
1490 DeleteFile.create = create;
1491 function is(value) {
1492 var candidate = value;
1493 return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) &&
1494 (candidate.options === void 0 ||
1495 ((candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))));
1496 }
1497 DeleteFile.is = is;
1498})(DeleteFile || (DeleteFile = {}));
1499var WorkspaceEdit;
1500(function (WorkspaceEdit) {
1501 function is(value) {
1502 var candidate = value;
1503 return candidate &&
1504 (candidate.changes !== void 0 || candidate.documentChanges !== void 0) &&
1505 (candidate.documentChanges === void 0 || candidate.documentChanges.every(function (change) {
1506 if (Is.string(change.kind)) {
1507 return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
1508 }
1509 else {
1510 return TextDocumentEdit.is(change);
1511 }
1512 }));
1513 }
1514 WorkspaceEdit.is = is;
1515})(WorkspaceEdit || (WorkspaceEdit = {}));
1516var TextEditChangeImpl = /** @class */ (function () {
1517 function TextEditChangeImpl(edits) {
1518 this.edits = edits;
1519 }
1520 TextEditChangeImpl.prototype.insert = function (position, newText) {
1521 this.edits.push(TextEdit.insert(position, newText));
1522 };
1523 TextEditChangeImpl.prototype.replace = function (range, newText) {
1524 this.edits.push(TextEdit.replace(range, newText));
1525 };
1526 TextEditChangeImpl.prototype.delete = function (range) {
1527 this.edits.push(TextEdit.del(range));
1528 };
1529 TextEditChangeImpl.prototype.add = function (edit) {
1530 this.edits.push(edit);
1531 };
1532 TextEditChangeImpl.prototype.all = function () {
1533 return this.edits;
1534 };
1535 TextEditChangeImpl.prototype.clear = function () {
1536 this.edits.splice(0, this.edits.length);
1537 };
1538 return TextEditChangeImpl;
1539}());
1540/**
1541 * A workspace change helps constructing changes to a workspace.
1542 */
1543var WorkspaceChange = /** @class */ (function () {
1544 function WorkspaceChange(workspaceEdit) {
1545 var _this = this;
1546 this._textEditChanges = Object.create(null);
1547 if (workspaceEdit) {
1548 this._workspaceEdit = workspaceEdit;
1549 if (workspaceEdit.documentChanges) {
1550 workspaceEdit.documentChanges.forEach(function (change) {
1551 if (TextDocumentEdit.is(change)) {
1552 var textEditChange = new TextEditChangeImpl(change.edits);
1553 _this._textEditChanges[change.textDocument.uri] = textEditChange;
1554 }
1555 });
1556 }
1557 else if (workspaceEdit.changes) {
1558 Object.keys(workspaceEdit.changes).forEach(function (key) {
1559 var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
1560 _this._textEditChanges[key] = textEditChange;
1561 });
1562 }
1563 }
1564 }
1565 Object.defineProperty(WorkspaceChange.prototype, "edit", {
1566 /**
1567 * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
1568 * use to be returned from a workspace edit operation like rename.
1569 */
1570 get: function () {
1571 return this._workspaceEdit;
1572 },
1573 enumerable: true,
1574 configurable: true
1575 });
1576 WorkspaceChange.prototype.getTextEditChange = function (key) {
1577 if (VersionedTextDocumentIdentifier.is(key)) {
1578 if (!this._workspaceEdit) {
1579 this._workspaceEdit = {
1580 documentChanges: []
1581 };
1582 }
1583 if (!this._workspaceEdit.documentChanges) {
1584 throw new Error('Workspace edit is not configured for document changes.');
1585 }
1586 var textDocument = key;
1587 var result = this._textEditChanges[textDocument.uri];
1588 if (!result) {
1589 var edits = [];
1590 var textDocumentEdit = {
1591 textDocument: textDocument,
1592 edits: edits
1593 };
1594 this._workspaceEdit.documentChanges.push(textDocumentEdit);
1595 result = new TextEditChangeImpl(edits);
1596 this._textEditChanges[textDocument.uri] = result;
1597 }
1598 return result;
1599 }
1600 else {
1601 if (!this._workspaceEdit) {
1602 this._workspaceEdit = {
1603 changes: Object.create(null)
1604 };
1605 }
1606 if (!this._workspaceEdit.changes) {
1607 throw new Error('Workspace edit is not configured for normal text edit changes.');
1608 }
1609 var result = this._textEditChanges[key];
1610 if (!result) {
1611 var edits = [];
1612 this._workspaceEdit.changes[key] = edits;
1613 result = new TextEditChangeImpl(edits);
1614 this._textEditChanges[key] = result;
1615 }
1616 return result;
1617 }
1618 };
1619 WorkspaceChange.prototype.createFile = function (uri, options) {
1620 this.checkDocumentChanges();
1621 this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options));
1622 };
1623 WorkspaceChange.prototype.renameFile = function (oldUri, newUri, options) {
1624 this.checkDocumentChanges();
1625 this._workspaceEdit.documentChanges.push(RenameFile.create(oldUri, newUri, options));
1626 };
1627 WorkspaceChange.prototype.deleteFile = function (uri, options) {
1628 this.checkDocumentChanges();
1629 this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options));
1630 };
1631 WorkspaceChange.prototype.checkDocumentChanges = function () {
1632 if (!this._workspaceEdit || !this._workspaceEdit.documentChanges) {
1633 throw new Error('Workspace edit is not configured for document changes.');
1634 }
1635 };
1636 return WorkspaceChange;
1637}());
1638
1639/**
1640 * The TextDocumentIdentifier namespace provides helper functions to work with
1641 * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
1642 */
1643var TextDocumentIdentifier;
1644(function (TextDocumentIdentifier) {
1645 /**
1646 * Creates a new TextDocumentIdentifier literal.
1647 * @param uri The document's uri.
1648 */
1649 function create(uri) {
1650 return { uri: uri };
1651 }
1652 TextDocumentIdentifier.create = create;
1653 /**
1654 * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
1655 */
1656 function is(value) {
1657 var candidate = value;
1658 return Is.defined(candidate) && Is.string(candidate.uri);
1659 }
1660 TextDocumentIdentifier.is = is;
1661})(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
1662/**
1663 * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
1664 * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
1665 */
1666var VersionedTextDocumentIdentifier;
1667(function (VersionedTextDocumentIdentifier) {
1668 /**
1669 * Creates a new VersionedTextDocumentIdentifier literal.
1670 * @param uri The document's uri.
1671 * @param uri The document's text.
1672 */
1673 function create(uri, version) {
1674 return { uri: uri, version: version };
1675 }
1676 VersionedTextDocumentIdentifier.create = create;
1677 /**
1678 * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
1679 */
1680 function is(value) {
1681 var candidate = value;
1682 return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.number(candidate.version));
1683 }
1684 VersionedTextDocumentIdentifier.is = is;
1685})(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
1686/**
1687 * The TextDocumentItem namespace provides helper functions to work with
1688 * [TextDocumentItem](#TextDocumentItem) literals.
1689 */
1690var TextDocumentItem;
1691(function (TextDocumentItem) {
1692 /**
1693 * Creates a new TextDocumentItem literal.
1694 * @param uri The document's uri.
1695 * @param languageId The document's language identifier.
1696 * @param version The document's version number.
1697 * @param text The document's text.
1698 */
1699 function create(uri, languageId, version, text) {
1700 return { uri: uri, languageId: languageId, version: version, text: text };
1701 }
1702 TextDocumentItem.create = create;
1703 /**
1704 * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
1705 */
1706 function is(value) {
1707 var candidate = value;
1708 return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.number(candidate.version) && Is.string(candidate.text);
1709 }
1710 TextDocumentItem.is = is;
1711})(TextDocumentItem || (TextDocumentItem = {}));
1712/**
1713 * Describes the content type that a client supports in various
1714 * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
1715 *
1716 * Please note that `MarkupKinds` must not start with a `$`. This kinds
1717 * are reserved for internal usage.
1718 */
1719var MarkupKind;
1720(function (MarkupKind) {
1721 /**
1722 * Plain text is supported as a content format
1723 */
1724 MarkupKind.PlainText = 'plaintext';
1725 /**
1726 * Markdown is supported as a content format
1727 */
1728 MarkupKind.Markdown = 'markdown';
1729})(MarkupKind || (MarkupKind = {}));
1730(function (MarkupKind) {
1731 /**
1732 * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.
1733 */
1734 function is(value) {
1735 var candidate = value;
1736 return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
1737 }
1738 MarkupKind.is = is;
1739})(MarkupKind || (MarkupKind = {}));
1740var MarkupContent;
1741(function (MarkupContent) {
1742 /**
1743 * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.
1744 */
1745 function is(value) {
1746 var candidate = value;
1747 return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
1748 }
1749 MarkupContent.is = is;
1750})(MarkupContent || (MarkupContent = {}));
1751/**
1752 * The kind of a completion entry.
1753 */
1754var CompletionItemKind;
1755(function (CompletionItemKind) {
1756 CompletionItemKind.Text = 1;
1757 CompletionItemKind.Method = 2;
1758 CompletionItemKind.Function = 3;
1759 CompletionItemKind.Constructor = 4;
1760 CompletionItemKind.Field = 5;
1761 CompletionItemKind.Variable = 6;
1762 CompletionItemKind.Class = 7;
1763 CompletionItemKind.Interface = 8;
1764 CompletionItemKind.Module = 9;
1765 CompletionItemKind.Property = 10;
1766 CompletionItemKind.Unit = 11;
1767 CompletionItemKind.Value = 12;
1768 CompletionItemKind.Enum = 13;
1769 CompletionItemKind.Keyword = 14;
1770 CompletionItemKind.Snippet = 15;
1771 CompletionItemKind.Color = 16;
1772 CompletionItemKind.File = 17;
1773 CompletionItemKind.Reference = 18;
1774 CompletionItemKind.Folder = 19;
1775 CompletionItemKind.EnumMember = 20;
1776 CompletionItemKind.Constant = 21;
1777 CompletionItemKind.Struct = 22;
1778 CompletionItemKind.Event = 23;
1779 CompletionItemKind.Operator = 24;
1780 CompletionItemKind.TypeParameter = 25;
1781})(CompletionItemKind || (CompletionItemKind = {}));
1782/**
1783 * Defines whether the insert text in a completion item should be interpreted as
1784 * plain text or a snippet.
1785 */
1786var InsertTextFormat;
1787(function (InsertTextFormat) {
1788 /**
1789 * The primary text to be inserted is treated as a plain string.
1790 */
1791 InsertTextFormat.PlainText = 1;
1792 /**
1793 * The primary text to be inserted is treated as a snippet.
1794 *
1795 * A snippet can define tab stops and placeholders with `$1`, `$2`
1796 * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
1797 * the end of the snippet. Placeholders with equal identifiers are linked,
1798 * that is typing in one will update others too.
1799 *
1800 * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
1801 */
1802 InsertTextFormat.Snippet = 2;
1803})(InsertTextFormat || (InsertTextFormat = {}));
1804/**
1805 * The CompletionItem namespace provides functions to deal with
1806 * completion items.
1807 */
1808var CompletionItem;
1809(function (CompletionItem) {
1810 /**
1811 * Create a completion item and seed it with a label.
1812 * @param label The completion item's label
1813 */
1814 function create(label) {
1815 return { label: label };
1816 }
1817 CompletionItem.create = create;
1818})(CompletionItem || (CompletionItem = {}));
1819/**
1820 * The CompletionList namespace provides functions to deal with
1821 * completion lists.
1822 */
1823var CompletionList;
1824(function (CompletionList) {
1825 /**
1826 * Creates a new completion list.
1827 *
1828 * @param items The completion items.
1829 * @param isIncomplete The list is not complete.
1830 */
1831 function create(items, isIncomplete) {
1832 return { items: items ? items : [], isIncomplete: !!isIncomplete };
1833 }
1834 CompletionList.create = create;
1835})(CompletionList || (CompletionList = {}));
1836var MarkedString;
1837(function (MarkedString) {
1838 /**
1839 * Creates a marked string from plain text.
1840 *
1841 * @param plainText The plain text.
1842 */
1843 function fromPlainText(plainText) {
1844 return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&"); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
1845 }
1846 MarkedString.fromPlainText = fromPlainText;
1847 /**
1848 * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.
1849 */
1850 function is(value) {
1851 var candidate = value;
1852 return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));
1853 }
1854 MarkedString.is = is;
1855})(MarkedString || (MarkedString = {}));
1856var Hover;
1857(function (Hover) {
1858 /**
1859 * Checks whether the given value conforms to the [Hover](#Hover) interface.
1860 */
1861 function is(value) {
1862 var candidate = value;
1863 return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||
1864 MarkedString.is(candidate.contents) ||
1865 Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
1866 }
1867 Hover.is = is;
1868})(Hover || (Hover = {}));
1869/**
1870 * The ParameterInformation namespace provides helper functions to work with
1871 * [ParameterInformation](#ParameterInformation) literals.
1872 */
1873var ParameterInformation;
1874(function (ParameterInformation) {
1875 /**
1876 * Creates a new parameter information literal.
1877 *
1878 * @param label A label string.
1879 * @param documentation A doc string.
1880 */
1881 function create(label, documentation) {
1882 return documentation ? { label: label, documentation: documentation } : { label: label };
1883 }
1884 ParameterInformation.create = create;
1885 ;
1886})(ParameterInformation || (ParameterInformation = {}));
1887/**
1888 * The SignatureInformation namespace provides helper functions to work with
1889 * [SignatureInformation](#SignatureInformation) literals.
1890 */
1891var SignatureInformation;
1892(function (SignatureInformation) {
1893 function create(label, documentation) {
1894 var parameters = [];
1895 for (var _i = 2; _i < arguments.length; _i++) {
1896 parameters[_i - 2] = arguments[_i];
1897 }
1898 var result = { label: label };
1899 if (Is.defined(documentation)) {
1900 result.documentation = documentation;
1901 }
1902 if (Is.defined(parameters)) {
1903 result.parameters = parameters;
1904 }
1905 else {
1906 result.parameters = [];
1907 }
1908 return result;
1909 }
1910 SignatureInformation.create = create;
1911})(SignatureInformation || (SignatureInformation = {}));
1912/**
1913 * A document highlight kind.
1914 */
1915var DocumentHighlightKind;
1916(function (DocumentHighlightKind) {
1917 /**
1918 * A textual occurrence.
1919 */
1920 DocumentHighlightKind.Text = 1;
1921 /**
1922 * Read-access of a symbol, like reading a variable.
1923 */
1924 DocumentHighlightKind.Read = 2;
1925 /**
1926 * Write-access of a symbol, like writing to a variable.
1927 */
1928 DocumentHighlightKind.Write = 3;
1929})(DocumentHighlightKind || (DocumentHighlightKind = {}));
1930/**
1931 * DocumentHighlight namespace to provide helper functions to work with
1932 * [DocumentHighlight](#DocumentHighlight) literals.
1933 */
1934var DocumentHighlight;
1935(function (DocumentHighlight) {
1936 /**
1937 * Create a DocumentHighlight object.
1938 * @param range The range the highlight applies to.
1939 */
1940 function create(range, kind) {
1941 var result = { range: range };
1942 if (Is.number(kind)) {
1943 result.kind = kind;
1944 }
1945 return result;
1946 }
1947 DocumentHighlight.create = create;
1948})(DocumentHighlight || (DocumentHighlight = {}));
1949/**
1950 * A symbol kind.
1951 */
1952var SymbolKind;
1953(function (SymbolKind) {
1954 SymbolKind.File = 1;
1955 SymbolKind.Module = 2;
1956 SymbolKind.Namespace = 3;
1957 SymbolKind.Package = 4;
1958 SymbolKind.Class = 5;
1959 SymbolKind.Method = 6;
1960 SymbolKind.Property = 7;
1961 SymbolKind.Field = 8;
1962 SymbolKind.Constructor = 9;
1963 SymbolKind.Enum = 10;
1964 SymbolKind.Interface = 11;
1965 SymbolKind.Function = 12;
1966 SymbolKind.Variable = 13;
1967 SymbolKind.Constant = 14;
1968 SymbolKind.String = 15;
1969 SymbolKind.Number = 16;
1970 SymbolKind.Boolean = 17;
1971 SymbolKind.Array = 18;
1972 SymbolKind.Object = 19;
1973 SymbolKind.Key = 20;
1974 SymbolKind.Null = 21;
1975 SymbolKind.EnumMember = 22;
1976 SymbolKind.Struct = 23;
1977 SymbolKind.Event = 24;
1978 SymbolKind.Operator = 25;
1979 SymbolKind.TypeParameter = 26;
1980})(SymbolKind || (SymbolKind = {}));
1981var SymbolInformation;
1982(function (SymbolInformation) {
1983 /**
1984 * Creates a new symbol information literal.
1985 *
1986 * @param name The name of the symbol.
1987 * @param kind The kind of the symbol.
1988 * @param range The range of the location of the symbol.
1989 * @param uri The resource of the location of symbol, defaults to the current document.
1990 * @param containerName The name of the symbol containing the symbol.
1991 */
1992 function create(name, kind, range, uri, containerName) {
1993 var result = {
1994 name: name,
1995 kind: kind,
1996 location: { uri: uri, range: range }
1997 };
1998 if (containerName) {
1999 result.containerName = containerName;
2000 }
2001 return result;
2002 }
2003 SymbolInformation.create = create;
2004})(SymbolInformation || (SymbolInformation = {}));
2005/**
2006 * Represents programming constructs like variables, classes, interfaces etc.
2007 * that appear in a document. Document symbols can be hierarchical and they
2008 * have two ranges: one that encloses its definition and one that points to
2009 * its most interesting range, e.g. the range of an identifier.
2010 */
2011var DocumentSymbol = /** @class */ (function () {
2012 function DocumentSymbol() {
2013 }
2014 return DocumentSymbol;
2015}());
2016
2017(function (DocumentSymbol) {
2018 /**
2019 * Creates a new symbol information literal.
2020 *
2021 * @param name The name of the symbol.
2022 * @param detail The detail of the symbol.
2023 * @param kind The kind of the symbol.
2024 * @param range The range of the symbol.
2025 * @param selectionRange The selectionRange of the symbol.
2026 * @param children Children of the symbol.
2027 */
2028 function create(name, detail, kind, range, selectionRange, children) {
2029 var result = {
2030 name: name,
2031 detail: detail,
2032 kind: kind,
2033 range: range,
2034 selectionRange: selectionRange
2035 };
2036 if (children !== void 0) {
2037 result.children = children;
2038 }
2039 return result;
2040 }
2041 DocumentSymbol.create = create;
2042 /**
2043 * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.
2044 */
2045 function is(value) {
2046 var candidate = value;
2047 return candidate &&
2048 Is.string(candidate.name) && Is.number(candidate.kind) &&
2049 Range.is(candidate.range) && Range.is(candidate.selectionRange) &&
2050 (candidate.detail === void 0 || Is.string(candidate.detail)) &&
2051 (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) &&
2052 (candidate.children === void 0 || Array.isArray(candidate.children));
2053 }
2054 DocumentSymbol.is = is;
2055})(DocumentSymbol || (DocumentSymbol = {}));
2056/**
2057 * A set of predefined code action kinds
2058 */
2059var CodeActionKind;
2060(function (CodeActionKind) {
2061 /**
2062 * Base kind for quickfix actions: 'quickfix'
2063 */
2064 CodeActionKind.QuickFix = 'quickfix';
2065 /**
2066 * Base kind for refactoring actions: 'refactor'
2067 */
2068 CodeActionKind.Refactor = 'refactor';
2069 /**
2070 * Base kind for refactoring extraction actions: 'refactor.extract'
2071 *
2072 * Example extract actions:
2073 *
2074 * - Extract method
2075 * - Extract function
2076 * - Extract variable
2077 * - Extract interface from class
2078 * - ...
2079 */
2080 CodeActionKind.RefactorExtract = 'refactor.extract';
2081 /**
2082 * Base kind for refactoring inline actions: 'refactor.inline'
2083 *
2084 * Example inline actions:
2085 *
2086 * - Inline function
2087 * - Inline variable
2088 * - Inline constant
2089 * - ...
2090 */
2091 CodeActionKind.RefactorInline = 'refactor.inline';
2092 /**
2093 * Base kind for refactoring rewrite actions: 'refactor.rewrite'
2094 *
2095 * Example rewrite actions:
2096 *
2097 * - Convert JavaScript function to class
2098 * - Add or remove parameter
2099 * - Encapsulate field
2100 * - Make method static
2101 * - Move method to base class
2102 * - ...
2103 */
2104 CodeActionKind.RefactorRewrite = 'refactor.rewrite';
2105 /**
2106 * Base kind for source actions: `source`
2107 *
2108 * Source code actions apply to the entire file.
2109 */
2110 CodeActionKind.Source = 'source';
2111 /**
2112 * Base kind for an organize imports source action: `source.organizeImports`
2113 */
2114 CodeActionKind.SourceOrganizeImports = 'source.organizeImports';
2115})(CodeActionKind || (CodeActionKind = {}));
2116/**
2117 * The CodeActionContext namespace provides helper functions to work with
2118 * [CodeActionContext](#CodeActionContext) literals.
2119 */
2120var CodeActionContext;
2121(function (CodeActionContext) {
2122 /**
2123 * Creates a new CodeActionContext literal.
2124 */
2125 function create(diagnostics, only) {
2126 var result = { diagnostics: diagnostics };
2127 if (only !== void 0 && only !== null) {
2128 result.only = only;
2129 }
2130 return result;
2131 }
2132 CodeActionContext.create = create;
2133 /**
2134 * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
2135 */
2136 function is(value) {
2137 var candidate = value;
2138 return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
2139 }
2140 CodeActionContext.is = is;
2141})(CodeActionContext || (CodeActionContext = {}));
2142var CodeAction;
2143(function (CodeAction) {
2144 function create(title, commandOrEdit, kind) {
2145 var result = { title: title };
2146 if (Command.is(commandOrEdit)) {
2147 result.command = commandOrEdit;
2148 }
2149 else {
2150 result.edit = commandOrEdit;
2151 }
2152 if (kind !== void null) {
2153 result.kind = kind;
2154 }
2155 return result;
2156 }
2157 CodeAction.create = create;
2158 function is(value) {
2159 var candidate = value;
2160 return candidate && Is.string(candidate.title) &&
2161 (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&
2162 (candidate.kind === void 0 || Is.string(candidate.kind)) &&
2163 (candidate.edit !== void 0 || candidate.command !== void 0) &&
2164 (candidate.command === void 0 || Command.is(candidate.command)) &&
2165 (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
2166 }
2167 CodeAction.is = is;
2168})(CodeAction || (CodeAction = {}));
2169/**
2170 * The CodeLens namespace provides helper functions to work with
2171 * [CodeLens](#CodeLens) literals.
2172 */
2173var CodeLens;
2174(function (CodeLens) {
2175 /**
2176 * Creates a new CodeLens literal.
2177 */
2178 function create(range, data) {
2179 var result = { range: range };
2180 if (Is.defined(data))
2181 result.data = data;
2182 return result;
2183 }
2184 CodeLens.create = create;
2185 /**
2186 * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
2187 */
2188 function is(value) {
2189 var candidate = value;
2190 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
2191 }
2192 CodeLens.is = is;
2193})(CodeLens || (CodeLens = {}));
2194/**
2195 * The FormattingOptions namespace provides helper functions to work with
2196 * [FormattingOptions](#FormattingOptions) literals.
2197 */
2198var FormattingOptions;
2199(function (FormattingOptions) {
2200 /**
2201 * Creates a new FormattingOptions literal.
2202 */
2203 function create(tabSize, insertSpaces) {
2204 return { tabSize: tabSize, insertSpaces: insertSpaces };
2205 }
2206 FormattingOptions.create = create;
2207 /**
2208 * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
2209 */
2210 function is(value) {
2211 var candidate = value;
2212 return Is.defined(candidate) && Is.number(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
2213 }
2214 FormattingOptions.is = is;
2215})(FormattingOptions || (FormattingOptions = {}));
2216/**
2217 * A document link is a range in a text document that links to an internal or external resource, like another
2218 * text document or a web site.
2219 */
2220var DocumentLink = /** @class */ (function () {
2221 function DocumentLink() {
2222 }
2223 return DocumentLink;
2224}());
2225
2226/**
2227 * The DocumentLink namespace provides helper functions to work with
2228 * [DocumentLink](#DocumentLink) literals.
2229 */
2230(function (DocumentLink) {
2231 /**
2232 * Creates a new DocumentLink literal.
2233 */
2234 function create(range, target, data) {
2235 return { range: range, target: target, data: data };
2236 }
2237 DocumentLink.create = create;
2238 /**
2239 * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
2240 */
2241 function is(value) {
2242 var candidate = value;
2243 return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
2244 }
2245 DocumentLink.is = is;
2246})(DocumentLink || (DocumentLink = {}));
2247var EOL = ['\n', '\r\n', '\r'];
2248var TextDocument;
2249(function (TextDocument) {
2250 /**
2251 * Creates a new ITextDocument literal from the given uri and content.
2252 * @param uri The document's uri.
2253 * @param languageId The document's language Id.
2254 * @param content The document's content.
2255 */
2256 function create(uri, languageId, version, content) {
2257 return new FullTextDocument(uri, languageId, version, content);
2258 }
2259 TextDocument.create = create;
2260 /**
2261 * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
2262 */
2263 function is(value) {
2264 var candidate = value;
2265 return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.number(candidate.lineCount)
2266 && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
2267 }
2268 TextDocument.is = is;
2269 function applyEdits(document, edits) {
2270 var text = document.getText();
2271 var sortedEdits = mergeSort(edits, function (a, b) {
2272 var diff = a.range.start.line - b.range.start.line;
2273 if (diff === 0) {
2274 return a.range.start.character - b.range.start.character;
2275 }
2276 return diff;
2277 });
2278 var lastModifiedOffset = text.length;
2279 for (var i = sortedEdits.length - 1; i >= 0; i--) {
2280 var e = sortedEdits[i];
2281 var startOffset = document.offsetAt(e.range.start);
2282 var endOffset = document.offsetAt(e.range.end);
2283 if (endOffset <= lastModifiedOffset) {
2284 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
2285 }
2286 else {
2287 throw new Error('Overlapping edit');
2288 }
2289 lastModifiedOffset = startOffset;
2290 }
2291 return text;
2292 }
2293 TextDocument.applyEdits = applyEdits;
2294 function mergeSort(data, compare) {
2295 if (data.length <= 1) {
2296 // sorted
2297 return data;
2298 }
2299 var p = (data.length / 2) | 0;
2300 var left = data.slice(0, p);
2301 var right = data.slice(p);
2302 mergeSort(left, compare);
2303 mergeSort(right, compare);
2304 var leftIdx = 0;
2305 var rightIdx = 0;
2306 var i = 0;
2307 while (leftIdx < left.length && rightIdx < right.length) {
2308 var ret = compare(left[leftIdx], right[rightIdx]);
2309 if (ret <= 0) {
2310 // smaller_equal -> take left to preserve order
2311 data[i++] = left[leftIdx++];
2312 }
2313 else {
2314 // greater -> take right
2315 data[i++] = right[rightIdx++];
2316 }
2317 }
2318 while (leftIdx < left.length) {
2319 data[i++] = left[leftIdx++];
2320 }
2321 while (rightIdx < right.length) {
2322 data[i++] = right[rightIdx++];
2323 }
2324 return data;
2325 }
2326})(TextDocument || (TextDocument = {}));
2327/**
2328 * Represents reasons why a text document is saved.
2329 */
2330var TextDocumentSaveReason;
2331(function (TextDocumentSaveReason) {
2332 /**
2333 * Manually triggered, e.g. by the user pressing save, by starting debugging,
2334 * or by an API call.
2335 */
2336 TextDocumentSaveReason.Manual = 1;
2337 /**
2338 * Automatic after a delay.
2339 */
2340 TextDocumentSaveReason.AfterDelay = 2;
2341 /**
2342 * When the editor lost focus.
2343 */
2344 TextDocumentSaveReason.FocusOut = 3;
2345})(TextDocumentSaveReason || (TextDocumentSaveReason = {}));
2346var FullTextDocument = /** @class */ (function () {
2347 function FullTextDocument(uri, languageId, version, content) {
2348 this._uri = uri;
2349 this._languageId = languageId;
2350 this._version = version;
2351 this._content = content;
2352 this._lineOffsets = null;
2353 }
2354 Object.defineProperty(FullTextDocument.prototype, "uri", {
2355 get: function () {
2356 return this._uri;
2357 },
2358 enumerable: true,
2359 configurable: true
2360 });
2361 Object.defineProperty(FullTextDocument.prototype, "languageId", {
2362 get: function () {
2363 return this._languageId;
2364 },
2365 enumerable: true,
2366 configurable: true
2367 });
2368 Object.defineProperty(FullTextDocument.prototype, "version", {
2369 get: function () {
2370 return this._version;
2371 },
2372 enumerable: true,
2373 configurable: true
2374 });
2375 FullTextDocument.prototype.getText = function (range) {
2376 if (range) {
2377 var start = this.offsetAt(range.start);
2378 var end = this.offsetAt(range.end);
2379 return this._content.substring(start, end);
2380 }
2381 return this._content;
2382 };
2383 FullTextDocument.prototype.update = function (event, version) {
2384 this._content = event.text;
2385 this._version = version;
2386 this._lineOffsets = null;
2387 };
2388 FullTextDocument.prototype.getLineOffsets = function () {
2389 if (this._lineOffsets === null) {
2390 var lineOffsets = [];
2391 var text = this._content;
2392 var isLineStart = true;
2393 for (var i = 0; i < text.length; i++) {
2394 if (isLineStart) {
2395 lineOffsets.push(i);
2396 isLineStart = false;
2397 }
2398 var ch = text.charAt(i);
2399 isLineStart = (ch === '\r' || ch === '\n');
2400 if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
2401 i++;
2402 }
2403 }
2404 if (isLineStart && text.length > 0) {
2405 lineOffsets.push(text.length);
2406 }
2407 this._lineOffsets = lineOffsets;
2408 }
2409 return this._lineOffsets;
2410 };
2411 FullTextDocument.prototype.positionAt = function (offset) {
2412 offset = Math.max(Math.min(offset, this._content.length), 0);
2413 var lineOffsets = this.getLineOffsets();
2414 var low = 0, high = lineOffsets.length;
2415 if (high === 0) {
2416 return Position.create(0, offset);
2417 }
2418 while (low < high) {
2419 var mid = Math.floor((low + high) / 2);
2420 if (lineOffsets[mid] > offset) {
2421 high = mid;
2422 }
2423 else {
2424 low = mid + 1;
2425 }
2426 }
2427 // low is the least x for which the line offset is larger than the current offset
2428 // or array.length if no line offset is larger than the current offset
2429 var line = low - 1;
2430 return Position.create(line, offset - lineOffsets[line]);
2431 };
2432 FullTextDocument.prototype.offsetAt = function (position) {
2433 var lineOffsets = this.getLineOffsets();
2434 if (position.line >= lineOffsets.length) {
2435 return this._content.length;
2436 }
2437 else if (position.line < 0) {
2438 return 0;
2439 }
2440 var lineOffset = lineOffsets[position.line];
2441 var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
2442 return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
2443 };
2444 Object.defineProperty(FullTextDocument.prototype, "lineCount", {
2445 get: function () {
2446 return this.getLineOffsets().length;
2447 },
2448 enumerable: true,
2449 configurable: true
2450 });
2451 return FullTextDocument;
2452}());
2453var Is;
2454(function (Is) {
2455 var toString = Object.prototype.toString;
2456 function defined(value) {
2457 return typeof value !== 'undefined';
2458 }
2459 Is.defined = defined;
2460 function undefined(value) {
2461 return typeof value === 'undefined';
2462 }
2463 Is.undefined = undefined;
2464 function boolean(value) {
2465 return value === true || value === false;
2466 }
2467 Is.boolean = boolean;
2468 function string(value) {
2469 return toString.call(value) === '[object String]';
2470 }
2471 Is.string = string;
2472 function number(value) {
2473 return toString.call(value) === '[object Number]';
2474 }
2475 Is.number = number;
2476 function func(value) {
2477 return toString.call(value) === '[object Function]';
2478 }
2479 Is.func = func;
2480 function objectLiteral(value) {
2481 // Strictly speaking class instances pass this check as well. Since the LSP
2482 // doesn't use classes we ignore this for now. If we do we need to add something
2483 // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
2484 return value !== null && typeof value === 'object';
2485 }
2486 Is.objectLiteral = objectLiteral;
2487 function typedArray(value, check) {
2488 return Array.isArray(value) && value.every(check);
2489 }
2490 Is.typedArray = typedArray;
2491})(Is || (Is = {}));
2492
2493
2494/***/ }),
2495
2496/***/ 21:
2497/***/ (function(module, exports, __webpack_require__) {
2498
2499"use strict";
2500/* --------------------------------------------------------------------------------------------
2501 * Copyright (c) Microsoft Corporation. All rights reserved.
2502 * Licensed under the MIT License. See License.txt in the project root for license information.
2503 * ------------------------------------------------------------------------------------------ */
2504
2505Object.defineProperty(exports, "__esModule", { value: true });
2506const Is = __webpack_require__(22);
2507const vscode_jsonrpc_1 = __webpack_require__(6);
2508const protocol_implementation_1 = __webpack_require__(23);
2509exports.ImplementationRequest = protocol_implementation_1.ImplementationRequest;
2510const protocol_typeDefinition_1 = __webpack_require__(24);
2511exports.TypeDefinitionRequest = protocol_typeDefinition_1.TypeDefinitionRequest;
2512const protocol_workspaceFolders_1 = __webpack_require__(25);
2513exports.WorkspaceFoldersRequest = protocol_workspaceFolders_1.WorkspaceFoldersRequest;
2514exports.DidChangeWorkspaceFoldersNotification = protocol_workspaceFolders_1.DidChangeWorkspaceFoldersNotification;
2515const protocol_configuration_1 = __webpack_require__(26);
2516exports.ConfigurationRequest = protocol_configuration_1.ConfigurationRequest;
2517const protocol_colorProvider_1 = __webpack_require__(27);
2518exports.DocumentColorRequest = protocol_colorProvider_1.DocumentColorRequest;
2519exports.ColorPresentationRequest = protocol_colorProvider_1.ColorPresentationRequest;
2520const protocol_foldingRange_1 = __webpack_require__(28);
2521exports.FoldingRangeRequest = protocol_foldingRange_1.FoldingRangeRequest;
2522const protocol_declaration_1 = __webpack_require__(29);
2523exports.DeclarationRequest = protocol_declaration_1.DeclarationRequest;
2524// @ts-ignore: to avoid inlining LocatioLink as dynamic import
2525let __noDynamicImport;
2526var DocumentFilter;
2527(function (DocumentFilter) {
2528 function is(value) {
2529 let candidate = value;
2530 return Is.string(candidate.language) || Is.string(candidate.scheme) || Is.string(candidate.pattern);
2531 }
2532 DocumentFilter.is = is;
2533})(DocumentFilter = exports.DocumentFilter || (exports.DocumentFilter = {}));
2534/**
2535 * The `client/registerCapability` request is sent from the server to the client to register a new capability
2536 * handler on the client side.
2537 */
2538var RegistrationRequest;
2539(function (RegistrationRequest) {
2540 RegistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/registerCapability');
2541})(RegistrationRequest = exports.RegistrationRequest || (exports.RegistrationRequest = {}));
2542/**
2543 * The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability
2544 * handler on the client side.
2545 */
2546var UnregistrationRequest;
2547(function (UnregistrationRequest) {
2548 UnregistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/unregisterCapability');
2549})(UnregistrationRequest = exports.UnregistrationRequest || (exports.UnregistrationRequest = {}));
2550var ResourceOperationKind;
2551(function (ResourceOperationKind) {
2552 /**
2553 * Supports creating new files and folders.
2554 */
2555 ResourceOperationKind.Create = 'create';
2556 /**
2557 * Supports renaming existing files and folders.
2558 */
2559 ResourceOperationKind.Rename = 'rename';
2560 /**
2561 * Supports deleting existing files and folders.
2562 */
2563 ResourceOperationKind.Delete = 'delete';
2564})(ResourceOperationKind = exports.ResourceOperationKind || (exports.ResourceOperationKind = {}));
2565var FailureHandlingKind;
2566(function (FailureHandlingKind) {
2567 /**
2568 * Applying the workspace change is simply aborted if one of the changes provided
2569 * fails. All operations executed before the failing operation stay executed.
2570 */
2571 FailureHandlingKind.Abort = 'abort';
2572 /**
2573 * All operations are executed transactional. That means they either all
2574 * succeed or no changes at all are applied to the workspace.
2575 */
2576 FailureHandlingKind.Transactional = 'transactional';
2577 /**
2578 * If the workspace edit contains only textual file changes they are executed transactional.
2579 * If resource changes (create, rename or delete file) are part of the change the failure
2580 * handling startegy is abort.
2581 */
2582 FailureHandlingKind.TextOnlyTransactional = 'textOnlyTransactional';
2583 /**
2584 * The client tries to undo the operations already executed. But there is no
2585 * guaruntee that this is succeeding.
2586 */
2587 FailureHandlingKind.Undo = 'undo';
2588})(FailureHandlingKind = exports.FailureHandlingKind || (exports.FailureHandlingKind = {}));
2589/**
2590 * Defines how the host (editor) should sync
2591 * document changes to the language server.
2592 */
2593var TextDocumentSyncKind;
2594(function (TextDocumentSyncKind) {
2595 /**
2596 * Documents should not be synced at all.
2597 */
2598 TextDocumentSyncKind.None = 0;
2599 /**
2600 * Documents are synced by always sending the full content
2601 * of the document.
2602 */
2603 TextDocumentSyncKind.Full = 1;
2604 /**
2605 * Documents are synced by sending the full content on open.
2606 * After that only incremental updates to the document are
2607 * send.
2608 */
2609 TextDocumentSyncKind.Incremental = 2;
2610})(TextDocumentSyncKind = exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));
2611/**
2612 * The initialize request is sent from the client to the server.
2613 * It is sent once as the request after starting up the server.
2614 * The requests parameter is of type [InitializeParams](#InitializeParams)
2615 * the response if of type [InitializeResult](#InitializeResult) of a Thenable that
2616 * resolves to such.
2617 */
2618var InitializeRequest;
2619(function (InitializeRequest) {
2620 InitializeRequest.type = new vscode_jsonrpc_1.RequestType('initialize');
2621})(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));
2622/**
2623 * Known error codes for an `InitializeError`;
2624 */
2625var InitializeError;
2626(function (InitializeError) {
2627 /**
2628 * If the protocol version provided by the client can't be handled by the server.
2629 * @deprecated This initialize error got replaced by client capabilities. There is
2630 * no version handshake in version 3.0x
2631 */
2632 InitializeError.unknownProtocolVersion = 1;
2633})(InitializeError = exports.InitializeError || (exports.InitializeError = {}));
2634/**
2635 * The intialized notification is sent from the client to the
2636 * server after the client is fully initialized and the server
2637 * is allowed to send requests from the server to the client.
2638 */
2639var InitializedNotification;
2640(function (InitializedNotification) {
2641 InitializedNotification.type = new vscode_jsonrpc_1.NotificationType('initialized');
2642})(InitializedNotification = exports.InitializedNotification || (exports.InitializedNotification = {}));
2643//---- Shutdown Method ----
2644/**
2645 * A shutdown request is sent from the client to the server.
2646 * It is sent once when the client decides to shutdown the
2647 * server. The only notification that is sent after a shutdown request
2648 * is the exit event.
2649 */
2650var ShutdownRequest;
2651(function (ShutdownRequest) {
2652 ShutdownRequest.type = new vscode_jsonrpc_1.RequestType0('shutdown');
2653})(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));
2654//---- Exit Notification ----
2655/**
2656 * The exit event is sent from the client to the server to
2657 * ask the server to exit its process.
2658 */
2659var ExitNotification;
2660(function (ExitNotification) {
2661 ExitNotification.type = new vscode_jsonrpc_1.NotificationType0('exit');
2662})(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));
2663//---- Configuration notification ----
2664/**
2665 * The configuration change notification is sent from the client to the server
2666 * when the client's configuration has changed. The notification contains
2667 * the changed configuration as defined by the language client.
2668 */
2669var DidChangeConfigurationNotification;
2670(function (DidChangeConfigurationNotification) {
2671 DidChangeConfigurationNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeConfiguration');
2672})(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));
2673//---- Message show and log notifications ----
2674/**
2675 * The message type
2676 */
2677var MessageType;
2678(function (MessageType) {
2679 /**
2680 * An error message.
2681 */
2682 MessageType.Error = 1;
2683 /**
2684 * A warning message.
2685 */
2686 MessageType.Warning = 2;
2687 /**
2688 * An information message.
2689 */
2690 MessageType.Info = 3;
2691 /**
2692 * A log message.
2693 */
2694 MessageType.Log = 4;
2695})(MessageType = exports.MessageType || (exports.MessageType = {}));
2696/**
2697 * The show message notification is sent from a server to a client to ask
2698 * the client to display a particular message in the user interface.
2699 */
2700var ShowMessageNotification;
2701(function (ShowMessageNotification) {
2702 ShowMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/showMessage');
2703})(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));
2704/**
2705 * The show message request is sent from the server to the client to show a message
2706 * and a set of options actions to the user.
2707 */
2708var ShowMessageRequest;
2709(function (ShowMessageRequest) {
2710 ShowMessageRequest.type = new vscode_jsonrpc_1.RequestType('window/showMessageRequest');
2711})(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));
2712/**
2713 * The log message notification is sent from the server to the client to ask
2714 * the client to log a particular message.
2715 */
2716var LogMessageNotification;
2717(function (LogMessageNotification) {
2718 LogMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/logMessage');
2719})(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));
2720//---- Telemetry notification
2721/**
2722 * The telemetry event notification is sent from the server to the client to ask
2723 * the client to log telemetry data.
2724 */
2725var TelemetryEventNotification;
2726(function (TelemetryEventNotification) {
2727 TelemetryEventNotification.type = new vscode_jsonrpc_1.NotificationType('telemetry/event');
2728})(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));
2729/**
2730 * The document open notification is sent from the client to the server to signal
2731 * newly opened text documents. The document's truth is now managed by the client
2732 * and the server must not try to read the document's truth using the document's
2733 * uri. Open in this sense means it is managed by the client. It doesn't necessarily
2734 * mean that its content is presented in an editor. An open notification must not
2735 * be sent more than once without a corresponding close notification send before.
2736 * This means open and close notification must be balanced and the max open count
2737 * is one.
2738 */
2739var DidOpenTextDocumentNotification;
2740(function (DidOpenTextDocumentNotification) {
2741 DidOpenTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didOpen');
2742})(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));
2743/**
2744 * The document change notification is sent from the client to the server to signal
2745 * changes to a text document.
2746 */
2747var DidChangeTextDocumentNotification;
2748(function (DidChangeTextDocumentNotification) {
2749 DidChangeTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didChange');
2750})(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));
2751/**
2752 * The document close notification is sent from the client to the server when
2753 * the document got closed in the client. The document's truth now exists where
2754 * the document's uri points to (e.g. if the document's uri is a file uri the
2755 * truth now exists on disk). As with the open notification the close notification
2756 * is about managing the document's content. Receiving a close notification
2757 * doesn't mean that the document was open in an editor before. A close
2758 * notification requires a previous open notification to be sent.
2759 */
2760var DidCloseTextDocumentNotification;
2761(function (DidCloseTextDocumentNotification) {
2762 DidCloseTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didClose');
2763})(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));
2764/**
2765 * The document save notification is sent from the client to the server when
2766 * the document got saved in the client.
2767 */
2768var DidSaveTextDocumentNotification;
2769(function (DidSaveTextDocumentNotification) {
2770 DidSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didSave');
2771})(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));
2772/**
2773 * A document will save notification is sent from the client to the server before
2774 * the document is actually saved.
2775 */
2776var WillSaveTextDocumentNotification;
2777(function (WillSaveTextDocumentNotification) {
2778 WillSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/willSave');
2779})(WillSaveTextDocumentNotification = exports.WillSaveTextDocumentNotification || (exports.WillSaveTextDocumentNotification = {}));
2780/**
2781 * A document will save request is sent from the client to the server before
2782 * the document is actually saved. The request can return an array of TextEdits
2783 * which will be applied to the text document before it is saved. Please note that
2784 * clients might drop results if computing the text edits took too long or if a
2785 * server constantly fails on this request. This is done to keep the save fast and
2786 * reliable.
2787 */
2788var WillSaveTextDocumentWaitUntilRequest;
2789(function (WillSaveTextDocumentWaitUntilRequest) {
2790 WillSaveTextDocumentWaitUntilRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/willSaveWaitUntil');
2791})(WillSaveTextDocumentWaitUntilRequest = exports.WillSaveTextDocumentWaitUntilRequest || (exports.WillSaveTextDocumentWaitUntilRequest = {}));
2792//---- File eventing ----
2793/**
2794 * The watched files notification is sent from the client to the server when
2795 * the client detects changes to file watched by the language client.
2796 */
2797var DidChangeWatchedFilesNotification;
2798(function (DidChangeWatchedFilesNotification) {
2799 DidChangeWatchedFilesNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWatchedFiles');
2800})(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));
2801/**
2802 * The file event type
2803 */
2804var FileChangeType;
2805(function (FileChangeType) {
2806 /**
2807 * The file got created.
2808 */
2809 FileChangeType.Created = 1;
2810 /**
2811 * The file got changed.
2812 */
2813 FileChangeType.Changed = 2;
2814 /**
2815 * The file got deleted.
2816 */
2817 FileChangeType.Deleted = 3;
2818})(FileChangeType = exports.FileChangeType || (exports.FileChangeType = {}));
2819var WatchKind;
2820(function (WatchKind) {
2821 /**
2822 * Interested in create events.
2823 */
2824 WatchKind.Create = 1;
2825 /**
2826 * Interested in change events
2827 */
2828 WatchKind.Change = 2;
2829 /**
2830 * Interested in delete events
2831 */
2832 WatchKind.Delete = 4;
2833})(WatchKind = exports.WatchKind || (exports.WatchKind = {}));
2834//---- Diagnostic notification ----
2835/**
2836 * Diagnostics notification are sent from the server to the client to signal
2837 * results of validation runs.
2838 */
2839var PublishDiagnosticsNotification;
2840(function (PublishDiagnosticsNotification) {
2841 PublishDiagnosticsNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/publishDiagnostics');
2842})(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));
2843/**
2844 * How a completion was triggered
2845 */
2846var CompletionTriggerKind;
2847(function (CompletionTriggerKind) {
2848 /**
2849 * Completion was triggered by typing an identifier (24x7 code
2850 * complete), manual invocation (e.g Ctrl+Space) or via API.
2851 */
2852 CompletionTriggerKind.Invoked = 1;
2853 /**
2854 * Completion was triggered by a trigger character specified by
2855 * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.
2856 */
2857 CompletionTriggerKind.TriggerCharacter = 2;
2858 /**
2859 * Completion was re-triggered as current completion list is incomplete
2860 */
2861 CompletionTriggerKind.TriggerForIncompleteCompletions = 3;
2862})(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));
2863/**
2864 * Request to request completion at a given text document position. The request's
2865 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response
2866 * is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)
2867 * or a Thenable that resolves to such.
2868 *
2869 * The request can delay the computation of the [`detail`](#CompletionItem.detail)
2870 * and [`documentation`](#CompletionItem.documentation) properties to the `completionItem/resolve`
2871 * request. However, properties that are needed for the initial sorting and filtering, like `sortText`,
2872 * `filterText`, `insertText`, and `textEdit`, must not be changed during resolve.
2873 */
2874var CompletionRequest;
2875(function (CompletionRequest) {
2876 CompletionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/completion');
2877})(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));
2878/**
2879 * Request to resolve additional information for a given completion item.The request's
2880 * parameter is of type [CompletionItem](#CompletionItem) the response
2881 * is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.
2882 */
2883var CompletionResolveRequest;
2884(function (CompletionResolveRequest) {
2885 CompletionResolveRequest.type = new vscode_jsonrpc_1.RequestType('completionItem/resolve');
2886})(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));
2887//---- Hover Support -------------------------------
2888/**
2889 * Request to request hover information at a given text document position. The request's
2890 * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of
2891 * type [Hover](#Hover) or a Thenable that resolves to such.
2892 */
2893var HoverRequest;
2894(function (HoverRequest) {
2895 HoverRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/hover');
2896})(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));
2897var SignatureHelpRequest;
2898(function (SignatureHelpRequest) {
2899 SignatureHelpRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/signatureHelp');
2900})(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));
2901//---- Goto Definition -------------------------------------
2902/**
2903 * A request to resolve the definition location of a symbol at a given text
2904 * document position. The request's parameter is of type [TextDocumentPosition]
2905 * (#TextDocumentPosition) the response is of either type [Definition](#Definition)
2906 * or a typed array of [DefinitionLink](#DefinitionLink) or a Thenable that resolves
2907 * to such.
2908 */
2909var DefinitionRequest;
2910(function (DefinitionRequest) {
2911 DefinitionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/definition');
2912})(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));
2913/**
2914 * A request to resolve project-wide references for the symbol denoted
2915 * by the given text document position. The request's parameter is of
2916 * type [ReferenceParams](#ReferenceParams) the response is of type
2917 * [Location[]](#Location) or a Thenable that resolves to such.
2918 */
2919var ReferencesRequest;
2920(function (ReferencesRequest) {
2921 ReferencesRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/references');
2922})(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));
2923//---- Document Highlight ----------------------------------
2924/**
2925 * Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given
2926 * text document position. The request's parameter is of type [TextDocumentPosition]
2927 * (#TextDocumentPosition) the request response is of type [DocumentHighlight[]]
2928 * (#DocumentHighlight) or a Thenable that resolves to such.
2929 */
2930var DocumentHighlightRequest;
2931(function (DocumentHighlightRequest) {
2932 DocumentHighlightRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentHighlight');
2933})(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));
2934//---- Document Symbol Provider ---------------------------
2935/**
2936 * A request to list all symbols found in a given text document. The request's
2937 * parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the
2938 * response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable
2939 * that resolves to such.
2940 */
2941var DocumentSymbolRequest;
2942(function (DocumentSymbolRequest) {
2943 DocumentSymbolRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentSymbol');
2944})(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));
2945//---- Workspace Symbol Provider ---------------------------
2946/**
2947 * A request to list project-wide symbols matching the query string given
2948 * by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is
2949 * of type [SymbolInformation[]](#SymbolInformation) or a Thenable that
2950 * resolves to such.
2951 */
2952var WorkspaceSymbolRequest;
2953(function (WorkspaceSymbolRequest) {
2954 WorkspaceSymbolRequest.type = new vscode_jsonrpc_1.RequestType('workspace/symbol');
2955})(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));
2956/**
2957 * A request to provide commands for the given text document and range.
2958 */
2959var CodeActionRequest;
2960(function (CodeActionRequest) {
2961 CodeActionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/codeAction');
2962})(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));
2963/**
2964 * A request to provide code lens for the given text document.
2965 */
2966var CodeLensRequest;
2967(function (CodeLensRequest) {
2968 CodeLensRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/codeLens');
2969})(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));
2970/**
2971 * A request to resolve a command for a given code lens.
2972 */
2973var CodeLensResolveRequest;
2974(function (CodeLensResolveRequest) {
2975 CodeLensResolveRequest.type = new vscode_jsonrpc_1.RequestType('codeLens/resolve');
2976})(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));
2977/**
2978 * A request to to format a whole document.
2979 */
2980var DocumentFormattingRequest;
2981(function (DocumentFormattingRequest) {
2982 DocumentFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/formatting');
2983})(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));
2984/**
2985 * A request to to format a range in a document.
2986 */
2987var DocumentRangeFormattingRequest;
2988(function (DocumentRangeFormattingRequest) {
2989 DocumentRangeFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/rangeFormatting');
2990})(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));
2991/**
2992 * A request to format a document on type.
2993 */
2994var DocumentOnTypeFormattingRequest;
2995(function (DocumentOnTypeFormattingRequest) {
2996 DocumentOnTypeFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/onTypeFormatting');
2997})(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));
2998/**
2999 * A request to rename a symbol.
3000 */
3001var RenameRequest;
3002(function (RenameRequest) {
3003 RenameRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/rename');
3004})(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));
3005/**
3006 * A request to test and perform the setup necessary for a rename.
3007 */
3008var PrepareRenameRequest;
3009(function (PrepareRenameRequest) {
3010 PrepareRenameRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/prepareRename');
3011})(PrepareRenameRequest = exports.PrepareRenameRequest || (exports.PrepareRenameRequest = {}));
3012/**
3013 * A request to provide document links
3014 */
3015var DocumentLinkRequest;
3016(function (DocumentLinkRequest) {
3017 DocumentLinkRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentLink');
3018})(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));
3019/**
3020 * Request to resolve additional information for a given document link. The request's
3021 * parameter is of type [DocumentLink](#DocumentLink) the response
3022 * is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.
3023 */
3024var DocumentLinkResolveRequest;
3025(function (DocumentLinkResolveRequest) {
3026 DocumentLinkResolveRequest.type = new vscode_jsonrpc_1.RequestType('documentLink/resolve');
3027})(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));
3028/**
3029 * A request send from the client to the server to execute a command. The request might return
3030 * a workspace edit which the client will apply to the workspace.
3031 */
3032var ExecuteCommandRequest;
3033(function (ExecuteCommandRequest) {
3034 ExecuteCommandRequest.type = new vscode_jsonrpc_1.RequestType('workspace/executeCommand');
3035})(ExecuteCommandRequest = exports.ExecuteCommandRequest || (exports.ExecuteCommandRequest = {}));
3036/**
3037 * A request sent from the server to the client to modified certain resources.
3038 */
3039var ApplyWorkspaceEditRequest;
3040(function (ApplyWorkspaceEditRequest) {
3041 ApplyWorkspaceEditRequest.type = new vscode_jsonrpc_1.RequestType('workspace/applyEdit');
3042})(ApplyWorkspaceEditRequest = exports.ApplyWorkspaceEditRequest || (exports.ApplyWorkspaceEditRequest = {}));
3043
3044
3045/***/ }),
3046
3047/***/ 22:
3048/***/ (function(module, exports, __webpack_require__) {
3049
3050"use strict";
3051/* --------------------------------------------------------------------------------------------
3052 * Copyright (c) Microsoft Corporation. All rights reserved.
3053 * Licensed under the MIT License. See License.txt in the project root for license information.
3054 * ------------------------------------------------------------------------------------------ */
3055
3056Object.defineProperty(exports, "__esModule", { value: true });
3057function boolean(value) {
3058 return value === true || value === false;
3059}
3060exports.boolean = boolean;
3061function string(value) {
3062 return typeof value === 'string' || value instanceof String;
3063}
3064exports.string = string;
3065function number(value) {
3066 return typeof value === 'number' || value instanceof Number;
3067}
3068exports.number = number;
3069function error(value) {
3070 return value instanceof Error;
3071}
3072exports.error = error;
3073function func(value) {
3074 return typeof value === 'function';
3075}
3076exports.func = func;
3077function array(value) {
3078 return Array.isArray(value);
3079}
3080exports.array = array;
3081function stringArray(value) {
3082 return array(value) && value.every(elem => string(elem));
3083}
3084exports.stringArray = stringArray;
3085function typedArray(value, check) {
3086 return Array.isArray(value) && value.every(check);
3087}
3088exports.typedArray = typedArray;
3089function thenable(value) {
3090 return value && func(value.then);
3091}
3092exports.thenable = thenable;
3093
3094
3095/***/ }),
3096
3097/***/ 23:
3098/***/ (function(module, exports, __webpack_require__) {
3099
3100"use strict";
3101/* --------------------------------------------------------------------------------------------
3102 * Copyright (c) Microsoft Corporation. All rights reserved.
3103 * Licensed under the MIT License. See License.txt in the project root for license information.
3104 * ------------------------------------------------------------------------------------------ */
3105
3106Object.defineProperty(exports, "__esModule", { value: true });
3107const vscode_jsonrpc_1 = __webpack_require__(6);
3108// @ts-ignore: to avoid inlining LocatioLink as dynamic import
3109let __noDynamicImport;
3110/**
3111 * A request to resolve the implementation locations of a symbol at a given text
3112 * document position. The request's parameter is of type [TextDocumentPositioParams]
3113 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
3114 * Thenable that resolves to such.
3115 */
3116var ImplementationRequest;
3117(function (ImplementationRequest) {
3118 ImplementationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/implementation');
3119})(ImplementationRequest = exports.ImplementationRequest || (exports.ImplementationRequest = {}));
3120
3121
3122/***/ }),
3123
3124/***/ 24:
3125/***/ (function(module, exports, __webpack_require__) {
3126
3127"use strict";
3128/* --------------------------------------------------------------------------------------------
3129 * Copyright (c) Microsoft Corporation. All rights reserved.
3130 * Licensed under the MIT License. See License.txt in the project root for license information.
3131 * ------------------------------------------------------------------------------------------ */
3132
3133Object.defineProperty(exports, "__esModule", { value: true });
3134const vscode_jsonrpc_1 = __webpack_require__(6);
3135// @ts-ignore: to avoid inlining LocatioLink as dynamic import
3136let __noDynamicImport;
3137/**
3138 * A request to resolve the type definition locations of a symbol at a given text
3139 * document position. The request's parameter is of type [TextDocumentPositioParams]
3140 * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a
3141 * Thenable that resolves to such.
3142 */
3143var TypeDefinitionRequest;
3144(function (TypeDefinitionRequest) {
3145 TypeDefinitionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/typeDefinition');
3146})(TypeDefinitionRequest = exports.TypeDefinitionRequest || (exports.TypeDefinitionRequest = {}));
3147
3148
3149/***/ }),
3150
3151/***/ 25:
3152/***/ (function(module, exports, __webpack_require__) {
3153
3154"use strict";
3155/* --------------------------------------------------------------------------------------------
3156 * Copyright (c) Microsoft Corporation. All rights reserved.
3157 * Licensed under the MIT License. See License.txt in the project root for license information.
3158 * ------------------------------------------------------------------------------------------ */
3159
3160Object.defineProperty(exports, "__esModule", { value: true });
3161const vscode_jsonrpc_1 = __webpack_require__(6);
3162/**
3163 * The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
3164 */
3165var WorkspaceFoldersRequest;
3166(function (WorkspaceFoldersRequest) {
3167 WorkspaceFoldersRequest.type = new vscode_jsonrpc_1.RequestType0('workspace/workspaceFolders');
3168})(WorkspaceFoldersRequest = exports.WorkspaceFoldersRequest || (exports.WorkspaceFoldersRequest = {}));
3169/**
3170 * The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace
3171 * folder configuration changes.
3172 */
3173var DidChangeWorkspaceFoldersNotification;
3174(function (DidChangeWorkspaceFoldersNotification) {
3175 DidChangeWorkspaceFoldersNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWorkspaceFolders');
3176})(DidChangeWorkspaceFoldersNotification = exports.DidChangeWorkspaceFoldersNotification || (exports.DidChangeWorkspaceFoldersNotification = {}));
3177
3178
3179/***/ }),
3180
3181/***/ 26:
3182/***/ (function(module, exports, __webpack_require__) {
3183
3184"use strict";
3185/* --------------------------------------------------------------------------------------------
3186 * Copyright (c) Microsoft Corporation. All rights reserved.
3187 * Licensed under the MIT License. See License.txt in the project root for license information.
3188 * ------------------------------------------------------------------------------------------ */
3189
3190Object.defineProperty(exports, "__esModule", { value: true });
3191const vscode_jsonrpc_1 = __webpack_require__(6);
3192/**
3193 * The 'workspace/configuration' request is sent from the server to the client to fetch a certain
3194 * configuration setting.
3195 *
3196 * This pull model replaces the old push model were the client signaled configuration change via an
3197 * event. If the server still needs to react to configuration changes (since the server caches the
3198 * result of `workspace/configuration` requests) the server should register for an empty configuration
3199 * change event and empty the cache if such an event is received.
3200 */
3201var ConfigurationRequest;
3202(function (ConfigurationRequest) {
3203 ConfigurationRequest.type = new vscode_jsonrpc_1.RequestType('workspace/configuration');
3204})(ConfigurationRequest = exports.ConfigurationRequest || (exports.ConfigurationRequest = {}));
3205
3206
3207/***/ }),
3208
3209/***/ 27:
3210/***/ (function(module, exports, __webpack_require__) {
3211
3212"use strict";
3213/* --------------------------------------------------------------------------------------------
3214 * Copyright (c) Microsoft Corporation. All rights reserved.
3215 * Licensed under the MIT License. See License.txt in the project root for license information.
3216 * ------------------------------------------------------------------------------------------ */
3217
3218Object.defineProperty(exports, "__esModule", { value: true });
3219const vscode_jsonrpc_1 = __webpack_require__(6);
3220/**
3221 * A request to list all color symbols found in a given text document. The request's
3222 * parameter is of type [DocumentColorParams](#DocumentColorParams) the
3223 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
3224 * that resolves to such.
3225 */
3226var DocumentColorRequest;
3227(function (DocumentColorRequest) {
3228 DocumentColorRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentColor');
3229})(DocumentColorRequest = exports.DocumentColorRequest || (exports.DocumentColorRequest = {}));
3230/**
3231 * A request to list all presentation for a color. The request's
3232 * parameter is of type [ColorPresentationParams](#ColorPresentationParams) the
3233 * response is of type [ColorInformation[]](#ColorInformation) or a Thenable
3234 * that resolves to such.
3235 */
3236var ColorPresentationRequest;
3237(function (ColorPresentationRequest) {
3238 ColorPresentationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/colorPresentation');
3239})(ColorPresentationRequest = exports.ColorPresentationRequest || (exports.ColorPresentationRequest = {}));
3240
3241
3242/***/ }),
3243
3244/***/ 28:
3245/***/ (function(module, exports, __webpack_require__) {
3246
3247"use strict";
3248
3249/*---------------------------------------------------------------------------------------------
3250 * Copyright (c) Microsoft Corporation. All rights reserved.
3251 * Licensed under the MIT License. See License.txt in the project root for license information.
3252 *--------------------------------------------------------------------------------------------*/
3253Object.defineProperty(exports, "__esModule", { value: true });
3254const vscode_jsonrpc_1 = __webpack_require__(6);
3255/**
3256 * Enum of known range kinds
3257 */
3258var FoldingRangeKind;
3259(function (FoldingRangeKind) {
3260 /**
3261 * Folding range for a comment
3262 */
3263 FoldingRangeKind["Comment"] = "comment";
3264 /**
3265 * Folding range for a imports or includes
3266 */
3267 FoldingRangeKind["Imports"] = "imports";
3268 /**
3269 * Folding range for a region (e.g. `#region`)
3270 */
3271 FoldingRangeKind["Region"] = "region";
3272})(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {}));
3273/**
3274 * A request to provide folding ranges in a document. The request's
3275 * parameter is of type [FoldingRangeParams](#FoldingRangeParams), the
3276 * response is of type [FoldingRangeList](#FoldingRangeList) or a Thenable
3277 * that resolves to such.
3278 */
3279var FoldingRangeRequest;
3280(function (FoldingRangeRequest) {
3281 FoldingRangeRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/foldingRange');
3282})(FoldingRangeRequest = exports.FoldingRangeRequest || (exports.FoldingRangeRequest = {}));
3283
3284
3285/***/ }),
3286
3287/***/ 29:
3288/***/ (function(module, exports, __webpack_require__) {
3289
3290"use strict";
3291/* --------------------------------------------------------------------------------------------
3292 * Copyright (c) Microsoft Corporation. All rights reserved.
3293 * Licensed under the MIT License. See License.txt in the project root for license information.
3294 * ------------------------------------------------------------------------------------------ */
3295
3296Object.defineProperty(exports, "__esModule", { value: true });
3297const vscode_jsonrpc_1 = __webpack_require__(6);
3298// @ts-ignore: to avoid inlining LocatioLink as dynamic import
3299let __noDynamicImport;
3300/**
3301 * A request to resolve the type definition locations of a symbol at a given text
3302 * document position. The request's parameter is of type [TextDocumentPositioParams]
3303 * (#TextDocumentPositionParams) the response is of type [Declaration](#Declaration)
3304 * or a typed array of [DeclarationLink](#DeclarationLink) or a Thenable that resolves
3305 * to such.
3306 */
3307var DeclarationRequest;
3308(function (DeclarationRequest) {
3309 DeclarationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/declaration');
3310})(DeclarationRequest = exports.DeclarationRequest || (exports.DeclarationRequest = {}));
3311
3312
3313/***/ }),
3314
3315/***/ 30:
3316/***/ (function(module, exports, __webpack_require__) {
3317
3318"use strict";
3319/* --------------------------------------------------------------------------------------------
3320 * Copyright (c) Microsoft Corporation. All rights reserved.
3321 * Licensed under the MIT License. See License.txt in the project root for license information.
3322 * ------------------------------------------------------------------------------------------ */
3323
3324Object.defineProperty(exports, "__esModule", { value: true });
3325const vscode_languageserver_protocol_1 = __webpack_require__(5);
3326const Is = __webpack_require__(31);
3327exports.ConfigurationFeature = (Base) => {
3328 return class extends Base {
3329 getConfiguration(arg) {
3330 if (!arg) {
3331 return this._getConfiguration({});
3332 }
3333 else if (Is.string(arg)) {
3334 return this._getConfiguration({ section: arg });
3335 }
3336 else {
3337 return this._getConfiguration(arg);
3338 }
3339 }
3340 _getConfiguration(arg) {
3341 let params = {
3342 items: Array.isArray(arg) ? arg : [arg]
3343 };
3344 return this.connection.sendRequest(vscode_languageserver_protocol_1.ConfigurationRequest.type, params).then((result) => {
3345 return Array.isArray(arg) ? result : result[0];
3346 });
3347 }
3348 };
3349};
3350
3351
3352/***/ }),
3353
3354/***/ 31:
3355/***/ (function(module, exports, __webpack_require__) {
3356
3357"use strict";
3358/* --------------------------------------------------------------------------------------------
3359 * Copyright (c) Microsoft Corporation. All rights reserved.
3360 * Licensed under the MIT License. See License.txt in the project root for license information.
3361 * ------------------------------------------------------------------------------------------ */
3362
3363Object.defineProperty(exports, "__esModule", { value: true });
3364function boolean(value) {
3365 return value === true || value === false;
3366}
3367exports.boolean = boolean;
3368function string(value) {
3369 return typeof value === 'string' || value instanceof String;
3370}
3371exports.string = string;
3372function number(value) {
3373 return typeof value === 'number' || value instanceof Number;
3374}
3375exports.number = number;
3376function error(value) {
3377 return value instanceof Error;
3378}
3379exports.error = error;
3380function func(value) {
3381 return typeof value === 'function';
3382}
3383exports.func = func;
3384function array(value) {
3385 return Array.isArray(value);
3386}
3387exports.array = array;
3388function stringArray(value) {
3389 return array(value) && value.every(elem => string(elem));
3390}
3391exports.stringArray = stringArray;
3392function typedArray(value, check) {
3393 return Array.isArray(value) && value.every(check);
3394}
3395exports.typedArray = typedArray;
3396function thenable(value) {
3397 return value && func(value.then);
3398}
3399exports.thenable = thenable;
3400
3401
3402/***/ }),
3403
3404/***/ 32:
3405/***/ (function(module, exports, __webpack_require__) {
3406
3407"use strict";
3408/* --------------------------------------------------------------------------------------------
3409 * Copyright (c) Microsoft Corporation. All rights reserved.
3410 * Licensed under the MIT License. See License.txt in the project root for license information.
3411 * ------------------------------------------------------------------------------------------ */
3412
3413Object.defineProperty(exports, "__esModule", { value: true });
3414const vscode_languageserver_protocol_1 = __webpack_require__(5);
3415exports.WorkspaceFoldersFeature = (Base) => {
3416 return class extends Base {
3417 initialize(capabilities) {
3418 let workspaceCapabilities = capabilities.workspace;
3419 if (workspaceCapabilities && workspaceCapabilities.workspaceFolders) {
3420 this._onDidChangeWorkspaceFolders = new vscode_languageserver_protocol_1.Emitter();
3421 this.connection.onNotification(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type, (params) => {
3422 this._onDidChangeWorkspaceFolders.fire(params.event);
3423 });
3424 }
3425 }
3426 getWorkspaceFolders() {
3427 return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkspaceFoldersRequest.type);
3428 }
3429 get onDidChangeWorkspaceFolders() {
3430 if (!this._onDidChangeWorkspaceFolders) {
3431 throw new Error('Client doesn\'t support sending workspace folder change events.');
3432 }
3433 if (!this._unregistration) {
3434 this._unregistration = this.connection.client.register(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type);
3435 }
3436 return this._onDidChangeWorkspaceFolders.event;
3437 }
3438 };
3439};
3440
3441
3442/***/ }),
3443
3444/***/ 33:
3445/***/ (function(module, exports, __webpack_require__) {
3446
3447"use strict";
3448/*---------------------------------------------------------------------------------------------
3449 * Copyright (c) Microsoft Corporation. All rights reserved.
3450 * Licensed under the MIT License. See License.txt in the project root for license information.
3451 *--------------------------------------------------------------------------------------------*/
3452
3453Object.defineProperty(exports, "__esModule", { value: true });
3454class ValueUUID {
3455 constructor(_value) {
3456 this._value = _value;
3457 // empty
3458 }
3459 asHex() {
3460 return this._value;
3461 }
3462 equals(other) {
3463 return this.asHex() === other.asHex();
3464 }
3465}
3466class V4UUID extends ValueUUID {
3467 constructor() {
3468 super([
3469 V4UUID._randomHex(),
3470 V4UUID._randomHex(),
3471 V4UUID._randomHex(),
3472 V4UUID._randomHex(),
3473 V4UUID._randomHex(),
3474 V4UUID._randomHex(),
3475 V4UUID._randomHex(),
3476 V4UUID._randomHex(),
3477 '-',
3478 V4UUID._randomHex(),
3479 V4UUID._randomHex(),
3480 V4UUID._randomHex(),
3481 V4UUID._randomHex(),
3482 '-',
3483 '4',
3484 V4UUID._randomHex(),
3485 V4UUID._randomHex(),
3486 V4UUID._randomHex(),
3487 '-',
3488 V4UUID._oneOf(V4UUID._timeHighBits),
3489 V4UUID._randomHex(),
3490 V4UUID._randomHex(),
3491 V4UUID._randomHex(),
3492 '-',
3493 V4UUID._randomHex(),
3494 V4UUID._randomHex(),
3495 V4UUID._randomHex(),
3496 V4UUID._randomHex(),
3497 V4UUID._randomHex(),
3498 V4UUID._randomHex(),
3499 V4UUID._randomHex(),
3500 V4UUID._randomHex(),
3501 V4UUID._randomHex(),
3502 V4UUID._randomHex(),
3503 V4UUID._randomHex(),
3504 V4UUID._randomHex(),
3505 ].join(''));
3506 }
3507 static _oneOf(array) {
3508 return array[Math.floor(array.length * Math.random())];
3509 }
3510 static _randomHex() {
3511 return V4UUID._oneOf(V4UUID._chars);
3512 }
3513}
3514V4UUID._chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];
3515V4UUID._timeHighBits = ['8', '9', 'a', 'b'];
3516/**
3517 * An empty UUID that contains only zeros.
3518 */
3519exports.empty = new ValueUUID('00000000-0000-0000-0000-000000000000');
3520function v4() {
3521 return new V4UUID();
3522}
3523exports.v4 = v4;
3524const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
3525function isUUID(value) {
3526 return _UUIDPattern.test(value);
3527}
3528exports.isUUID = isUUID;
3529/**
3530 * Parses a UUID that is of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.
3531 * @param value A uuid string.
3532 */
3533function parse(value) {
3534 if (!isUUID(value)) {
3535 throw new Error('invalid uuid');
3536 }
3537 return new ValueUUID(value);
3538}
3539exports.parse = parse;
3540function generateUuid() {
3541 return v4().asHex();
3542}
3543exports.generateUuid = generateUuid;
3544
3545
3546/***/ }),
3547
3548/***/ 34:
3549/***/ (function(module, exports, __webpack_require__) {
3550
3551"use strict";
3552/* --------------------------------------------------------------------------------------------
3553 * Copyright (c) Microsoft Corporation. All rights reserved.
3554 * Licensed under the MIT License. See License.txt in the project root for license information.
3555 * ------------------------------------------------------------------------------------------ */
3556
3557Object.defineProperty(exports, "__esModule", { value: true });
3558const url = __webpack_require__(35);
3559const path = __webpack_require__(15);
3560const fs = __webpack_require__(36);
3561const child_process_1 = __webpack_require__(37);
3562/**
3563 * @deprecated Use the `vscode-uri` npm module which provides a more
3564 * complete implementation of handling VS Code URIs.
3565 */
3566function uriToFilePath(uri) {
3567 let parsed = url.parse(uri);
3568 if (parsed.protocol !== 'file:' || !parsed.path) {
3569 return undefined;
3570 }
3571 let segments = parsed.path.split('/');
3572 for (var i = 0, len = segments.length; i < len; i++) {
3573 segments[i] = decodeURIComponent(segments[i]);
3574 }
3575 if (process.platform === 'win32' && segments.length > 1) {
3576 let first = segments[0];
3577 let second = segments[1];
3578 // Do we have a drive letter and we started with a / which is the
3579 // case if the first segement is empty (see split above)
3580 if (first.length === 0 && second.length > 1 && second[1] === ':') {
3581 // Remove first slash
3582 segments.shift();
3583 }
3584 }
3585 return path.normalize(segments.join('/'));
3586}
3587exports.uriToFilePath = uriToFilePath;
3588function isWindows() {
3589 return process.platform === 'win32';
3590}
3591function resolveModule(workspaceRoot, moduleName) {
3592 let nodePathKey = 'NODE_PATH';
3593 return new Promise((resolve, reject) => {
3594 let nodePath = [];
3595 if (workspaceRoot) {
3596 nodePath.push(path.join(workspaceRoot, 'node_modules'));
3597 }
3598 child_process_1.exec('npm config get prefix', (error, stdout, _stderr) => {
3599 if (!error) {
3600 let globalPath = stdout.replace(/[\s\r\n]+$/, '');
3601 if (globalPath.length > 0) {
3602 if (isWindows()) {
3603 nodePath.push(path.join(globalPath, 'node_modules'));
3604 }
3605 else {
3606 nodePath.push(path.join(globalPath, 'lib', 'node_modules'));
3607 }
3608 }
3609 }
3610 let separator = isWindows() ? ';' : ':';
3611 let env = process.env;
3612 let newEnv = Object.create(null);
3613 Object.keys(env).forEach(key => newEnv[key] = env[key]);
3614 if (newEnv[nodePathKey]) {
3615 newEnv[nodePathKey] = nodePath.join(separator) + separator + newEnv[nodePathKey];
3616 }
3617 else {
3618 newEnv[nodePathKey] = nodePath.join(separator);
3619 }
3620 newEnv['ELECTRON_RUN_AS_NODE'] = '1';
3621 try {
3622 let cp = child_process_1.fork(path.join(__dirname, 'resolve.js'), [], { env: newEnv, execArgv: [] });
3623 if (cp.pid === void 0) {
3624 reject(new Error(`Starting process to resolve node module ${moduleName} failed`));
3625 return;
3626 }
3627 cp.on('message', (message) => {
3628 if (message.command === 'resolve') {
3629 let toRequire = moduleName;
3630 if (message.success) {
3631 toRequire = message.result;
3632 }
3633 cp.send({ command: 'exit' });
3634 try {
3635 resolve(__webpack_require__(38)(toRequire));
3636 }
3637 catch (error) {
3638 reject(error);
3639 }
3640 }
3641 });
3642 let message = {
3643 command: 'resolve',
3644 args: moduleName
3645 };
3646 cp.send(message);
3647 }
3648 catch (error) {
3649 reject(error);
3650 }
3651 });
3652 });
3653}
3654exports.resolveModule = resolveModule;
3655function resolve(moduleName, nodePath, cwd, tracer) {
3656 const nodePathKey = 'NODE_PATH';
3657 const app = [
3658 "var p = process;",
3659 "p.on('message',function(m){",
3660 "if(m.c==='e'){",
3661 "p.exit(0);",
3662 "}",
3663 "else if(m.c==='rs'){",
3664 "try{",
3665 "var r=require.resolve(m.a);",
3666 "p.send({c:'r',s:true,r:r});",
3667 "}",
3668 "catch(err){",
3669 "p.send({c:'r',s:false});",
3670 "}",
3671 "}",
3672 "});"
3673 ].join('');
3674 return new Promise((resolve, reject) => {
3675 let env = process.env;
3676 let newEnv = Object.create(null);
3677 Object.keys(env).forEach(key => newEnv[key] = env[key]);
3678 if (nodePath) {
3679 if (newEnv[nodePathKey]) {
3680 newEnv[nodePathKey] = nodePath + path.delimiter + newEnv[nodePathKey];
3681 }
3682 else {
3683 newEnv[nodePathKey] = nodePath;
3684 }
3685 if (tracer) {
3686 tracer(`NODE_PATH value is: ${newEnv[nodePathKey]}`);
3687 }
3688 }
3689 newEnv['ELECTRON_RUN_AS_NODE'] = '1';
3690 try {
3691 let cp = child_process_1.fork('', [], {
3692 cwd: cwd,
3693 env: newEnv,
3694 execArgv: ['-e', app]
3695 });
3696 if (cp.pid === void 0) {
3697 reject(new Error(`Starting process to resolve node module ${moduleName} failed`));
3698 return;
3699 }
3700 cp.on('error', (error) => {
3701 reject(error);
3702 });
3703 cp.on('message', (message) => {
3704 if (message.c === 'r') {
3705 cp.send({ c: 'e' });
3706 if (message.s) {
3707 resolve(message.r);
3708 }
3709 else {
3710 reject(new Error(`Failed to resolve module: ${moduleName}`));
3711 }
3712 }
3713 });
3714 let message = {
3715 c: 'rs',
3716 a: moduleName
3717 };
3718 cp.send(message);
3719 }
3720 catch (error) {
3721 reject(error);
3722 }
3723 });
3724}
3725exports.resolve = resolve;
3726function resolveGlobalNodePath(tracer) {
3727 let npmCommand = 'npm';
3728 let options = {
3729 encoding: 'utf8'
3730 };
3731 if (isWindows()) {
3732 npmCommand = 'npm.cmd';
3733 options.shell = true;
3734 }
3735 let handler = () => { };
3736 try {
3737 process.on('SIGPIPE', handler);
3738 let stdout = child_process_1.spawnSync(npmCommand, ['config', 'get', 'prefix'], options).stdout;
3739 if (!stdout) {
3740 if (tracer) {
3741 tracer(`'npm config get prefix' didn't return a value.`);
3742 }
3743 return undefined;
3744 }
3745 let prefix = stdout.trim();
3746 if (tracer) {
3747 tracer(`'npm config get prefix' value is: ${prefix}`);
3748 }
3749 if (prefix.length > 0) {
3750 if (isWindows()) {
3751 return path.join(prefix, 'node_modules');
3752 }
3753 else {
3754 return path.join(prefix, 'lib', 'node_modules');
3755 }
3756 }
3757 return undefined;
3758 }
3759 catch (err) {
3760 return undefined;
3761 }
3762 finally {
3763 process.removeListener('SIGPIPE', handler);
3764 }
3765}
3766exports.resolveGlobalNodePath = resolveGlobalNodePath;
3767function resolveGlobalYarnPath(tracer) {
3768 let yarnCommand = 'yarn';
3769 let options = {
3770 encoding: 'utf8'
3771 };
3772 if (isWindows()) {
3773 yarnCommand = 'yarn.cmd';
3774 options.shell = true;
3775 }
3776 let handler = () => { };
3777 try {
3778 process.on('SIGPIPE', handler);
3779 let results = child_process_1.spawnSync(yarnCommand, ['global', 'dir', '--json'], options);
3780 let stdout = results.stdout;
3781 if (!stdout) {
3782 if (tracer) {
3783 tracer(`'yarn global dir' didn't return a value.`);
3784 if (results.stderr) {
3785 tracer(results.stderr);
3786 }
3787 }
3788 return undefined;
3789 }
3790 let lines = stdout.trim().split(/\r?\n/);
3791 for (let line of lines) {
3792 try {
3793 let yarn = JSON.parse(line);
3794 if (yarn.type === 'log') {
3795 return path.join(yarn.data, 'node_modules');
3796 }
3797 }
3798 catch (e) {
3799 // Do nothing. Ignore the line
3800 }
3801 }
3802 return undefined;
3803 }
3804 catch (err) {
3805 return undefined;
3806 }
3807 finally {
3808 process.removeListener('SIGPIPE', handler);
3809 }
3810}
3811exports.resolveGlobalYarnPath = resolveGlobalYarnPath;
3812var FileSystem;
3813(function (FileSystem) {
3814 let _isCaseSensitive = undefined;
3815 function isCaseSensitive() {
3816 if (_isCaseSensitive !== void 0) {
3817 return _isCaseSensitive;
3818 }
3819 if (process.platform === 'win32') {
3820 _isCaseSensitive = false;
3821 }
3822 else {
3823 // convert current file name to upper case / lower case and check if file exists
3824 // (guards against cases when name is already all uppercase or lowercase)
3825 _isCaseSensitive = !fs.existsSync(__filename.toUpperCase()) || !fs.existsSync(__filename.toLowerCase());
3826 }
3827 return _isCaseSensitive;
3828 }
3829 FileSystem.isCaseSensitive = isCaseSensitive;
3830 function isParent(parent, child) {
3831 if (isCaseSensitive()) {
3832 return path.normalize(child).indexOf(path.normalize(parent)) === 0;
3833 }
3834 else {
3835 return path.normalize(child).toLowerCase().indexOf(path.normalize(parent).toLowerCase()) == 0;
3836 }
3837 }
3838 FileSystem.isParent = isParent;
3839})(FileSystem = exports.FileSystem || (exports.FileSystem = {}));
3840function resolveModulePath(workspaceRoot, moduleName, nodePath, tracer) {
3841 if (nodePath) {
3842 if (!path.isAbsolute(nodePath)) {
3843 nodePath = path.join(workspaceRoot, nodePath);
3844 }
3845 return resolve(moduleName, nodePath, nodePath, tracer).then((value) => {
3846 if (FileSystem.isParent(nodePath, value)) {
3847 return value;
3848 }
3849 else {
3850 return Promise.reject(new Error(`Failed to load ${moduleName} from node path location.`));
3851 }
3852 }).then(undefined, (_error) => {
3853 return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
3854 });
3855 }
3856 else {
3857 return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);
3858 }
3859}
3860exports.resolveModulePath = resolveModulePath;
3861/**
3862 * Resolves the given module relative to the given workspace root. In contrast to
3863 * `resolveModule` this method considers the parent chain as well.
3864 */
3865function resolveModule2(workspaceRoot, moduleName, nodePath, tracer) {
3866 return resolveModulePath(workspaceRoot, moduleName, nodePath, tracer).then((path) => {
3867 if (tracer) {
3868 tracer(`Module ${moduleName} got resolved to ${path}`);
3869 }
3870 return __webpack_require__(38)(path);
3871 });
3872}
3873exports.resolveModule2 = resolveModule2;
3874
3875
3876/***/ }),
3877
3878/***/ 35:
3879/***/ (function(module, exports) {
3880
3881module.exports = require("url");
3882
3883/***/ }),
3884
3885/***/ 350:
3886/***/ (function(module, exports, __webpack_require__) {
3887
3888"use strict";
3889
3890var __assign = (this && this.__assign) || function () {
3891 __assign = Object.assign || function(t) {
3892 for (var s, i = 1, n = arguments.length; i < n; i++) {
3893 s = arguments[i];
3894 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
3895 t[p] = s[p];
3896 }
3897 return t;
3898 };
3899 return __assign.apply(this, arguments);
3900};
3901var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3902 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3903 return new (P || (P = Promise))(function (resolve, reject) {
3904 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
3905 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
3906 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
3907 step((generator = generator.apply(thisArg, _arguments || [])).next());
3908 });
3909};
3910var __generator = (this && this.__generator) || function (thisArg, body) {
3911 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
3912 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
3913 function verb(n) { return function (v) { return step([n, v]); }; }
3914 function step(op) {
3915 if (f) throw new TypeError("Generator is already executing.");
3916 while (_) try {
3917 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;
3918 if (y = 0, t) op = [op[0] & 2, t.value];
3919 switch (op[0]) {
3920 case 0: case 1: t = op; break;
3921 case 4: _.label++; return { value: op[1], done: false };
3922 case 5: _.label++; y = op[1]; op = [0]; continue;
3923 case 7: op = _.ops.pop(); _.trys.pop(); continue;
3924 default:
3925 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
3926 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
3927 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
3928 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
3929 if (t[2]) _.ops.pop();
3930 _.trys.pop(); continue;
3931 }
3932 op = body.call(thisArg, _);
3933 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
3934 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
3935 }
3936};
3937Object.defineProperty(exports, "__esModule", { value: true });
3938/*
3939 * vim builtin completion items
3940 *
3941 * 1. functions
3942 * 2. options
3943 * 3. variables
3944 * 4. commands
3945 * 5. has features
3946 * 6. expand Keyword
3947 */
3948var fs_1 = __webpack_require__(36);
3949var path_1 = __webpack_require__(15);
3950var vscode_languageserver_1 = __webpack_require__(4);
3951var constant_1 = __webpack_require__(2);
3952var util_1 = __webpack_require__(40);
3953var EVAL_PATH = "/doc/eval.txt";
3954var OPTIONS_PATH = "/doc/options.txt";
3955var INDEX_PATH = "/doc/index.txt";
3956var API_PATH = "/doc/api.txt";
3957var AUTOCMD_PATH = "/doc/autocmd.txt";
3958var POPUP_PATH = "/doc/popup.txt";
3959var CHANNEL_PATH = "/doc/channel.txt";
3960var TEXTPROP_PATH = "/doc/textprop.txt";
3961var TERMINAL_PATH = "/doc/terminal.txt";
3962var TESTING_PATH = "/doc/testing.txt";
3963var Server = /** @class */ (function () {
3964 function Server(config) {
3965 this.config = config;
3966 // completion items
3967 this.vimPredefinedVariablesItems = [];
3968 this.vimOptionItems = [];
3969 this.vimBuiltinFunctionItems = [];
3970 this.vimCommandItems = [];
3971 this.vimFeatureItems = [];
3972 this.vimExpandKeywordItems = [];
3973 this.vimAutocmdItems = [];
3974 // documents
3975 this.vimBuiltFunctionDocuments = {};
3976 this.vimOptionDocuments = {};
3977 this.vimPredefinedVariableDocuments = {};
3978 this.vimCommandDocuments = {};
3979 this.vimFeatureDocuments = {};
3980 this.expandKeywordDocuments = {};
3981 // signature help
3982 this.vimBuiltFunctionSignatureHelp = {};
3983 // raw docs
3984 this.text = {};
3985 }
3986 Server.prototype.build = function () {
3987 return __awaiter(this, void 0, void 0, function () {
3988 var vimruntime, paths, index, p, _a, err, data;
3989 return __generator(this, function (_b) {
3990 switch (_b.label) {
3991 case 0:
3992 vimruntime = this.config.vimruntime;
3993 if (!vimruntime) return [3 /*break*/, 5];
3994 paths = [
3995 EVAL_PATH,
3996 OPTIONS_PATH,
3997 INDEX_PATH,
3998 API_PATH,
3999 AUTOCMD_PATH,
4000 POPUP_PATH,
4001 CHANNEL_PATH,
4002 TEXTPROP_PATH,
4003 TERMINAL_PATH,
4004 TESTING_PATH,
4005 ];
4006 index = 0;
4007 _b.label = 1;
4008 case 1:
4009 if (!(index < paths.length)) return [3 /*break*/, 4];
4010 p = path_1.join(vimruntime, paths[index]);
4011 return [4 /*yield*/, util_1.pcb(fs_1.readFile)(p, "utf-8")];
4012 case 2:
4013 _a = _b.sent(), err = _a[0], data = _a[1];
4014 if (err) {
4015 // tslint:disable-next-line: no-console
4016 console.error("[vimls]: read " + p + " error: " + err.message);
4017 }
4018 this.text[paths[index]] = (data && data.toString().split("\n")) || [];
4019 _b.label = 3;
4020 case 3:
4021 index++;
4022 return [3 /*break*/, 1];
4023 case 4:
4024 this.resolveVimPredefinedVariables();
4025 this.resolveVimOptions();
4026 this.resolveBuiltinFunctions();
4027 this.resolveBuiltinFunctionsDocument();
4028 this.resolveBuiltinVimPopupFunctionsDocument();
4029 this.resolveBuiltinVimChannelFunctionsDocument();
4030 this.resolveBuiltinVimJobFunctionsDocument();
4031 this.resolveBuiltinVimTextpropFunctionsDocument();
4032 this.resolveBuiltinVimTerminalFunctionsDocument();
4033 this.resolveBuiltinVimTestingFunctionsDocument();
4034 this.resolveBuiltinNvimFunctions();
4035 this.resolveExpandKeywords();
4036 this.resolveVimCommands();
4037 this.resolveVimFeatures();
4038 this.resolveVimAutocmds();
4039 _b.label = 5;
4040 case 5: return [2 /*return*/];
4041 }
4042 });
4043 });
4044 };
4045 Server.prototype.serialize = function () {
4046 var str = JSON.stringify({
4047 completionItems: {
4048 commands: this.vimCommandItems,
4049 functions: this.vimBuiltinFunctionItems,
4050 variables: this.vimPredefinedVariablesItems,
4051 options: this.vimOptionItems,
4052 features: this.vimFeatureItems,
4053 expandKeywords: this.vimExpandKeywordItems,
4054 autocmds: this.vimAutocmdItems,
4055 },
4056 signatureHelp: this.vimBuiltFunctionSignatureHelp,
4057 documents: {
4058 commands: this.vimCommandDocuments,
4059 functions: this.vimBuiltFunctionDocuments,
4060 variables: this.vimPredefinedVariableDocuments,
4061 options: this.vimOptionDocuments,
4062 features: this.vimFeatureDocuments,
4063 expandKeywords: this.expandKeywordDocuments,
4064 },
4065 }, null, 2);
4066 fs_1.writeFileSync("./src/docs/builtin-docs.json", str, "utf-8");
4067 };
4068 Server.prototype.formatFunctionSnippets = function (fname, snippets) {
4069 if (snippets === "") {
4070 return fname + "(${0})";
4071 }
4072 var idx = 0;
4073 if (/^\[.+\]/.test(snippets)) {
4074 return fname + "(${1})${0}";
4075 }
4076 var str = snippets.split("[")[0].trim().replace(/\{?(\w+)\}?/g, function (m, g1) {
4077 return "${" + (idx += 1) + ":" + g1 + "}";
4078 });
4079 return fname + "(" + str + ")${0}";
4080 };
4081 // get vim predefined variables from vim document eval.txt
4082 Server.prototype.resolveVimPredefinedVariables = function () {
4083 var evalText = this.text[EVAL_PATH] || [];
4084 var isMatchLine = false;
4085 var completionItem;
4086 for (var _i = 0, evalText_1 = evalText; _i < evalText_1.length; _i++) {
4087 var line = evalText_1[_i];
4088 if (!isMatchLine) {
4089 if (/\*vim-variable\*/.test(line)) {
4090 isMatchLine = true;
4091 }
4092 continue;
4093 }
4094 else {
4095 var m = line.match(/^(v:[^ \t]+)[ \t]+([^ ].*)$/);
4096 if (m) {
4097 if (completionItem) {
4098 this.vimPredefinedVariablesItems.push(completionItem);
4099 this.vimPredefinedVariableDocuments[completionItem.label].pop();
4100 completionItem = undefined;
4101 }
4102 var label = m[1];
4103 completionItem = {
4104 label: label,
4105 kind: vscode_languageserver_1.CompletionItemKind.Variable,
4106 sortText: constant_1.sortTexts.four,
4107 insertText: label.slice(2),
4108 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
4109 };
4110 if (!this.vimPredefinedVariableDocuments[label]) {
4111 this.vimPredefinedVariableDocuments[label] = [];
4112 }
4113 this.vimPredefinedVariableDocuments[label].push(m[2]);
4114 }
4115 else if (/^\s*$/.test(line) && completionItem) {
4116 this.vimPredefinedVariablesItems.push(completionItem);
4117 completionItem = undefined;
4118 }
4119 else if (completionItem) {
4120 this.vimPredefinedVariableDocuments[completionItem.label].push(line);
4121 }
4122 else if (/===============/.test(line)) {
4123 break;
4124 }
4125 }
4126 }
4127 };
4128 // get vim options from vim document options.txt
4129 Server.prototype.resolveVimOptions = function () {
4130 var optionsText = this.text[OPTIONS_PATH] || [];
4131 var isMatchLine = false;
4132 var completionItem;
4133 for (var _i = 0, optionsText_1 = optionsText; _i < optionsText_1.length; _i++) {
4134 var line = optionsText_1[_i];
4135 if (!isMatchLine) {
4136 if (/\*'aleph'\*/.test(line)) {
4137 isMatchLine = true;
4138 }
4139 continue;
4140 }
4141 else {
4142 var m = line.match(/^'([^']+)'[ \t]+('[^']+')?[ \t]+([^ \t].*)$/);
4143 if (m) {
4144 var label = m[1];
4145 completionItem = {
4146 label: label,
4147 kind: vscode_languageserver_1.CompletionItemKind.Property,
4148 detail: m[3].trim().split(/[ \t]/)[0],
4149 documentation: "",
4150 sortText: "00004",
4151 insertText: m[1],
4152 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
4153 };
4154 if (!this.vimOptionDocuments[label]) {
4155 this.vimOptionDocuments[label] = [];
4156 }
4157 this.vimOptionDocuments[label].push(m[3]);
4158 }
4159 else if (/^\s*$/.test(line) && completionItem) {
4160 this.vimOptionItems.push(completionItem);
4161 completionItem = undefined;
4162 }
4163 else if (completionItem) {
4164 this.vimOptionDocuments[completionItem.label].push(line);
4165 }
4166 }
4167 }
4168 };
4169 // get vim builtin function from document eval.txt
4170 Server.prototype.resolveBuiltinFunctions = function () {
4171 var evalText = this.text[EVAL_PATH] || [];
4172 var isMatchLine = false;
4173 var completionItem;
4174 for (var _i = 0, evalText_2 = evalText; _i < evalText_2.length; _i++) {
4175 var line = evalText_2[_i];
4176 if (!isMatchLine) {
4177 if (/\*functions\*/.test(line)) {
4178 isMatchLine = true;
4179 }
4180 continue;
4181 }
4182 else {
4183 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
4184 if (m) {
4185 if (completionItem) {
4186 this.vimBuiltinFunctionItems.push(completionItem);
4187 }
4188 var label = m[2];
4189 completionItem = {
4190 label: label,
4191 kind: vscode_languageserver_1.CompletionItemKind.Function,
4192 detail: (m[4] || "").split(/[ \t]/)[0],
4193 sortText: "00004",
4194 insertText: this.formatFunctionSnippets(m[2], m[3]),
4195 insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
4196 };
4197 this.vimBuiltFunctionSignatureHelp[label] = [
4198 m[3],
4199 (m[4] || "").split(/[ \t]/)[0],
4200 ];
4201 }
4202 else if (/^[ \t]*$/.test(line)) {
4203 if (completionItem) {
4204 this.vimBuiltinFunctionItems.push(completionItem);
4205 completionItem = undefined;
4206 break;
4207 }
4208 }
4209 else if (completionItem) {
4210 if (completionItem.detail === "") {
4211 completionItem.detail = line.trim().split(/[ \t]/)[0];
4212 if (this.vimBuiltFunctionSignatureHelp[completionItem.label]) {
4213 this.vimBuiltFunctionSignatureHelp[completionItem.label][1] = line.trim().split(/[ \t]/)[0];
4214 }
4215 }
4216 }
4217 }
4218 }
4219 };
4220 Server.prototype.resolveBuiltinFunctionsDocument = function () {
4221 var evalText = this.text[EVAL_PATH] || [];
4222 var isMatchLine = false;
4223 var label = "";
4224 for (var idx = 0; idx < evalText.length; idx++) {
4225 var line = evalText[idx];
4226 if (!isMatchLine) {
4227 if (/\*abs\(\)\*/.test(line)) {
4228 isMatchLine = true;
4229 idx -= 1;
4230 }
4231 continue;
4232 }
4233 else {
4234 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
4235 if (m) {
4236 if (label) {
4237 this.vimBuiltFunctionDocuments[label].pop();
4238 }
4239 label = m[2];
4240 if (!this.vimBuiltFunctionDocuments[label]) {
4241 this.vimBuiltFunctionDocuments[label] = [];
4242 }
4243 }
4244 else if (/^[ \t]*\*string-match\*[ \t]*$/.test(line)) {
4245 if (label) {
4246 this.vimBuiltFunctionDocuments[label].pop();
4247 }
4248 break;
4249 }
4250 else if (label) {
4251 this.vimBuiltFunctionDocuments[label].push(line);
4252 }
4253 }
4254 }
4255 };
4256 Server.prototype.resolveBuiltinVimPopupFunctionsDocument = function () {
4257 var popupText = this.text[POPUP_PATH] || [];
4258 var isMatchLine = false;
4259 var label = "";
4260 for (var idx = 0; idx < popupText.length; idx++) {
4261 var line = popupText[idx];
4262 if (!isMatchLine) {
4263 if (/^DETAILS\s+\*popup-function-details\*/.test(line)) {
4264 isMatchLine = true;
4265 idx += 1;
4266 }
4267 continue;
4268 }
4269 else {
4270 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
4271 if (m) {
4272 if (label) {
4273 this.vimBuiltFunctionDocuments[label].pop();
4274 }
4275 label = m[2];
4276 if (!this.vimBuiltFunctionDocuments[label]) {
4277 this.vimBuiltFunctionDocuments[label] = [];
4278 }
4279 }
4280 else if (/^=+$/.test(line)) {
4281 if (label) {
4282 this.vimBuiltFunctionDocuments[label].pop();
4283 }
4284 break;
4285 }
4286 else if (label) {
4287 this.vimBuiltFunctionDocuments[label].push(line);
4288 }
4289 }
4290 }
4291 };
4292 Server.prototype.resolveBuiltinVimChannelFunctionsDocument = function () {
4293 var channelText = this.text[CHANNEL_PATH] || [];
4294 var isMatchLine = false;
4295 var label = "";
4296 for (var idx = 0; idx < channelText.length; idx++) {
4297 var line = channelText[idx];
4298 if (!isMatchLine) {
4299 if (/^8\.\sChannel\sfunctions\sdetails\s+\*channel-functions-details\*/.test(line)) {
4300 isMatchLine = true;
4301 idx += 1;
4302 }
4303 continue;
4304 }
4305 else {
4306 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
4307 if (m) {
4308 if (label) {
4309 this.vimBuiltFunctionDocuments[label].pop();
4310 }
4311 label = m[2];
4312 if (!this.vimBuiltFunctionDocuments[label]) {
4313 this.vimBuiltFunctionDocuments[label] = [];
4314 }
4315 }
4316 else if (/^=+$/.test(line)) {
4317 if (label) {
4318 this.vimBuiltFunctionDocuments[label].pop();
4319 }
4320 break;
4321 }
4322 else if (label) {
4323 this.vimBuiltFunctionDocuments[label].push(line);
4324 }
4325 }
4326 }
4327 };
4328 Server.prototype.resolveBuiltinVimJobFunctionsDocument = function () {
4329 var channelText = this.text[CHANNEL_PATH] || [];
4330 var isMatchLine = false;
4331 var label = "";
4332 for (var idx = 0; idx < channelText.length; idx++) {
4333 var line = channelText[idx];
4334 if (!isMatchLine) {
4335 if (/^11\.\sJob\sfunctions\s+\*job-functions-details\*/.test(line)) {
4336 isMatchLine = true;
4337 idx += 1;
4338 }
4339 continue;
4340 }
4341 else {
4342 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
4343 if (m) {
4344 if (label) {
4345 this.vimBuiltFunctionDocuments[label].pop();
4346 }
4347 label = m[2];
4348 if (!this.vimBuiltFunctionDocuments[label]) {
4349 this.vimBuiltFunctionDocuments[label] = [];
4350 }
4351 }
4352 else if (/^=+$/.test(line)) {
4353 if (label) {
4354 this.vimBuiltFunctionDocuments[label].pop();
4355 }
4356 break;
4357 }
4358 else if (label) {
4359 this.vimBuiltFunctionDocuments[label].push(line);
4360 }
4361 }
4362 }
4363 };
4364 Server.prototype.resolveBuiltinVimTextpropFunctionsDocument = function () {
4365 var textpropText = this.text[TEXTPROP_PATH] || [];
4366 var isMatchLine = false;
4367 var label = "";
4368 // tslint:disable-next-line: prefer-for-of
4369 for (var idx = 0; idx < textpropText.length; idx++) {
4370 var line = textpropText[idx];
4371 if (!isMatchLine) {
4372 if (/^\s+\*prop_add\(\)\*\s\*E965/.test(line)) {
4373 isMatchLine = true;
4374 }
4375 continue;
4376 }
4377 else {
4378 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
4379 if (m) {
4380 if (label) {
4381 this.vimBuiltFunctionDocuments[label].pop();
4382 }
4383 label = m[2];
4384 if (!this.vimBuiltFunctionDocuments[label]) {
4385 this.vimBuiltFunctionDocuments[label] = [];
4386 }
4387 }
4388 else if (/^=+$/.test(line)) {
4389 if (label) {
4390 this.vimBuiltFunctionDocuments[label].pop();
4391 }
4392 break;
4393 }
4394 else if (label) {
4395 this.vimBuiltFunctionDocuments[label].push(line);
4396 }
4397 }
4398 }
4399 };
4400 Server.prototype.resolveBuiltinVimTerminalFunctionsDocument = function () {
4401 var terminalText = this.text[TERMINAL_PATH] || [];
4402 var isMatchLine = false;
4403 var label = "";
4404 // tslint:disable-next-line: prefer-for-of
4405 for (var idx = 0; idx < terminalText.length; idx++) {
4406 var line = terminalText[idx];
4407 if (!isMatchLine) {
4408 if (/^\s+\*term_dumpdiff\(\)/.test(line)) {
4409 isMatchLine = true;
4410 }
4411 continue;
4412 }
4413 else {
4414 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
4415 if (m) {
4416 if (label) {
4417 this.vimBuiltFunctionDocuments[label].pop();
4418 }
4419 label = m[2];
4420 if (!this.vimBuiltFunctionDocuments[label]) {
4421 this.vimBuiltFunctionDocuments[label] = [];
4422 }
4423 }
4424 else if (/^=+$/.test(line)) {
4425 if (label) {
4426 this.vimBuiltFunctionDocuments[label].pop();
4427 }
4428 break;
4429 }
4430 else if (label) {
4431 this.vimBuiltFunctionDocuments[label].push(line);
4432 }
4433 }
4434 }
4435 };
4436 Server.prototype.resolveBuiltinVimTestingFunctionsDocument = function () {
4437 var testingText = this.text[TESTING_PATH] || [];
4438 var isMatchLine = false;
4439 var label = "";
4440 // tslint:disable-next-line: prefer-for-of
4441 for (var idx = 0; idx < testingText.length; idx++) {
4442 var line = testingText[idx];
4443 if (!isMatchLine) {
4444 if (/^2\.\sTest\sfunctions\s+\*test-functions-details\*/.test(line)) {
4445 isMatchLine = true;
4446 idx += 1;
4447 }
4448 continue;
4449 }
4450 else {
4451 var m = line.match(/^((\w+)\(([^)]*)\))[ \t]*([^ \t].*)?$/);
4452 if (m) {
4453 if (label) {
4454 this.vimBuiltFunctionDocuments[label].pop();
4455 }
4456 label = m[2];
4457 if (!this.vimBuiltFunctionDocuments[label]) {
4458 this.vimBuiltFunctionDocuments[label] = [];
4459 }
4460 }
4461 else if (/^=+$/.test(line)) {
4462 if (label) {
4463 this.vimBuiltFunctionDocuments[label].pop();
4464 }
4465 break;
4466 }
4467 else if (label) {
4468 this.vimBuiltFunctionDocuments[label].push(line);
4469 }
4470 }
4471 }
4472 };
4473 Server.prototype.resolveBuiltinNvimFunctions = function () {
4474 var evalText = this.text[API_PATH] || [];
4475 var completionItem;
4476 var pattern = /^((nvim_\w+)\(([^)]*)\))[ \t]*/m;
4477 for (var idx = 0; idx < evalText.length; idx++) {
4478 var line = evalText[idx];
4479 var m = line.match(pattern);
4480 if (!m && evalText[idx + 1]) {
4481 m = [line, evalText[idx + 1].trim()].join(" ").match(pattern);
4482 if (m) {
4483 idx++;
4484 }
4485 }
4486 if (m) {
4487 if (completionItem) {
4488 this.vimBuiltinFunctionItems.push(completionItem);
4489 if (this.vimBuiltFunctionDocuments[completionItem.label]) {
4490 this.vimBuiltFunctionDocuments[completionItem.label].pop();
4491 }
4492 }
4493 var label = m[2];
4494 completionItem = {
4495 label: label,
4496 kind: vscode_languageserver_1.CompletionItemKind.Function,
4497 detail: "",
4498 documentation: "",
4499 sortText: "00004",
4500 insertText: this.formatFunctionSnippets(m[2], m[3]),
4501 insertTextFormat: vscode_languageserver_1.InsertTextFormat.Snippet,
4502 };
4503 if (!this.vimBuiltFunctionDocuments[label]) {
4504 this.vimBuiltFunctionDocuments[label] = [];
4505 }
4506 this.vimBuiltFunctionSignatureHelp[label] = [
4507 m[3],
4508 "",
4509 ];
4510 }
4511 else if (/^(================|[ \t]*vim:tw=78:ts=8:ft=help:norl:)/.test(line)) {
4512 if (completionItem) {
4513 this.vimBuiltinFunctionItems.push(completionItem);
4514 if (this.vimBuiltFunctionDocuments[completionItem.label]) {
4515 this.vimBuiltFunctionDocuments[completionItem.label].pop();
4516 }
4517 completionItem = undefined;
4518 }
4519 }
4520 else if (completionItem && !/^[ \t]\*nvim(_\w+)+\(\)\*\s*$/.test(line)) {
4521 this.vimBuiltFunctionDocuments[completionItem.label].push(line);
4522 }
4523 }
4524 };
4525 Server.prototype.resolveVimCommands = function () {
4526 var indexText = this.text[INDEX_PATH] || [];
4527 var isMatchLine = false;
4528 var completionItem;
4529 for (var _i = 0, indexText_1 = indexText; _i < indexText_1.length; _i++) {
4530 var line = indexText_1[_i];
4531 if (!isMatchLine) {
4532 if (/\*ex-cmd-index\*/.test(line)) {
4533 isMatchLine = true;
4534 }
4535 continue;
4536 }
4537 else {
4538 var m = line.match(/^\|?:([^ \t]+?)\|?[ \t]+:([^ \t]+)[ \t]+([^ \t].*)$/);
4539 if (m) {
4540 if (completionItem) {
4541 this.vimCommandItems.push(completionItem);
4542 }
4543 var label = m[1];
4544 completionItem = {
4545 label: m[1],
4546 kind: vscode_languageserver_1.CompletionItemKind.Operator,
4547 detail: m[2],
4548 documentation: m[3],
4549 sortText: "00004",
4550 insertText: m[1],
4551 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
4552 };
4553 if (!this.vimCommandDocuments[label]) {
4554 this.vimCommandDocuments[label] = [];
4555 }
4556 this.vimCommandDocuments[label].push(m[3]);
4557 }
4558 else if (/^[ \t]*$/.test(line)) {
4559 if (completionItem) {
4560 this.vimCommandItems.push(completionItem);
4561 completionItem = undefined;
4562 break;
4563 }
4564 }
4565 else if (completionItem) {
4566 completionItem.documentation += " " + line.trim();
4567 this.vimCommandDocuments[completionItem.label].push(line);
4568 }
4569 }
4570 }
4571 };
4572 Server.prototype.resolveVimFeatures = function () {
4573 var text = this.text[EVAL_PATH] || [];
4574 var isMatchLine = false;
4575 var completionItem;
4576 var features = [];
4577 for (var idx = 0; idx < text.length; idx++) {
4578 var line = text[idx];
4579 if (!isMatchLine) {
4580 if (/^[ \t]*acl[ \t]/.test(line)) {
4581 isMatchLine = true;
4582 idx -= 1;
4583 }
4584 continue;
4585 }
4586 else {
4587 var m = line.match(/^[ \t]*\*?([^ \t]+?)\*?[ \t]+([^ \t].*)$/);
4588 if (m) {
4589 if (completionItem) {
4590 features.push(completionItem);
4591 }
4592 var label = m[1];
4593 completionItem = {
4594 label: m[1],
4595 kind: vscode_languageserver_1.CompletionItemKind.EnumMember,
4596 documentation: "",
4597 sortText: "00004",
4598 insertText: m[1],
4599 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
4600 };
4601 if (!this.vimFeatureDocuments[label]) {
4602 this.vimFeatureDocuments[label] = [];
4603 }
4604 this.vimFeatureDocuments[label].push(m[2]);
4605 }
4606 else if (/^[ \t]*$/.test(line)) {
4607 if (completionItem) {
4608 features.push(completionItem);
4609 break;
4610 }
4611 }
4612 else if (completionItem) {
4613 this.vimFeatureDocuments[completionItem.label].push(line);
4614 }
4615 }
4616 }
4617 this.vimFeatureItems = features;
4618 };
4619 Server.prototype.resolveVimAutocmds = function () {
4620 var text = this.text[AUTOCMD_PATH] || [];
4621 var isMatchLine = false;
4622 for (var idx = 0; idx < text.length; idx++) {
4623 var line = text[idx];
4624 if (!isMatchLine) {
4625 if (/^\|BufNewFile\|/.test(line)) {
4626 isMatchLine = true;
4627 idx -= 1;
4628 }
4629 continue;
4630 }
4631 else {
4632 var m = line.match(/^\|([^ \t]+)\|[ \t]+([^ \t].*)$/);
4633 if (m) {
4634 this.vimAutocmdItems.push({
4635 label: m[1],
4636 kind: vscode_languageserver_1.CompletionItemKind.EnumMember,
4637 documentation: m[2],
4638 sortText: "00004",
4639 insertText: m[1],
4640 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
4641 });
4642 if (m[1] === "Signal") {
4643 break;
4644 }
4645 }
4646 }
4647 }
4648 };
4649 Server.prototype.resolveExpandKeywords = function () {
4650 var _this = this;
4651 this.vimExpandKeywordItems = [
4652 "<cfile>,file name under the cursor",
4653 "<afile>,autocmd file name",
4654 "<abuf>,autocmd buffer number (as a String!)",
4655 "<amatch>,autocmd matched name",
4656 "<sfile>,sourced script file or function name",
4657 "<slnum>,sourced script file line number",
4658 "<cword>,word under the cursor",
4659 "<cWORD>,WORD under the cursor",
4660 "<client>,the {clientid} of the last received message `server2client()`",
4661 ].map(function (line) {
4662 var item = line.split(",");
4663 _this.expandKeywordDocuments[item[0]] = [
4664 item[1],
4665 ];
4666 return {
4667 label: item[0],
4668 kind: vscode_languageserver_1.CompletionItemKind.Keyword,
4669 documentation: item[1],
4670 sortText: "00004",
4671 insertText: item[0],
4672 insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText,
4673 };
4674 });
4675 };
4676 return Server;
4677}());
4678function main() {
4679 return __awaiter(this, void 0, void 0, function () {
4680 var servers, idx, server;
4681 return __generator(this, function (_a) {
4682 switch (_a.label) {
4683 case 0:
4684 servers = [];
4685 idx = 2;
4686 _a.label = 1;
4687 case 1:
4688 if (!(idx < process.argv.length)) return [3 /*break*/, 4];
4689 servers.push(new Server({
4690 vimruntime: process.argv[idx],
4691 }));
4692 return [4 /*yield*/, servers[servers.length - 1].build()];
4693 case 2:
4694 _a.sent();
4695 _a.label = 3;
4696 case 3:
4697 idx++;
4698 return [3 /*break*/, 1];
4699 case 4:
4700 server = servers.reduce(function (pre, next) {
4701 // merge functions
4702 next.vimBuiltinFunctionItems.forEach(function (item) {
4703 var label = item.label;
4704 if (!pre.vimBuiltFunctionDocuments[label]) {
4705 pre.vimBuiltinFunctionItems.push(item);
4706 pre.vimBuiltFunctionDocuments[label] = next.vimBuiltFunctionDocuments[label];
4707 }
4708 });
4709 // merge commands
4710 next.vimCommandItems.forEach(function (item) {
4711 var label = item.label;
4712 if (!pre.vimCommandDocuments[label]) {
4713 pre.vimCommandItems.push(item);
4714 pre.vimCommandDocuments[label] = next.vimCommandDocuments[label];
4715 }
4716 });
4717 // merge options
4718 next.vimOptionItems.forEach(function (item) {
4719 var label = item.label;
4720 if (!pre.vimOptionDocuments[label]) {
4721 pre.vimOptionItems.push(item);
4722 pre.vimOptionDocuments[label] = next.vimOptionDocuments[label];
4723 }
4724 });
4725 // merge variables
4726 next.vimPredefinedVariablesItems.forEach(function (item) {
4727 var label = item.label;
4728 if (!pre.vimPredefinedVariableDocuments[label]) {
4729 pre.vimPredefinedVariablesItems.push(item);
4730 pre.vimPredefinedVariableDocuments[label] = next.vimPredefinedVariableDocuments[label];
4731 }
4732 });
4733 // merge features
4734 next.vimFeatureItems.forEach(function (item) {
4735 var label = item.label;
4736 if (!pre.vimFeatureDocuments[label]) {
4737 pre.vimFeatureItems.push(item);
4738 pre.vimFeatureDocuments[label] = next.vimFeatureDocuments[label];
4739 }
4740 });
4741 // merge expand key words
4742 next.vimExpandKeywordItems.forEach(function (item) {
4743 var label = item.label;
4744 if (!pre.expandKeywordDocuments[label]) {
4745 pre.vimExpandKeywordItems.push(item);
4746 pre.expandKeywordDocuments[label] = next.expandKeywordDocuments[label];
4747 }
4748 });
4749 // merge autocmd
4750 next.vimAutocmdItems.forEach(function (item) {
4751 var label = item.label;
4752 if (!pre.vimAutocmdItems.some(function (n) { return n.label === label; })) {
4753 pre.vimAutocmdItems.push(item);
4754 }
4755 });
4756 // merge signature help
4757 pre.vimBuiltFunctionSignatureHelp = __assign(__assign({}, next.vimBuiltFunctionSignatureHelp), pre.vimBuiltFunctionSignatureHelp);
4758 return pre;
4759 });
4760 server.serialize();
4761 return [2 /*return*/];
4762 }
4763 });
4764 });
4765}
4766main();
4767
4768
4769/***/ }),
4770
4771/***/ 36:
4772/***/ (function(module, exports) {
4773
4774module.exports = require("fs");
4775
4776/***/ }),
4777
4778/***/ 37:
4779/***/ (function(module, exports) {
4780
4781module.exports = require("child_process");
4782
4783/***/ }),
4784
4785/***/ 38:
4786/***/ (function(module, exports) {
4787
4788function webpackEmptyContext(req) {
4789 var e = new Error("Cannot find module '" + req + "'");
4790 e.code = 'MODULE_NOT_FOUND';
4791 throw e;
4792}
4793webpackEmptyContext.keys = function() { return []; };
4794webpackEmptyContext.resolve = webpackEmptyContext;
4795module.exports = webpackEmptyContext;
4796webpackEmptyContext.id = 38;
4797
4798/***/ }),
4799
4800/***/ 4:
4801/***/ (function(module, exports, __webpack_require__) {
4802
4803"use strict";
4804/* --------------------------------------------------------------------------------------------
4805 * Copyright (c) Microsoft Corporation. All rights reserved.
4806 * Licensed under the MIT License. See License.txt in the project root for license information.
4807 * ------------------------------------------------------------------------------------------ */
4808/// <reference path="./thenable.ts" />
4809
4810function __export(m) {
4811 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
4812}
4813Object.defineProperty(exports, "__esModule", { value: true });
4814const vscode_languageserver_protocol_1 = __webpack_require__(5);
4815exports.Event = vscode_languageserver_protocol_1.Event;
4816const configuration_1 = __webpack_require__(30);
4817const workspaceFolders_1 = __webpack_require__(32);
4818const Is = __webpack_require__(31);
4819const UUID = __webpack_require__(33);
4820// ------------- Reexport the API surface of the language worker API ----------------------
4821__export(__webpack_require__(5));
4822const fm = __webpack_require__(34);
4823var Files;
4824(function (Files) {
4825 Files.uriToFilePath = fm.uriToFilePath;
4826 Files.resolveGlobalNodePath = fm.resolveGlobalNodePath;
4827 Files.resolveGlobalYarnPath = fm.resolveGlobalYarnPath;
4828 Files.resolve = fm.resolve;
4829 Files.resolveModule = fm.resolveModule;
4830 Files.resolveModule2 = fm.resolveModule2;
4831 Files.resolveModulePath = fm.resolveModulePath;
4832})(Files = exports.Files || (exports.Files = {}));
4833let shutdownReceived = false;
4834let exitTimer = undefined;
4835function setupExitTimer() {
4836 const argName = '--clientProcessId';
4837 function runTimer(value) {
4838 try {
4839 let processId = parseInt(value);
4840 if (!isNaN(processId)) {
4841 exitTimer = setInterval(() => {
4842 try {
4843 process.kill(processId, 0);
4844 }
4845 catch (ex) {
4846 // Parent process doesn't exist anymore. Exit the server.
4847 process.exit(shutdownReceived ? 0 : 1);
4848 }
4849 }, 3000);
4850 }
4851 }
4852 catch (e) {
4853 // Ignore errors;
4854 }
4855 }
4856 for (let i = 2; i < process.argv.length; i++) {
4857 let arg = process.argv[i];
4858 if (arg === argName && i + 1 < process.argv.length) {
4859 runTimer(process.argv[i + 1]);
4860 return;
4861 }
4862 else {
4863 let args = arg.split('=');
4864 if (args[0] === argName) {
4865 runTimer(args[1]);
4866 }
4867 }
4868 }
4869}
4870setupExitTimer();
4871function null2Undefined(value) {
4872 if (value === null) {
4873 return void 0;
4874 }
4875 return value;
4876}
4877/**
4878 * A manager for simple text documents
4879 */
4880class TextDocuments {
4881 /**
4882 * Create a new text document manager.
4883 */
4884 constructor() {
4885 this._documents = Object.create(null);
4886 this._onDidChangeContent = new vscode_languageserver_protocol_1.Emitter();
4887 this._onDidOpen = new vscode_languageserver_protocol_1.Emitter();
4888 this._onDidClose = new vscode_languageserver_protocol_1.Emitter();
4889 this._onDidSave = new vscode_languageserver_protocol_1.Emitter();
4890 this._onWillSave = new vscode_languageserver_protocol_1.Emitter();
4891 }
4892 /**
4893 * Returns the [TextDocumentSyncKind](#TextDocumentSyncKind) used by
4894 * this text document manager.
4895 */
4896 get syncKind() {
4897 return vscode_languageserver_protocol_1.TextDocumentSyncKind.Full;
4898 }
4899 /**
4900 * An event that fires when a text document managed by this manager
4901 * has been opened or the content changes.
4902 */
4903 get onDidChangeContent() {
4904 return this._onDidChangeContent.event;
4905 }
4906 /**
4907 * An event that fires when a text document managed by this manager
4908 * has been opened.
4909 */
4910 get onDidOpen() {
4911 return this._onDidOpen.event;
4912 }
4913 /**
4914 * An event that fires when a text document managed by this manager
4915 * will be saved.
4916 */
4917 get onWillSave() {
4918 return this._onWillSave.event;
4919 }
4920 /**
4921 * Sets a handler that will be called if a participant wants to provide
4922 * edits during a text document save.
4923 */
4924 onWillSaveWaitUntil(handler) {
4925 this._willSaveWaitUntil = handler;
4926 }
4927 /**
4928 * An event that fires when a text document managed by this manager
4929 * has been saved.
4930 */
4931 get onDidSave() {
4932 return this._onDidSave.event;
4933 }
4934 /**
4935 * An event that fires when a text document managed by this manager
4936 * has been closed.
4937 */
4938 get onDidClose() {
4939 return this._onDidClose.event;
4940 }
4941 /**
4942 * Returns the document for the given URI. Returns undefined if
4943 * the document is not mananged by this instance.
4944 *
4945 * @param uri The text document's URI to retrieve.
4946 * @return the text document or `undefined`.
4947 */
4948 get(uri) {
4949 return this._documents[uri];
4950 }
4951 /**
4952 * Returns all text documents managed by this instance.
4953 *
4954 * @return all text documents.
4955 */
4956 all() {
4957 return Object.keys(this._documents).map(key => this._documents[key]);
4958 }
4959 /**
4960 * Returns the URIs of all text documents managed by this instance.
4961 *
4962 * @return the URI's of all text documents.
4963 */
4964 keys() {
4965 return Object.keys(this._documents);
4966 }
4967 /**
4968 * Listens for `low level` notification on the given connection to
4969 * update the text documents managed by this instance.
4970 *
4971 * @param connection The connection to listen on.
4972 */
4973 listen(connection) {
4974 function isUpdateableDocument(value) {
4975 return Is.func(value.update);
4976 }
4977 connection.__textDocumentSync = vscode_languageserver_protocol_1.TextDocumentSyncKind.Full;
4978 connection.onDidOpenTextDocument((event) => {
4979 let td = event.textDocument;
4980 let document = vscode_languageserver_protocol_1.TextDocument.create(td.uri, td.languageId, td.version, td.text);
4981 this._documents[td.uri] = document;
4982 let toFire = Object.freeze({ document });
4983 this._onDidOpen.fire(toFire);
4984 this._onDidChangeContent.fire(toFire);
4985 });
4986 connection.onDidChangeTextDocument((event) => {
4987 let td = event.textDocument;
4988 let changes = event.contentChanges;
4989 let last = changes.length > 0 ? changes[changes.length - 1] : undefined;
4990 if (last) {
4991 let document = this._documents[td.uri];
4992 if (document && isUpdateableDocument(document)) {
4993 if (td.version === null || td.version === void 0) {
4994 throw new Error(`Received document change event for ${td.uri} without valid version identifier`);
4995 }
4996 document.update(last, td.version);
4997 this._onDidChangeContent.fire(Object.freeze({ document }));
4998 }
4999 }
5000 });
5001 connection.onDidCloseTextDocument((event) => {
5002 let document = this._documents[event.textDocument.uri];
5003 if (document) {
5004 delete this._documents[event.textDocument.uri];
5005 this._onDidClose.fire(Object.freeze({ document }));
5006 }
5007 });
5008 connection.onWillSaveTextDocument((event) => {
5009 let document = this._documents[event.textDocument.uri];
5010 if (document) {
5011 this._onWillSave.fire(Object.freeze({ document, reason: event.reason }));
5012 }
5013 });
5014 connection.onWillSaveTextDocumentWaitUntil((event, token) => {
5015 let document = this._documents[event.textDocument.uri];
5016 if (document && this._willSaveWaitUntil) {
5017 return this._willSaveWaitUntil(Object.freeze({ document, reason: event.reason }), token);
5018 }
5019 else {
5020 return [];
5021 }
5022 });
5023 connection.onDidSaveTextDocument((event) => {
5024 let document = this._documents[event.textDocument.uri];
5025 if (document) {
5026 this._onDidSave.fire(Object.freeze({ document }));
5027 }
5028 });
5029 }
5030}
5031exports.TextDocuments = TextDocuments;
5032/**
5033 * Helps tracking error message. Equal occurences of the same
5034 * message are only stored once. This class is for example
5035 * useful if text documents are validated in a loop and equal
5036 * error message should be folded into one.
5037 */
5038class ErrorMessageTracker {
5039 constructor() {
5040 this._messages = Object.create(null);
5041 }
5042 /**
5043 * Add a message to the tracker.
5044 *
5045 * @param message The message to add.
5046 */
5047 add(message) {
5048 let count = this._messages[message];
5049 if (!count) {
5050 count = 0;
5051 }
5052 count++;
5053 this._messages[message] = count;
5054 }
5055 /**
5056 * Send all tracked messages to the connection's window.
5057 *
5058 * @param connection The connection established between client and server.
5059 */
5060 sendErrors(connection) {
5061 Object.keys(this._messages).forEach(message => {
5062 connection.window.showErrorMessage(message);
5063 });
5064 }
5065}
5066exports.ErrorMessageTracker = ErrorMessageTracker;
5067var BulkRegistration;
5068(function (BulkRegistration) {
5069 /**
5070 * Creates a new bulk registration.
5071 * @return an empty bulk registration.
5072 */
5073 function create() {
5074 return new BulkRegistrationImpl();
5075 }
5076 BulkRegistration.create = create;
5077})(BulkRegistration = exports.BulkRegistration || (exports.BulkRegistration = {}));
5078class BulkRegistrationImpl {
5079 constructor() {
5080 this._registrations = [];
5081 this._registered = new Set();
5082 }
5083 add(type, registerOptions) {
5084 const method = Is.string(type) ? type : type.method;
5085 if (this._registered.has(method)) {
5086 throw new Error(`${method} is already added to this registration`);
5087 }
5088 const id = UUID.generateUuid();
5089 this._registrations.push({
5090 id: id,
5091 method: method,
5092 registerOptions: registerOptions || {}
5093 });
5094 this._registered.add(method);
5095 }
5096 asRegistrationParams() {
5097 return {
5098 registrations: this._registrations
5099 };
5100 }
5101}
5102var BulkUnregistration;
5103(function (BulkUnregistration) {
5104 function create() {
5105 return new BulkUnregistrationImpl(undefined, []);
5106 }
5107 BulkUnregistration.create = create;
5108})(BulkUnregistration = exports.BulkUnregistration || (exports.BulkUnregistration = {}));
5109class BulkUnregistrationImpl {
5110 constructor(_connection, unregistrations) {
5111 this._connection = _connection;
5112 this._unregistrations = new Map();
5113 unregistrations.forEach(unregistration => {
5114 this._unregistrations.set(unregistration.method, unregistration);
5115 });
5116 }
5117 get isAttached() {
5118 return !!this._connection;
5119 }
5120 attach(connection) {
5121 this._connection = connection;
5122 }
5123 add(unregistration) {
5124 this._unregistrations.set(unregistration.method, unregistration);
5125 }
5126 dispose() {
5127 let unregistrations = [];
5128 for (let unregistration of this._unregistrations.values()) {
5129 unregistrations.push(unregistration);
5130 }
5131 let params = {
5132 unregisterations: unregistrations
5133 };
5134 this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {
5135 this._connection.console.info(`Bulk unregistration failed.`);
5136 });
5137 }
5138 disposeSingle(arg) {
5139 const method = Is.string(arg) ? arg : arg.method;
5140 const unregistration = this._unregistrations.get(method);
5141 if (!unregistration) {
5142 return false;
5143 }
5144 let params = {
5145 unregisterations: [unregistration]
5146 };
5147 this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(() => {
5148 this._unregistrations.delete(method);
5149 }, (_error) => {
5150 this._connection.console.info(`Unregistering request handler for ${unregistration.id} failed.`);
5151 });
5152 return true;
5153 }
5154}
5155class ConnectionLogger {
5156 constructor() {
5157 }
5158 rawAttach(connection) {
5159 this._rawConnection = connection;
5160 }
5161 attach(connection) {
5162 this._connection = connection;
5163 }
5164 get connection() {
5165 if (!this._connection) {
5166 throw new Error('Remote is not attached to a connection yet.');
5167 }
5168 return this._connection;
5169 }
5170 fillServerCapabilities(_capabilities) {
5171 }
5172 initialize(_capabilities) {
5173 }
5174 error(message) {
5175 this.send(vscode_languageserver_protocol_1.MessageType.Error, message);
5176 }
5177 warn(message) {
5178 this.send(vscode_languageserver_protocol_1.MessageType.Warning, message);
5179 }
5180 info(message) {
5181 this.send(vscode_languageserver_protocol_1.MessageType.Info, message);
5182 }
5183 log(message) {
5184 this.send(vscode_languageserver_protocol_1.MessageType.Log, message);
5185 }
5186 send(type, message) {
5187 if (this._rawConnection) {
5188 this._rawConnection.sendNotification(vscode_languageserver_protocol_1.LogMessageNotification.type, { type, message });
5189 }
5190 }
5191}
5192class RemoteWindowImpl {
5193 constructor() {
5194 }
5195 attach(connection) {
5196 this._connection = connection;
5197 }
5198 get connection() {
5199 if (!this._connection) {
5200 throw new Error('Remote is not attached to a connection yet.');
5201 }
5202 return this._connection;
5203 }
5204 initialize(_capabilities) {
5205 }
5206 fillServerCapabilities(_capabilities) {
5207 }
5208 showErrorMessage(message, ...actions) {
5209 let params = { type: vscode_languageserver_protocol_1.MessageType.Error, message, actions };
5210 return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
5211 }
5212 showWarningMessage(message, ...actions) {
5213 let params = { type: vscode_languageserver_protocol_1.MessageType.Warning, message, actions };
5214 return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
5215 }
5216 showInformationMessage(message, ...actions) {
5217 let params = { type: vscode_languageserver_protocol_1.MessageType.Info, message, actions };
5218 return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);
5219 }
5220}
5221class RemoteClientImpl {
5222 attach(connection) {
5223 this._connection = connection;
5224 }
5225 get connection() {
5226 if (!this._connection) {
5227 throw new Error('Remote is not attached to a connection yet.');
5228 }
5229 return this._connection;
5230 }
5231 initialize(_capabilities) {
5232 }
5233 fillServerCapabilities(_capabilities) {
5234 }
5235 register(typeOrRegistrations, registerOptionsOrType, registerOptions) {
5236 if (typeOrRegistrations instanceof BulkRegistrationImpl) {
5237 return this.registerMany(typeOrRegistrations);
5238 }
5239 else if (typeOrRegistrations instanceof BulkUnregistrationImpl) {
5240 return this.registerSingle1(typeOrRegistrations, registerOptionsOrType, registerOptions);
5241 }
5242 else {
5243 return this.registerSingle2(typeOrRegistrations, registerOptionsOrType);
5244 }
5245 }
5246 registerSingle1(unregistration, type, registerOptions) {
5247 const method = Is.string(type) ? type : type.method;
5248 const id = UUID.generateUuid();
5249 let params = {
5250 registrations: [{ id, method, registerOptions: registerOptions || {} }]
5251 };
5252 if (!unregistration.isAttached) {
5253 unregistration.attach(this._connection);
5254 }
5255 return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
5256 unregistration.add({ id: id, method: method });
5257 return unregistration;
5258 }, (_error) => {
5259 this.connection.console.info(`Registering request handler for ${method} failed.`);
5260 return Promise.reject(_error);
5261 });
5262 }
5263 registerSingle2(type, registerOptions) {
5264 const method = Is.string(type) ? type : type.method;
5265 const id = UUID.generateUuid();
5266 let params = {
5267 registrations: [{ id, method, registerOptions: registerOptions || {} }]
5268 };
5269 return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {
5270 return vscode_languageserver_protocol_1.Disposable.create(() => {
5271 this.unregisterSingle(id, method);
5272 });
5273 }, (_error) => {
5274 this.connection.console.info(`Registering request handler for ${method} failed.`);
5275 return Promise.reject(_error);
5276 });
5277 }
5278 unregisterSingle(id, method) {
5279 let params = {
5280 unregisterations: [{ id, method }]
5281 };
5282 return this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {
5283 this.connection.console.info(`Unregistering request handler for ${id} failed.`);
5284 });
5285 }
5286 registerMany(registrations) {
5287 let params = registrations.asRegistrationParams();
5288 return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then(() => {
5289 return new BulkUnregistrationImpl(this._connection, params.registrations.map(registration => { return { id: registration.id, method: registration.method }; }));
5290 }, (_error) => {
5291 this.connection.console.info(`Bulk registration failed.`);
5292 return Promise.reject(_error);
5293 });
5294 }
5295}
5296class _RemoteWorkspaceImpl {
5297 constructor() {
5298 }
5299 attach(connection) {
5300 this._connection = connection;
5301 }
5302 get connection() {
5303 if (!this._connection) {
5304 throw new Error('Remote is not attached to a connection yet.');
5305 }
5306 return this._connection;
5307 }
5308 initialize(_capabilities) {
5309 }
5310 fillServerCapabilities(_capabilities) {
5311 }
5312 applyEdit(paramOrEdit) {
5313 function isApplyWorkspaceEditParams(value) {
5314 return value && !!value.edit;
5315 }
5316 let params = isApplyWorkspaceEditParams(paramOrEdit) ? paramOrEdit : { edit: paramOrEdit };
5317 return this._connection.sendRequest(vscode_languageserver_protocol_1.ApplyWorkspaceEditRequest.type, params);
5318 }
5319}
5320const RemoteWorkspaceImpl = workspaceFolders_1.WorkspaceFoldersFeature(configuration_1.ConfigurationFeature(_RemoteWorkspaceImpl));
5321class TracerImpl {
5322 constructor() {
5323 this._trace = vscode_languageserver_protocol_1.Trace.Off;
5324 }
5325 attach(connection) {
5326 this._connection = connection;
5327 }
5328 get connection() {
5329 if (!this._connection) {
5330 throw new Error('Remote is not attached to a connection yet.');
5331 }
5332 return this._connection;
5333 }
5334 initialize(_capabilities) {
5335 }
5336 fillServerCapabilities(_capabilities) {
5337 }
5338 set trace(value) {
5339 this._trace = value;
5340 }
5341 log(message, verbose) {
5342 if (this._trace === vscode_languageserver_protocol_1.Trace.Off) {
5343 return;
5344 }
5345 this._connection.sendNotification(vscode_languageserver_protocol_1.LogTraceNotification.type, {
5346 message: message,
5347 verbose: this._trace === vscode_languageserver_protocol_1.Trace.Verbose ? verbose : undefined
5348 });
5349 }
5350}
5351class TelemetryImpl {
5352 constructor() {
5353 }
5354 attach(connection) {
5355 this._connection = connection;
5356 }
5357 get connection() {
5358 if (!this._connection) {
5359 throw new Error('Remote is not attached to a connection yet.');
5360 }
5361 return this._connection;
5362 }
5363 initialize(_capabilities) {
5364 }
5365 fillServerCapabilities(_capabilities) {
5366 }
5367 logEvent(data) {
5368 this._connection.sendNotification(vscode_languageserver_protocol_1.TelemetryEventNotification.type, data);
5369 }
5370}
5371function combineConsoleFeatures(one, two) {
5372 return function (Base) {
5373 return two(one(Base));
5374 };
5375}
5376exports.combineConsoleFeatures = combineConsoleFeatures;
5377function combineTelemetryFeatures(one, two) {
5378 return function (Base) {
5379 return two(one(Base));
5380 };
5381}
5382exports.combineTelemetryFeatures = combineTelemetryFeatures;
5383function combineTracerFeatures(one, two) {
5384 return function (Base) {
5385 return two(one(Base));
5386 };
5387}
5388exports.combineTracerFeatures = combineTracerFeatures;
5389function combineClientFeatures(one, two) {
5390 return function (Base) {
5391 return two(one(Base));
5392 };
5393}
5394exports.combineClientFeatures = combineClientFeatures;
5395function combineWindowFeatures(one, two) {
5396 return function (Base) {
5397 return two(one(Base));
5398 };
5399}
5400exports.combineWindowFeatures = combineWindowFeatures;
5401function combineWorkspaceFeatures(one, two) {
5402 return function (Base) {
5403 return two(one(Base));
5404 };
5405}
5406exports.combineWorkspaceFeatures = combineWorkspaceFeatures;
5407function combineFeatures(one, two) {
5408 function combine(one, two, func) {
5409 if (one && two) {
5410 return func(one, two);
5411 }
5412 else if (one) {
5413 return one;
5414 }
5415 else {
5416 return two;
5417 }
5418 }
5419 let result = {
5420 __brand: 'features',
5421 console: combine(one.console, two.console, combineConsoleFeatures),
5422 tracer: combine(one.tracer, two.tracer, combineTracerFeatures),
5423 telemetry: combine(one.telemetry, two.telemetry, combineTelemetryFeatures),
5424 client: combine(one.client, two.client, combineClientFeatures),
5425 window: combine(one.window, two.window, combineWindowFeatures),
5426 workspace: combine(one.workspace, two.workspace, combineWorkspaceFeatures)
5427 };
5428 return result;
5429}
5430exports.combineFeatures = combineFeatures;
5431function createConnection(arg1, arg2, arg3, arg4) {
5432 let factories;
5433 let input;
5434 let output;
5435 let strategy;
5436 if (arg1 !== void 0 && arg1.__brand === 'features') {
5437 factories = arg1;
5438 arg1 = arg2;
5439 arg2 = arg3;
5440 arg3 = arg4;
5441 }
5442 if (vscode_languageserver_protocol_1.ConnectionStrategy.is(arg1)) {
5443 strategy = arg1;
5444 }
5445 else {
5446 input = arg1;
5447 output = arg2;
5448 strategy = arg3;
5449 }
5450 return _createConnection(input, output, strategy, factories);
5451}
5452exports.createConnection = createConnection;
5453function _createConnection(input, output, strategy, factories) {
5454 if (!input && !output && process.argv.length > 2) {
5455 let port = void 0;
5456 let pipeName = void 0;
5457 let argv = process.argv.slice(2);
5458 for (let i = 0; i < argv.length; i++) {
5459 let arg = argv[i];
5460 if (arg === '--node-ipc') {
5461 input = new vscode_languageserver_protocol_1.IPCMessageReader(process);
5462 output = new vscode_languageserver_protocol_1.IPCMessageWriter(process);
5463 break;
5464 }
5465 else if (arg === '--stdio') {
5466 input = process.stdin;
5467 output = process.stdout;
5468 break;
5469 }
5470 else if (arg === '--socket') {
5471 port = parseInt(argv[i + 1]);
5472 break;
5473 }
5474 else if (arg === '--pipe') {
5475 pipeName = argv[i + 1];
5476 break;
5477 }
5478 else {
5479 var args = arg.split('=');
5480 if (args[0] === '--socket') {
5481 port = parseInt(args[1]);
5482 break;
5483 }
5484 else if (args[0] === '--pipe') {
5485 pipeName = args[1];
5486 break;
5487 }
5488 }
5489 }
5490 if (port) {
5491 let transport = vscode_languageserver_protocol_1.createServerSocketTransport(port);
5492 input = transport[0];
5493 output = transport[1];
5494 }
5495 else if (pipeName) {
5496 let transport = vscode_languageserver_protocol_1.createServerPipeTransport(pipeName);
5497 input = transport[0];
5498 output = transport[1];
5499 }
5500 }
5501 var commandLineMessage = "Use arguments of createConnection or set command line parameters: '--node-ipc', '--stdio' or '--socket={number}'";
5502 if (!input) {
5503 throw new Error("Connection input stream is not set. " + commandLineMessage);
5504 }
5505 if (!output) {
5506 throw new Error("Connection output stream is not set. " + commandLineMessage);
5507 }
5508 // Backwards compatibility
5509 if (Is.func(input.read) && Is.func(input.on)) {
5510 let inputStream = input;
5511 inputStream.on('end', () => {
5512 process.exit(shutdownReceived ? 0 : 1);
5513 });
5514 inputStream.on('close', () => {
5515 process.exit(shutdownReceived ? 0 : 1);
5516 });
5517 }
5518 const logger = (factories && factories.console ? new (factories.console(ConnectionLogger))() : new ConnectionLogger());
5519 const connection = vscode_languageserver_protocol_1.createProtocolConnection(input, output, logger, strategy);
5520 logger.rawAttach(connection);
5521 const tracer = (factories && factories.tracer ? new (factories.tracer(TracerImpl))() : new TracerImpl());
5522 const telemetry = (factories && factories.telemetry ? new (factories.telemetry(TelemetryImpl))() : new TelemetryImpl());
5523 const client = (factories && factories.client ? new (factories.client(RemoteClientImpl))() : new RemoteClientImpl());
5524 const remoteWindow = (factories && factories.window ? new (factories.window(RemoteWindowImpl))() : new RemoteWindowImpl());
5525 const workspace = (factories && factories.workspace ? new (factories.workspace(RemoteWorkspaceImpl))() : new RemoteWorkspaceImpl());
5526 const allRemotes = [logger, tracer, telemetry, client, remoteWindow, workspace];
5527 function asThenable(value) {
5528 if (Is.thenable(value)) {
5529 return value;
5530 }
5531 else {
5532 return Promise.resolve(value);
5533 }
5534 }
5535 let shutdownHandler = undefined;
5536 let initializeHandler = undefined;
5537 let exitHandler = undefined;
5538 let protocolConnection = {
5539 listen: () => connection.listen(),
5540 sendRequest: (type, ...params) => connection.sendRequest(Is.string(type) ? type : type.method, ...params),
5541 onRequest: (type, handler) => connection.onRequest(type, handler),
5542 sendNotification: (type, param) => {
5543 const method = Is.string(type) ? type : type.method;
5544 if (arguments.length === 1) {
5545 connection.sendNotification(method);
5546 }
5547 else {
5548 connection.sendNotification(method, param);
5549 }
5550 },
5551 onNotification: (type, handler) => connection.onNotification(type, handler),
5552 onInitialize: (handler) => initializeHandler = handler,
5553 onInitialized: (handler) => connection.onNotification(vscode_languageserver_protocol_1.InitializedNotification.type, handler),
5554 onShutdown: (handler) => shutdownHandler = handler,
5555 onExit: (handler) => exitHandler = handler,
5556 get console() { return logger; },
5557 get telemetry() { return telemetry; },
5558 get tracer() { return tracer; },
5559 get client() { return client; },
5560 get window() { return remoteWindow; },
5561 get workspace() { return workspace; },
5562 onDidChangeConfiguration: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeConfigurationNotification.type, handler),
5563 onDidChangeWatchedFiles: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeWatchedFilesNotification.type, handler),
5564 __textDocumentSync: undefined,
5565 onDidOpenTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.type, handler),
5566 onDidChangeTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeTextDocumentNotification.type, handler),
5567 onDidCloseTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.type, handler),
5568 onWillSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.WillSaveTextDocumentNotification.type, handler),
5569 onWillSaveTextDocumentWaitUntil: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WillSaveTextDocumentWaitUntilRequest.type, handler),
5570 onDidSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidSaveTextDocumentNotification.type, handler),
5571 sendDiagnostics: (params) => connection.sendNotification(vscode_languageserver_protocol_1.PublishDiagnosticsNotification.type, params),
5572 onHover: (handler) => connection.onRequest(vscode_languageserver_protocol_1.HoverRequest.type, handler),
5573 onCompletion: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionRequest.type, handler),
5574 onCompletionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionResolveRequest.type, handler),
5575 onSignatureHelp: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SignatureHelpRequest.type, handler),
5576 onDeclaration: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DeclarationRequest.type, handler),
5577 onDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DefinitionRequest.type, handler),
5578 onTypeDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.TypeDefinitionRequest.type, handler),
5579 onImplementation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ImplementationRequest.type, handler),
5580 onReferences: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ReferencesRequest.type, handler),
5581 onDocumentHighlight: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentHighlightRequest.type, handler),
5582 onDocumentSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentSymbolRequest.type, handler),
5583 onWorkspaceSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WorkspaceSymbolRequest.type, handler),
5584 onCodeAction: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionRequest.type, handler),
5585 onCodeLens: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensRequest.type, handler),
5586 onCodeLensResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensResolveRequest.type, handler),
5587 onDocumentFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentFormattingRequest.type, handler),
5588 onDocumentRangeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentRangeFormattingRequest.type, handler),
5589 onDocumentOnTypeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentOnTypeFormattingRequest.type, handler),
5590 onRenameRequest: (handler) => connection.onRequest(vscode_languageserver_protocol_1.RenameRequest.type, handler),
5591 onPrepareRename: (handler) => connection.onRequest(vscode_languageserver_protocol_1.PrepareRenameRequest.type, handler),
5592 onDocumentLinks: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkRequest.type, handler),
5593 onDocumentLinkResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkResolveRequest.type, handler),
5594 onDocumentColor: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentColorRequest.type, handler),
5595 onColorPresentation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ColorPresentationRequest.type, handler),
5596 onFoldingRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.FoldingRangeRequest.type, handler),
5597 onExecuteCommand: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, handler),
5598 dispose: () => connection.dispose()
5599 };
5600 for (let remote of allRemotes) {
5601 remote.attach(protocolConnection);
5602 }
5603 connection.onRequest(vscode_languageserver_protocol_1.InitializeRequest.type, (params) => {
5604 const processId = params.processId;
5605 if (Is.number(processId) && exitTimer === void 0) {
5606 // We received a parent process id. Set up a timer to periodically check
5607 // if the parent is still alive.
5608 setInterval(() => {
5609 try {
5610 process.kill(processId, 0);
5611 }
5612 catch (ex) {
5613 // Parent process doesn't exist anymore. Exit the server.
5614 process.exit(shutdownReceived ? 0 : 1);
5615 }
5616 }, 3000);
5617 }
5618 if (Is.string(params.trace)) {
5619 tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.trace);
5620 }
5621 for (let remote of allRemotes) {
5622 remote.initialize(params.capabilities);
5623 }
5624 if (initializeHandler) {
5625 let result = initializeHandler(params, new vscode_languageserver_protocol_1.CancellationTokenSource().token);
5626 return asThenable(result).then((value) => {
5627 if (value instanceof vscode_languageserver_protocol_1.ResponseError) {
5628 return value;
5629 }
5630 let result = value;
5631 if (!result) {
5632 result = { capabilities: {} };
5633 }
5634 let capabilities = result.capabilities;
5635 if (!capabilities) {
5636 capabilities = {};
5637 result.capabilities = capabilities;
5638 }
5639 if (capabilities.textDocumentSync === void 0 || capabilities.textDocumentSync === null) {
5640 capabilities.textDocumentSync = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
5641 }
5642 else if (!Is.number(capabilities.textDocumentSync) && !Is.number(capabilities.textDocumentSync.change)) {
5643 capabilities.textDocumentSync.change = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;
5644 }
5645 for (let remote of allRemotes) {
5646 remote.fillServerCapabilities(capabilities);
5647 }
5648 return result;
5649 });
5650 }
5651 else {
5652 let result = { capabilities: { textDocumentSync: vscode_languageserver_protocol_1.TextDocumentSyncKind.None } };
5653 for (let remote of allRemotes) {
5654 remote.fillServerCapabilities(result.capabilities);
5655 }
5656 return result;
5657 }
5658 });
5659 connection.onRequest(vscode_languageserver_protocol_1.ShutdownRequest.type, () => {
5660 shutdownReceived = true;
5661 if (shutdownHandler) {
5662 return shutdownHandler(new vscode_languageserver_protocol_1.CancellationTokenSource().token);
5663 }
5664 else {
5665 return undefined;
5666 }
5667 });
5668 connection.onNotification(vscode_languageserver_protocol_1.ExitNotification.type, () => {
5669 try {
5670 if (exitHandler) {
5671 exitHandler();
5672 }
5673 }
5674 finally {
5675 if (shutdownReceived) {
5676 process.exit(0);
5677 }
5678 else {
5679 process.exit(1);
5680 }
5681 }
5682 });
5683 connection.onNotification(vscode_languageserver_protocol_1.SetTraceNotification.type, (params) => {
5684 tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.value);
5685 });
5686 return protocolConnection;
5687}
5688// Export the protocol currently in proposed state.
5689var ProposedFeatures;
5690(function (ProposedFeatures) {
5691 ProposedFeatures.all = {
5692 __brand: 'features',
5693 };
5694})(ProposedFeatures = exports.ProposedFeatures || (exports.ProposedFeatures = {}));
5695
5696
5697/***/ }),
5698
5699/***/ 40:
5700/***/ (function(module, exports, __webpack_require__) {
5701
5702"use strict";
5703
5704var __assign = (this && this.__assign) || function () {
5705 __assign = Object.assign || function(t) {
5706 for (var s, i = 1, n = arguments.length; i < n; i++) {
5707 s = arguments[i];
5708 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
5709 t[p] = s[p];
5710 }
5711 return t;
5712 };
5713 return __assign.apply(this, arguments);
5714};
5715var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5716 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5717 return new (P || (P = Promise))(function (resolve, reject) {
5718 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5719 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
5720 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
5721 step((generator = generator.apply(thisArg, _arguments || [])).next());
5722 });
5723};
5724var __generator = (this && this.__generator) || function (thisArg, body) {
5725 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
5726 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
5727 function verb(n) { return function (v) { return step([n, v]); }; }
5728 function step(op) {
5729 if (f) throw new TypeError("Generator is already executing.");
5730 while (_) try {
5731 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;
5732 if (y = 0, t) op = [op[0] & 2, t.value];
5733 switch (op[0]) {
5734 case 0: case 1: t = op; break;
5735 case 4: _.label++; return { value: op[1], done: false };
5736 case 5: _.label++; y = op[1]; op = [0]; continue;
5737 case 7: op = _.ops.pop(); _.trys.pop(); continue;
5738 default:
5739 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
5740 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
5741 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
5742 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
5743 if (t[2]) _.ops.pop();
5744 _.trys.pop(); continue;
5745 }
5746 op = body.call(thisArg, _);
5747 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
5748 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
5749 }
5750};
5751var __spreadArrays = (this && this.__spreadArrays) || function () {
5752 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
5753 for (var r = Array(s), k = 0, i = 0; i < il; i++)
5754 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
5755 r[k] = a[j];
5756 return r;
5757};
5758var __importDefault = (this && this.__importDefault) || function (mod) {
5759 return (mod && mod.__esModule) ? mod : { "default": mod };
5760};
5761Object.defineProperty(exports, "__esModule", { value: true });
5762var child_process_1 = __webpack_require__(37);
5763var findup_1 = __importDefault(__webpack_require__(41));
5764var fs_1 = __importDefault(__webpack_require__(36));
5765var path_1 = __importDefault(__webpack_require__(15));
5766var vscode_languageserver_1 = __webpack_require__(4);
5767var vimparser_1 = __webpack_require__(46);
5768var patterns_1 = __webpack_require__(48);
5769function isSomeMatchPattern(patterns, line) {
5770 return patterns.some(function (p) { return p.test(line); });
5771}
5772exports.isSomeMatchPattern = isSomeMatchPattern;
5773function executeFile(input, command, args, option) {
5774 return new Promise(function (resolve, reject) {
5775 var stdout = "";
5776 var stderr = "";
5777 var error;
5778 var isPassAsText = false;
5779 args = (args || []).map(function (arg) {
5780 if (/%text/.test(arg)) {
5781 isPassAsText = true;
5782 return arg.replace(/%text/g, input.toString());
5783 }
5784 return arg;
5785 });
5786 var cp = child_process_1.spawn(command, args, option);
5787 cp.stdout.on("data", function (data) {
5788 stdout += data;
5789 });
5790 cp.stderr.on("data", function (data) {
5791 stderr += data;
5792 });
5793 cp.on("error", function (err) {
5794 error = err;
5795 reject(error);
5796 });
5797 cp.on("close", function (code) {
5798 if (!error) {
5799 resolve({ code: code, stdout: stdout, stderr: stderr });
5800 }
5801 });
5802 // error will occur when cp get error
5803 if (!isPassAsText) {
5804 input.pipe(cp.stdin).on("error", function () { return; });
5805 }
5806 });
5807}
5808exports.executeFile = executeFile;
5809// cover cb type async function to promise
5810function pcb(cb) {
5811 return function () {
5812 var args = [];
5813 for (var _i = 0; _i < arguments.length; _i++) {
5814 args[_i] = arguments[_i];
5815 }
5816 return new Promise(function (resolve) {
5817 cb.apply(void 0, __spreadArrays(args, [function () {
5818 var params = [];
5819 for (var _i = 0; _i < arguments.length; _i++) {
5820 params[_i] = arguments[_i];
5821 }
5822 resolve(params);
5823 }]));
5824 });
5825 };
5826}
5827exports.pcb = pcb;
5828// find work dirname by root patterns
5829function findProjectRoot(filePath, rootPatterns) {
5830 return __awaiter(this, void 0, void 0, function () {
5831 var dirname, patterns, dirCandidate, _i, patterns_2, pattern, _a, err, dir;
5832 return __generator(this, function (_b) {
5833 switch (_b.label) {
5834 case 0:
5835 dirname = path_1.default.dirname(filePath);
5836 patterns = [].concat(rootPatterns);
5837 dirCandidate = "";
5838 _i = 0, patterns_2 = patterns;
5839 _b.label = 1;
5840 case 1:
5841 if (!(_i < patterns_2.length)) return [3 /*break*/, 4];
5842 pattern = patterns_2[_i];
5843 return [4 /*yield*/, pcb(findup_1.default)(dirname, pattern)];
5844 case 2:
5845 _a = _b.sent(), err = _a[0], dir = _a[1];
5846 if (!err && dir && dir !== "/" && dir.length > dirCandidate.length) {
5847 dirCandidate = dir;
5848 }
5849 _b.label = 3;
5850 case 3:
5851 _i++;
5852 return [3 /*break*/, 1];
5853 case 4:
5854 if (dirCandidate.length) {
5855 return [2 /*return*/, dirCandidate];
5856 }
5857 return [2 /*return*/, dirname];
5858 }
5859 });
5860 });
5861}
5862exports.findProjectRoot = findProjectRoot;
5863function markupSnippets(snippets) {
5864 return [
5865 "```vim",
5866 snippets.replace(/\$\{[0-9]+(:([^}]+))?\}/g, "$2"),
5867 "```",
5868 ].join("\n");
5869}
5870exports.markupSnippets = markupSnippets;
5871function getWordFromPosition(doc, position) {
5872 if (!doc) {
5873 return;
5874 }
5875 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)));
5876 // not keyword position
5877 if (!character || !patterns_1.keywordPattern.test(character)) {
5878 return;
5879 }
5880 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)));
5881 // comment line
5882 if (patterns_1.commentPattern.test(currentLine)) {
5883 return;
5884 }
5885 var preSegment = currentLine.slice(0, position.character);
5886 var nextSegment = currentLine.slice(position.character);
5887 var wordLeft = preSegment.match(patterns_1.wordPrePattern);
5888 var wordRight = nextSegment.match(patterns_1.wordNextPattern);
5889 var word = "" + (wordLeft && wordLeft[1] || "") + (wordRight && wordRight[1] || "");
5890 return {
5891 word: word,
5892 left: wordLeft && wordLeft[1] || "",
5893 right: wordRight && wordRight[1] || "",
5894 wordLeft: wordLeft && wordLeft[1]
5895 ? preSegment.replace(new RegExp(wordLeft[1] + "$"), word)
5896 : "" + preSegment + word,
5897 wordRight: wordRight && wordRight[1]
5898 ? nextSegment.replace(new RegExp("^" + wordRight[1]), word)
5899 : "" + word + nextSegment,
5900 };
5901}
5902exports.getWordFromPosition = getWordFromPosition;
5903// parse vim buffer
5904function handleParse(textDoc) {
5905 return __awaiter(this, void 0, void 0, function () {
5906 var text, tokens, node;
5907 return __generator(this, function (_a) {
5908 text = textDoc instanceof Object ? textDoc.getText() : textDoc;
5909 tokens = new vimparser_1.StringReader(text.split(/\r\n|\r|\n/));
5910 try {
5911 node = new vimparser_1.VimLParser(true).parse(tokens);
5912 return [2 /*return*/, [node, ""]];
5913 }
5914 catch (error) {
5915 return [2 /*return*/, [null, error]];
5916 }
5917 return [2 /*return*/];
5918 });
5919 });
5920}
5921exports.handleParse = handleParse;
5922// remove snippets of completionItem
5923function removeSnippets(completionItems) {
5924 if (completionItems === void 0) { completionItems = []; }
5925 return completionItems.map(function (item) {
5926 if (item.insertTextFormat === vscode_languageserver_1.InsertTextFormat.Snippet) {
5927 return __assign(__assign({}, item), { insertText: item.label, insertTextFormat: vscode_languageserver_1.InsertTextFormat.PlainText });
5928 }
5929 return item;
5930 });
5931}
5932exports.removeSnippets = removeSnippets;
5933exports.isSymbolLink = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
5934 return __generator(this, function (_a) {
5935 return [2 /*return*/, new Promise(function (resolve) {
5936 fs_1.default.lstat(filePath, function (err, stats) {
5937 resolve({
5938 err: err,
5939 stats: stats && stats.isSymbolicLink(),
5940 });
5941 });
5942 })];
5943 });
5944}); };
5945exports.getRealPath = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
5946 var _a, err, stats;
5947 return __generator(this, function (_b) {
5948 switch (_b.label) {
5949 case 0: return [4 /*yield*/, exports.isSymbolLink(filePath)];
5950 case 1:
5951 _a = _b.sent(), err = _a.err, stats = _a.stats;
5952 if (!err && stats) {
5953 return [2 /*return*/, new Promise(function (resolve) {
5954 fs_1.default.realpath(filePath, function (error, realPath) {
5955 if (error) {
5956 return resolve(filePath);
5957 }
5958 resolve(realPath);
5959 });
5960 })];
5961 }
5962 return [2 /*return*/, filePath];
5963 }
5964 });
5965}); };
5966
5967
5968/***/ }),
5969
5970/***/ 41:
5971/***/ (function(module, exports, __webpack_require__) {
5972
5973var fs = __webpack_require__(36),
5974 Path = __webpack_require__(15),
5975 util = __webpack_require__(42),
5976 colors = __webpack_require__(43),
5977 EE = __webpack_require__(45).EventEmitter,
5978 fsExists = fs.exists ? fs.exists : Path.exists,
5979 fsExistsSync = fs.existsSync ? fs.existsSync : Path.existsSync;
5980
5981module.exports = function(dir, iterator, options, callback){
5982 return FindUp(dir, iterator, options, callback);
5983};
5984
5985function FindUp(dir, iterator, options, callback){
5986 if (!(this instanceof FindUp)) {
5987 return new FindUp(dir, iterator, options, callback);
5988 }
5989 if(typeof options === 'function'){
5990 callback = options;
5991 options = {};
5992 }
5993 options = options || {};
5994
5995 EE.call(this);
5996 this.found = false;
5997 this.stopPlease = false;
5998 var self = this;
5999
6000 if(typeof iterator === 'string'){
6001 var file = iterator;
6002 iterator = function(dir, cb){
6003 return fsExists(Path.join(dir, file), cb);
6004 };
6005 }
6006
6007 if(callback) {
6008 this.on('found', function(dir){
6009 if(options.verbose) console.log(('found '+ dir ).green);
6010 callback(null, dir);
6011 self.stop();
6012 });
6013
6014 this.on('end', function(){
6015 if(options.verbose) console.log('end'.grey);
6016 if(!self.found) callback(new Error('not found'));
6017 });
6018
6019 this.on('error', function(err){
6020 if(options.verbose) console.log('error'.red, err);
6021 callback(err);
6022 });
6023 }
6024
6025 this._find(dir, iterator, options, callback);
6026}
6027util.inherits(FindUp, EE);
6028
6029FindUp.prototype._find = function(dir, iterator, options, callback){
6030 var self = this;
6031
6032 iterator(dir, function(exists){
6033 if(options.verbose) console.log(('traverse '+ dir).grey);
6034 if(exists) {
6035 self.found = true;
6036 self.emit('found', dir);
6037 }
6038
6039 var parentDir = Path.join(dir, '..');
6040 if (self.stopPlease) return self.emit('end');
6041 if (dir === parentDir) return self.emit('end');
6042 if(dir.indexOf('../../') !== -1 ) return self.emit('error', new Error(dir + ' is not correct.'));
6043 self._find(parentDir, iterator, options, callback);
6044 });
6045};
6046
6047FindUp.prototype.stop = function(){
6048 this.stopPlease = true;
6049};
6050
6051module.exports.FindUp = FindUp;
6052
6053module.exports.sync = function(dir, iteratorSync){
6054 if(typeof iteratorSync === 'string'){
6055 var file = iteratorSync;
6056 iteratorSync = function(dir){
6057 return fsExistsSync(Path.join(dir, file));
6058 };
6059 }
6060 var initialDir = dir;
6061 while(dir !== Path.join(dir, '..')){
6062 if(dir.indexOf('../../') !== -1 ) throw new Error(initialDir + ' is not correct.');
6063 if(iteratorSync(dir)) return dir;
6064 dir = Path.join(dir, '..');
6065 }
6066 throw new Error('not found');
6067};
6068
6069
6070/***/ }),
6071
6072/***/ 42:
6073/***/ (function(module, exports) {
6074
6075module.exports = require("util");
6076
6077/***/ }),
6078
6079/***/ 43:
6080/***/ (function(module, exports, __webpack_require__) {
6081
6082/*
6083colors.js
6084
6085Copyright (c) 2010
6086
6087Marak Squires
6088Alexis Sellier (cloudhead)
6089
6090Permission is hereby granted, free of charge, to any person obtaining a copy
6091of this software and associated documentation files (the "Software"), to deal
6092in the Software without restriction, including without limitation the rights
6093to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
6094copies of the Software, and to permit persons to whom the Software is
6095furnished to do so, subject to the following conditions:
6096
6097The above copyright notice and this permission notice shall be included in
6098all copies or substantial portions of the Software.
6099
6100THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6101IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
6102FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
6103AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
6104LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
6105OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
6106THE SOFTWARE.
6107
6108*/
6109
6110var isHeadless = false;
6111
6112if (typeof module !== 'undefined') {
6113 isHeadless = true;
6114}
6115
6116if (!isHeadless) {
6117 var exports = {};
6118 var module = {};
6119 var colors = exports;
6120 exports.mode = "browser";
6121} else {
6122 exports.mode = "console";
6123}
6124
6125//
6126// Prototypes the string object to have additional method calls that add terminal colors
6127//
6128var addProperty = function (color, func) {
6129 exports[color] = function (str) {
6130 return func.apply(str);
6131 };
6132 String.prototype.__defineGetter__(color, func);
6133};
6134
6135function stylize(str, style) {
6136
6137 var styles;
6138
6139 if (exports.mode === 'console') {
6140 styles = {
6141 //styles
6142 'bold' : ['\x1B[1m', '\x1B[22m'],
6143 'italic' : ['\x1B[3m', '\x1B[23m'],
6144 'underline' : ['\x1B[4m', '\x1B[24m'],
6145 'inverse' : ['\x1B[7m', '\x1B[27m'],
6146 'strikethrough' : ['\x1B[9m', '\x1B[29m'],
6147 //text colors
6148 //grayscale
6149 'white' : ['\x1B[37m', '\x1B[39m'],
6150 'grey' : ['\x1B[90m', '\x1B[39m'],
6151 'black' : ['\x1B[30m', '\x1B[39m'],
6152 //colors
6153 'blue' : ['\x1B[34m', '\x1B[39m'],
6154 'cyan' : ['\x1B[36m', '\x1B[39m'],
6155 'green' : ['\x1B[32m', '\x1B[39m'],
6156 'magenta' : ['\x1B[35m', '\x1B[39m'],
6157 'red' : ['\x1B[31m', '\x1B[39m'],
6158 'yellow' : ['\x1B[33m', '\x1B[39m'],
6159 //background colors
6160 //grayscale
6161 'whiteBG' : ['\x1B[47m', '\x1B[49m'],
6162 'greyBG' : ['\x1B[49;5;8m', '\x1B[49m'],
6163 'blackBG' : ['\x1B[40m', '\x1B[49m'],
6164 //colors
6165 'blueBG' : ['\x1B[44m', '\x1B[49m'],
6166 'cyanBG' : ['\x1B[46m', '\x1B[49m'],
6167 'greenBG' : ['\x1B[42m', '\x1B[49m'],
6168 'magentaBG' : ['\x1B[45m', '\x1B[49m'],
6169 'redBG' : ['\x1B[41m', '\x1B[49m'],
6170 'yellowBG' : ['\x1B[43m', '\x1B[49m']
6171 };
6172 } else if (exports.mode === 'browser') {
6173 styles = {
6174 //styles
6175 'bold' : ['<b>', '</b>'],
6176 'italic' : ['<i>', '</i>'],
6177 'underline' : ['<u>', '</u>'],
6178 'inverse' : ['<span style="background-color:black;color:white;">', '</span>'],
6179 'strikethrough' : ['<del>', '</del>'],
6180 //text colors
6181 //grayscale
6182 'white' : ['<span style="color:white;">', '</span>'],
6183 'grey' : ['<span style="color:gray;">', '</span>'],
6184 'black' : ['<span style="color:black;">', '</span>'],
6185 //colors
6186 'blue' : ['<span style="color:blue;">', '</span>'],
6187 'cyan' : ['<span style="color:cyan;">', '</span>'],
6188 'green' : ['<span style="color:green;">', '</span>'],
6189 'magenta' : ['<span style="color:magenta;">', '</span>'],
6190 'red' : ['<span style="color:red;">', '</span>'],
6191 'yellow' : ['<span style="color:yellow;">', '</span>'],
6192 //background colors
6193 //grayscale
6194 'whiteBG' : ['<span style="background-color:white;">', '</span>'],
6195 'greyBG' : ['<span style="background-color:gray;">', '</span>'],
6196 'blackBG' : ['<span style="background-color:black;">', '</span>'],
6197 //colors
6198 'blueBG' : ['<span style="background-color:blue;">', '</span>'],
6199 'cyanBG' : ['<span style="background-color:cyan;">', '</span>'],
6200 'greenBG' : ['<span style="background-color:green;">', '</span>'],
6201 'magentaBG' : ['<span style="background-color:magenta;">', '</span>'],
6202 'redBG' : ['<span style="background-color:red;">', '</span>'],
6203 'yellowBG' : ['<span style="background-color:yellow;">', '</span>']
6204 };
6205 } else if (exports.mode === 'none') {
6206 return str + '';
6207 } else {
6208 console.log('unsupported mode, try "browser", "console" or "none"');
6209 }
6210 return styles[style][0] + str + styles[style][1];
6211}
6212
6213function applyTheme(theme) {
6214
6215 //
6216 // Remark: This is a list of methods that exist
6217 // on String that you should not overwrite.
6218 //
6219 var stringPrototypeBlacklist = [
6220 '__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', 'charAt', 'constructor',
6221 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf', 'charCodeAt',
6222 'indexOf', 'lastIndexof', 'length', 'localeCompare', 'match', 'replace', 'search', 'slice', 'split', 'substring',
6223 'toLocaleLowerCase', 'toLocaleUpperCase', 'toLowerCase', 'toUpperCase', 'trim', 'trimLeft', 'trimRight'
6224 ];
6225
6226 Object.keys(theme).forEach(function (prop) {
6227 if (stringPrototypeBlacklist.indexOf(prop) !== -1) {
6228 console.log('warn: '.red + ('String.prototype' + prop).magenta + ' is probably something you don\'t want to override. Ignoring style name');
6229 }
6230 else {
6231 if (typeof(theme[prop]) === 'string') {
6232 addProperty(prop, function () {
6233 return exports[theme[prop]](this);
6234 });
6235 }
6236 else {
6237 addProperty(prop, function () {
6238 var ret = this;
6239 for (var t = 0; t < theme[prop].length; t++) {
6240 ret = exports[theme[prop][t]](ret);
6241 }
6242 return ret;
6243 });
6244 }
6245 }
6246 });
6247}
6248
6249
6250//
6251// Iterate through all default styles and colors
6252//
6253var x = ['bold', 'underline', 'strikethrough', 'italic', 'inverse', 'grey', 'black', 'yellow', 'red', 'green', 'blue', 'white', 'cyan', 'magenta', 'greyBG', 'blackBG', 'yellowBG', 'redBG', 'greenBG', 'blueBG', 'whiteBG', 'cyanBG', 'magentaBG'];
6254x.forEach(function (style) {
6255
6256 // __defineGetter__ at the least works in more browsers
6257 // http://robertnyman.com/javascript/javascript-getters-setters.html
6258 // Object.defineProperty only works in Chrome
6259 addProperty(style, function () {
6260 return stylize(this, style);
6261 });
6262});
6263
6264function sequencer(map) {
6265 return function () {
6266 if (!isHeadless) {
6267 return this.replace(/( )/, '$1');
6268 }
6269 var exploded = this.split(""), i = 0;
6270 exploded = exploded.map(map);
6271 return exploded.join("");
6272 };
6273}
6274
6275var rainbowMap = (function () {
6276 var rainbowColors = ['red', 'yellow', 'green', 'blue', 'magenta']; //RoY G BiV
6277 return function (letter, i, exploded) {
6278 if (letter === " ") {
6279 return letter;
6280 } else {
6281 return stylize(letter, rainbowColors[i++ % rainbowColors.length]);
6282 }
6283 };
6284})();
6285
6286exports.themes = {};
6287
6288exports.addSequencer = function (name, map) {
6289 addProperty(name, sequencer(map));
6290};
6291
6292exports.addSequencer('rainbow', rainbowMap);
6293exports.addSequencer('zebra', function (letter, i, exploded) {
6294 return i % 2 === 0 ? letter : letter.inverse;
6295});
6296
6297exports.setTheme = function (theme) {
6298 if (typeof theme === 'string') {
6299 try {
6300 exports.themes[theme] = __webpack_require__(44)(theme);
6301 applyTheme(exports.themes[theme]);
6302 return exports.themes[theme];
6303 } catch (err) {
6304 console.log(err);
6305 return err;
6306 }
6307 } else {
6308 applyTheme(theme);
6309 }
6310};
6311
6312
6313addProperty('stripColors', function () {
6314 return ("" + this).replace(/\x1B\[\d+m/g, '');
6315});
6316
6317// please no
6318function zalgo(text, options) {
6319 var soul = {
6320 "up" : [
6321 '̍', '̎', '̄', '̅',
6322 '̿', '̑', '̆', '̐',
6323 '͒', '͗', '͑', '̇',
6324 '̈', '̊', '͂', '̓',
6325 '̈', '͊', '͋', '͌',
6326 '̃', '̂', '̌', '͐',
6327 '̀', '́', '̋', '̏',
6328 '̒', '̓', '̔', '̽',
6329 '̉', 'ͣ', 'ͤ', 'ͥ',
6330 'ͦ', 'ͧ', 'ͨ', 'ͩ',
6331 'ͪ', 'ͫ', 'ͬ', 'ͭ',
6332 'ͮ', 'ͯ', '̾', '͛',
6333 '͆', '̚'
6334 ],
6335 "down" : [
6336 '̖', '̗', '̘', '̙',
6337 '̜', '̝', '̞', '̟',
6338 '̠', '̤', '̥', '̦',
6339 '̩', '̪', '̫', '̬',
6340 '̭', '̮', '̯', '̰',
6341 '̱', '̲', '̳', '̹',
6342 '̺', '̻', '̼', 'ͅ',
6343 '͇', '͈', '͉', '͍',
6344 '͎', '͓', '͔', '͕',
6345 '͖', '͙', '͚', '̣'
6346 ],
6347 "mid" : [
6348 '̕', '̛', '̀', '́',
6349 '͘', '̡', '̢', '̧',
6350 '̨', '̴', '̵', '̶',
6351 '͜', '͝', '͞',
6352 '͟', '͠', '͢', '̸',
6353 '̷', '͡', ' ҉'
6354 ]
6355 },
6356 all = [].concat(soul.up, soul.down, soul.mid),
6357 zalgo = {};
6358
6359 function randomNumber(range) {
6360 var r = Math.floor(Math.random() * range);
6361 return r;
6362 }
6363
6364 function is_char(character) {
6365 var bool = false;
6366 all.filter(function (i) {
6367 bool = (i === character);
6368 });
6369 return bool;
6370 }
6371
6372 function heComes(text, options) {
6373 var result = '', counts, l;
6374 options = options || {};
6375 options["up"] = options["up"] || true;
6376 options["mid"] = options["mid"] || true;
6377 options["down"] = options["down"] || true;
6378 options["size"] = options["size"] || "maxi";
6379 text = text.split('');
6380 for (l in text) {
6381 if (is_char(l)) {
6382 continue;
6383 }
6384 result = result + text[l];
6385 counts = {"up" : 0, "down" : 0, "mid" : 0};
6386 switch (options.size) {
6387 case 'mini':
6388 counts.up = randomNumber(8);
6389 counts.min = randomNumber(2);
6390 counts.down = randomNumber(8);
6391 break;
6392 case 'maxi':
6393 counts.up = randomNumber(16) + 3;
6394 counts.min = randomNumber(4) + 1;
6395 counts.down = randomNumber(64) + 3;
6396 break;
6397 default:
6398 counts.up = randomNumber(8) + 1;
6399 counts.mid = randomNumber(6) / 2;
6400 counts.down = randomNumber(8) + 1;
6401 break;
6402 }
6403
6404 var arr = ["up", "mid", "down"];
6405 for (var d in arr) {
6406 var index = arr[d];
6407 for (var i = 0 ; i <= counts[index]; i++) {
6408 if (options[index]) {
6409 result = result + soul[index][randomNumber(soul[index].length)];
6410 }
6411 }
6412 }
6413 }
6414 return result;
6415 }
6416 return heComes(text);
6417}
6418
6419
6420// don't summon zalgo
6421addProperty('zalgo', function () {
6422 return zalgo(this);
6423});
6424
6425
6426/***/ }),
6427
6428/***/ 44:
6429/***/ (function(module, exports) {
6430
6431function webpackEmptyContext(req) {
6432 var e = new Error("Cannot find module '" + req + "'");
6433 e.code = 'MODULE_NOT_FOUND';
6434 throw e;
6435}
6436webpackEmptyContext.keys = function() { return []; };
6437webpackEmptyContext.resolve = webpackEmptyContext;
6438module.exports = webpackEmptyContext;
6439webpackEmptyContext.id = 44;
6440
6441/***/ }),
6442
6443/***/ 45:
6444/***/ (function(module, exports) {
6445
6446module.exports = require("events");
6447
6448/***/ }),
6449
6450/***/ 46:
6451/***/ (function(module, exports, __webpack_require__) {
6452
6453/* WEBPACK VAR INJECTION */(function(module) {//!/usr/bin/env nodejs
6454// usage: nodejs vimlparser.js [--neovim] foo.vim
6455
6456var fs = __webpack_require__(36);
6457var util = __webpack_require__(42);
6458
6459function main() {
6460 var neovim = false;
6461 var fpath = ''
6462 var args = process.argv;
6463 if (args.length == 4) {
6464 if (args[2] == '--neovim') {
6465 neovim = true;
6466 }
6467 fpath = args[3];
6468 } else if (args.length == 3) {
6469 neovim = false;
6470 fpath = args[2]
6471 }
6472 var r = new StringReader(viml_readfile(fpath));
6473 var p = new VimLParser(neovim);
6474 var c = new Compiler();
6475 try {
6476 var lines = c.compile(p.parse(r));
6477 for (var i in lines) {
6478 process.stdout.write(lines[i] + "\n");
6479 }
6480 } catch (e) {
6481 process.stdout.write(e + '\n');
6482 }
6483}
6484
6485var pat_vim2js = {
6486 "[0-9a-zA-Z]" : "[0-9a-zA-Z]",
6487 "[@*!=><&~#]" : "[@*!=><&~#]",
6488 "\\<ARGOPT\\>" : "\\bARGOPT\\b",
6489 "\\<BANG\\>" : "\\bBANG\\b",
6490 "\\<EDITCMD\\>" : "\\bEDITCMD\\b",
6491 "\\<NOTRLCOM\\>" : "\\bNOTRLCOM\\b",
6492 "\\<TRLBAR\\>" : "\\bTRLBAR\\b",
6493 "\\<USECTRLV\\>" : "\\bUSECTRLV\\b",
6494 "\\<USERCMD\\>" : "\\bUSERCMD\\b",
6495 "\\<\\(XFILE\\|FILES\\|FILE1\\)\\>" : "\\b(XFILE|FILES|FILE1)\\b",
6496 "\\S" : "\\S",
6497 "\\a" : "[A-Za-z]",
6498 "\\d" : "\\d",
6499 "\\h" : "[A-Za-z_]",
6500 "\\s" : "\\s",
6501 "\\v^d%[elete][lp]$" : "^d(elete|elet|ele|el|e)[lp]$",
6502 "\\v^s%(c[^sr][^i][^p]|g|i[^mlg]|I|r[^e])" : "^s(c[^sr][^i][^p]|g|i[^mlg]|I|r[^e])",
6503 "\\w" : "[0-9A-Za-z_]",
6504 "\\w\\|[:#]" : "[0-9A-Za-z_]|[:#]",
6505 "\\x" : "[0-9A-Fa-f]",
6506 "^++" : "^\+\+",
6507 "^++bad=\\(keep\\|drop\\|.\\)\\>" : "^\\+\\+bad=(keep|drop|.)\\b",
6508 "^++bad=drop" : "^\\+\\+bad=drop",
6509 "^++bad=keep" : "^\\+\\+bad=keep",
6510 "^++bin\\>" : "^\\+\\+bin\\b",
6511 "^++edit\\>" : "^\\+\\+edit\\b",
6512 "^++enc=\\S" : "^\\+\\+enc=\\S",
6513 "^++encoding=\\S" : "^\\+\\+encoding=\\S",
6514 "^++ff=\\(dos\\|unix\\|mac\\)\\>" : "^\\+\\+ff=(dos|unix|mac)\\b",
6515 "^++fileformat=\\(dos\\|unix\\|mac\\)\\>" : "^\\+\\+fileformat=(dos|unix|mac)\\b",
6516 "^++nobin\\>" : "^\\+\\+nobin\\b",
6517 "^[A-Z]" : "^[A-Z]",
6518 "^\\$\\w\\+" : "^\\$[0-9A-Za-z_]+",
6519 "^\\(!\\|global\\|vglobal\\)$" : "^(!|global|vglobal)$",
6520 "^\\(WHILE\\|FOR\\)$" : "^(WHILE|FOR)$",
6521 "^\\(vimgrep\\|vimgrepadd\\|lvimgrep\\|lvimgrepadd\\)$" : "^(vimgrep|vimgrepadd|lvimgrep|lvimgrepadd)$",
6522 "^\\d" : "^\\d",
6523 "^\\h" : "^[A-Za-z_]",
6524 "^\\s" : "^\\s",
6525 "^\\s*\\\\" : "^\\s*\\\\",
6526 "^[ \\t]$" : "^[ \\t]$",
6527 "^[A-Za-z]$" : "^[A-Za-z]$",
6528 "^[0-9A-Za-z]$" : "^[0-9A-Za-z]$",
6529 "^[0-9]$" : "^[0-9]$",
6530 "^[0-9A-Fa-f]$" : "^[0-9A-Fa-f]$",
6531 "^[0-9A-Za-z_]$" : "^[0-9A-Za-z_]$",
6532 "^[A-Za-z_]$" : "^[A-Za-z_]$",
6533 "^[0-9A-Za-z_:#]$" : "^[0-9A-Za-z_:#]$",
6534 "^[A-Za-z_][0-9A-Za-z_]*$" : "^[A-Za-z_][0-9A-Za-z_]*$",
6535 "^[A-Z]$" : "^[A-Z]$",
6536 "^[a-z]$" : "^[a-z]$",
6537 "^[vgslabwt]:$\\|^\\([vgslabwt]:\\)\\?[A-Za-z_][0-9A-Za-z_#]*$" : "^[vgslabwt]:$|^([vgslabwt]:)?[A-Za-z_][0-9A-Za-z_#]*$",
6538 "^[0-7]$" : "^[0-7]$",
6539 "^[0-9A-Fa-f][0-9A-Fa-f]$" : "^[0-9A-Fa-f][0-9A-Fa-f]$",
6540 "^\\.[0-9A-Fa-f]$" : "^\\.[0-9A-Fa-f]$",
6541 "^[0-9A-Fa-f][^0-9A-Fa-f]$" : "^[0-9A-Fa-f][^0-9A-Fa-f]$",
6542}
6543
6544function viml_add(lst, item) {
6545 lst.push(item);
6546}
6547
6548function viml_call(func, args) {
6549 return func.apply(null, args);
6550}
6551
6552function viml_char2nr(c) {
6553 return c.charCodeAt(0);
6554}
6555
6556function viml_empty(obj) {
6557 return obj.length == 0;
6558}
6559
6560function viml_equalci(a, b) {
6561 return a.toLowerCase() == b.toLowerCase();
6562}
6563
6564function viml_eqreg(s, reg) {
6565 var mx = new RegExp(pat_vim2js[reg]);
6566 return mx.exec(s) != null;
6567}
6568
6569function viml_eqregh(s, reg) {
6570 var mx = new RegExp(pat_vim2js[reg]);
6571 return mx.exec(s) != null;
6572}
6573
6574function viml_eqregq(s, reg) {
6575 var mx = new RegExp(pat_vim2js[reg], "i");
6576 return mx.exec(s) != null;
6577}
6578
6579function viml_escape(s, chars) {
6580 var r = '';
6581 for (var i = 0; i < s.length; ++i) {
6582 if (chars.indexOf(s.charAt(i)) != -1) {
6583 r = r + "\\" + s.charAt(i);
6584 } else {
6585 r = r + s.charAt(i);
6586 }
6587 }
6588 return r;
6589}
6590
6591function viml_extend(obj, item) {
6592 obj.push.apply(obj, item);
6593}
6594
6595function viml_insert(lst, item) {
6596 var idx = arguments.length >= 3 ? arguments[2] : 0;
6597 lst.splice(0, 0, item);
6598}
6599
6600function viml_join(lst, sep) {
6601 return lst.join(sep);
6602}
6603
6604function viml_keys(obj) {
6605 return Object.keys(obj);
6606}
6607
6608function viml_len(obj) {
6609 if (typeof obj === 'string') {
6610 var len = 0;
6611 for (var i = 0; i < obj.length; i++) {
6612 var c = obj.charCodeAt(i);
6613 len += c < 128 ? 1 : ((c > 127) && (c < 2048)) ? 2 : 3;
6614 }
6615 return len;
6616 }
6617 return obj.length;
6618}
6619
6620function viml_printf() {
6621 var a000 = Array.prototype.slice.call(arguments, 0);
6622 if (a000.length == 1) {
6623 return a000[0];
6624 } else {
6625 return util.format.apply(null, a000);
6626 }
6627}
6628
6629function viml_range(start) {
6630 var end = arguments.length >= 2 ? arguments[1] : null;
6631 if (end == null) {
6632 var x = [];
6633 for (var i = 0; i < start; ++i) {
6634 x.push(i);
6635 }
6636 return x;
6637 } else {
6638 var x = []
6639 for (var i = start; i <= end; ++i) {
6640 x.push(i);
6641 }
6642 return x;
6643 }
6644}
6645
6646function viml_readfile(path) {
6647 // FIXME: newline?
6648 return fs.readFileSync(path, 'utf-8').split(/\r\n|\r|\n/);
6649}
6650
6651function viml_remove(lst, idx) {
6652 lst.splice(idx, 1);
6653}
6654
6655function viml_split(s, sep) {
6656 if (sep == "\\zs") {
6657 return s.split("");
6658 }
6659 throw "NotImplemented";
6660}
6661
6662function viml_str2nr(s) {
6663 var base = arguments.length >= 2 ? arguments[1] : 10;
6664 return parseInt(s, base);
6665}
6666
6667function viml_string(obj) {
6668 return obj.toString();
6669}
6670
6671function viml_has_key(obj, key) {
6672 return obj[key] !== undefined;
6673}
6674
6675function viml_stridx(a, b) {
6676 return a.indexOf(b);
6677}
6678
6679var NIL = [];
6680var TRUE = 1;
6681var FALSE = 0;
6682var NODE_TOPLEVEL = 1;
6683var NODE_COMMENT = 2;
6684var NODE_EXCMD = 3;
6685var NODE_FUNCTION = 4;
6686var NODE_ENDFUNCTION = 5;
6687var NODE_DELFUNCTION = 6;
6688var NODE_RETURN = 7;
6689var NODE_EXCALL = 8;
6690var NODE_LET = 9;
6691var NODE_UNLET = 10;
6692var NODE_LOCKVAR = 11;
6693var NODE_UNLOCKVAR = 12;
6694var NODE_IF = 13;
6695var NODE_ELSEIF = 14;
6696var NODE_ELSE = 15;
6697var NODE_ENDIF = 16;
6698var NODE_WHILE = 17;
6699var NODE_ENDWHILE = 18;
6700var NODE_FOR = 19;
6701var NODE_ENDFOR = 20;
6702var NODE_CONTINUE = 21;
6703var NODE_BREAK = 22;
6704var NODE_TRY = 23;
6705var NODE_CATCH = 24;
6706var NODE_FINALLY = 25;
6707var NODE_ENDTRY = 26;
6708var NODE_THROW = 27;
6709var NODE_ECHO = 28;
6710var NODE_ECHON = 29;
6711var NODE_ECHOHL = 30;
6712var NODE_ECHOMSG = 31;
6713var NODE_ECHOERR = 32;
6714var NODE_EXECUTE = 33;
6715var NODE_TERNARY = 34;
6716var NODE_OR = 35;
6717var NODE_AND = 36;
6718var NODE_EQUAL = 37;
6719var NODE_EQUALCI = 38;
6720var NODE_EQUALCS = 39;
6721var NODE_NEQUAL = 40;
6722var NODE_NEQUALCI = 41;
6723var NODE_NEQUALCS = 42;
6724var NODE_GREATER = 43;
6725var NODE_GREATERCI = 44;
6726var NODE_GREATERCS = 45;
6727var NODE_GEQUAL = 46;
6728var NODE_GEQUALCI = 47;
6729var NODE_GEQUALCS = 48;
6730var NODE_SMALLER = 49;
6731var NODE_SMALLERCI = 50;
6732var NODE_SMALLERCS = 51;
6733var NODE_SEQUAL = 52;
6734var NODE_SEQUALCI = 53;
6735var NODE_SEQUALCS = 54;
6736var NODE_MATCH = 55;
6737var NODE_MATCHCI = 56;
6738var NODE_MATCHCS = 57;
6739var NODE_NOMATCH = 58;
6740var NODE_NOMATCHCI = 59;
6741var NODE_NOMATCHCS = 60;
6742var NODE_IS = 61;
6743var NODE_ISCI = 62;
6744var NODE_ISCS = 63;
6745var NODE_ISNOT = 64;
6746var NODE_ISNOTCI = 65;
6747var NODE_ISNOTCS = 66;
6748var NODE_ADD = 67;
6749var NODE_SUBTRACT = 68;
6750var NODE_CONCAT = 69;
6751var NODE_MULTIPLY = 70;
6752var NODE_DIVIDE = 71;
6753var NODE_REMAINDER = 72;
6754var NODE_NOT = 73;
6755var NODE_MINUS = 74;
6756var NODE_PLUS = 75;
6757var NODE_SUBSCRIPT = 76;
6758var NODE_SLICE = 77;
6759var NODE_CALL = 78;
6760var NODE_DOT = 79;
6761var NODE_NUMBER = 80;
6762var NODE_STRING = 81;
6763var NODE_LIST = 82;
6764var NODE_DICT = 83;
6765var NODE_OPTION = 85;
6766var NODE_IDENTIFIER = 86;
6767var NODE_CURLYNAME = 87;
6768var NODE_ENV = 88;
6769var NODE_REG = 89;
6770var NODE_CURLYNAMEPART = 90;
6771var NODE_CURLYNAMEEXPR = 91;
6772var NODE_LAMBDA = 92;
6773var NODE_BLOB = 93;
6774var NODE_CONST = 94;
6775var NODE_EVAL = 95;
6776var NODE_HEREDOC = 96;
6777var NODE_METHOD = 97;
6778var TOKEN_EOF = 1;
6779var TOKEN_EOL = 2;
6780var TOKEN_SPACE = 3;
6781var TOKEN_OROR = 4;
6782var TOKEN_ANDAND = 5;
6783var TOKEN_EQEQ = 6;
6784var TOKEN_EQEQCI = 7;
6785var TOKEN_EQEQCS = 8;
6786var TOKEN_NEQ = 9;
6787var TOKEN_NEQCI = 10;
6788var TOKEN_NEQCS = 11;
6789var TOKEN_GT = 12;
6790var TOKEN_GTCI = 13;
6791var TOKEN_GTCS = 14;
6792var TOKEN_GTEQ = 15;
6793var TOKEN_GTEQCI = 16;
6794var TOKEN_GTEQCS = 17;
6795var TOKEN_LT = 18;
6796var TOKEN_LTCI = 19;
6797var TOKEN_LTCS = 20;
6798var TOKEN_LTEQ = 21;
6799var TOKEN_LTEQCI = 22;
6800var TOKEN_LTEQCS = 23;
6801var TOKEN_MATCH = 24;
6802var TOKEN_MATCHCI = 25;
6803var TOKEN_MATCHCS = 26;
6804var TOKEN_NOMATCH = 27;
6805var TOKEN_NOMATCHCI = 28;
6806var TOKEN_NOMATCHCS = 29;
6807var TOKEN_IS = 30;
6808var TOKEN_ISCI = 31;
6809var TOKEN_ISCS = 32;
6810var TOKEN_ISNOT = 33;
6811var TOKEN_ISNOTCI = 34;
6812var TOKEN_ISNOTCS = 35;
6813var TOKEN_PLUS = 36;
6814var TOKEN_MINUS = 37;
6815var TOKEN_DOT = 38;
6816var TOKEN_STAR = 39;
6817var TOKEN_SLASH = 40;
6818var TOKEN_PERCENT = 41;
6819var TOKEN_NOT = 42;
6820var TOKEN_QUESTION = 43;
6821var TOKEN_COLON = 44;
6822var TOKEN_POPEN = 45;
6823var TOKEN_PCLOSE = 46;
6824var TOKEN_SQOPEN = 47;
6825var TOKEN_SQCLOSE = 48;
6826var TOKEN_COPEN = 49;
6827var TOKEN_CCLOSE = 50;
6828var TOKEN_COMMA = 51;
6829var TOKEN_NUMBER = 52;
6830var TOKEN_SQUOTE = 53;
6831var TOKEN_DQUOTE = 54;
6832var TOKEN_OPTION = 55;
6833var TOKEN_IDENTIFIER = 56;
6834var TOKEN_ENV = 57;
6835var TOKEN_REG = 58;
6836var TOKEN_EQ = 59;
6837var TOKEN_OR = 60;
6838var TOKEN_SEMICOLON = 61;
6839var TOKEN_BACKTICK = 62;
6840var TOKEN_DOTDOTDOT = 63;
6841var TOKEN_SHARP = 64;
6842var TOKEN_ARROW = 65;
6843var TOKEN_BLOB = 66;
6844var TOKEN_LITCOPEN = 67;
6845var TOKEN_DOTDOT = 68;
6846var TOKEN_HEREDOC = 69;
6847var MAX_FUNC_ARGS = 20;
6848function isalpha(c) {
6849 return viml_eqregh(c, "^[A-Za-z]$");
6850}
6851
6852function isalnum(c) {
6853 return viml_eqregh(c, "^[0-9A-Za-z]$");
6854}
6855
6856function isdigit(c) {
6857 return viml_eqregh(c, "^[0-9]$");
6858}
6859
6860function isodigit(c) {
6861 return viml_eqregh(c, "^[0-7]$");
6862}
6863
6864function isxdigit(c) {
6865 return viml_eqregh(c, "^[0-9A-Fa-f]$");
6866}
6867
6868function iswordc(c) {
6869 return viml_eqregh(c, "^[0-9A-Za-z_]$");
6870}
6871
6872function iswordc1(c) {
6873 return viml_eqregh(c, "^[A-Za-z_]$");
6874}
6875
6876function iswhite(c) {
6877 return viml_eqregh(c, "^[ \\t]$");
6878}
6879
6880function isnamec(c) {
6881 return viml_eqregh(c, "^[0-9A-Za-z_:#]$");
6882}
6883
6884function isnamec1(c) {
6885 return viml_eqregh(c, "^[A-Za-z_]$");
6886}
6887
6888function isargname(s) {
6889 return viml_eqregh(s, "^[A-Za-z_][0-9A-Za-z_]*$");
6890}
6891
6892function isvarname(s) {
6893 return viml_eqregh(s, "^[vgslabwt]:$\\|^\\([vgslabwt]:\\)\\?[A-Za-z_][0-9A-Za-z_#]*$");
6894}
6895
6896// FIXME:
6897function isidc(c) {
6898 return viml_eqregh(c, "^[0-9A-Za-z_]$");
6899}
6900
6901function isupper(c) {
6902 return viml_eqregh(c, "^[A-Z]$");
6903}
6904
6905function islower(c) {
6906 return viml_eqregh(c, "^[a-z]$");
6907}
6908
6909function ExArg() {
6910 var ea = {};
6911 ea.forceit = FALSE;
6912 ea.addr_count = 0;
6913 ea.line1 = 0;
6914 ea.line2 = 0;
6915 ea.flags = 0;
6916 ea.do_ecmd_cmd = "";
6917 ea.do_ecmd_lnum = 0;
6918 ea.append = 0;
6919 ea.usefilter = FALSE;
6920 ea.amount = 0;
6921 ea.regname = 0;
6922 ea.force_bin = 0;
6923 ea.read_edit = 0;
6924 ea.force_ff = 0;
6925 ea.force_enc = 0;
6926 ea.bad_char = 0;
6927 ea.linepos = {};
6928 ea.cmdpos = [];
6929 ea.argpos = [];
6930 ea.cmd = {};
6931 ea.modifiers = [];
6932 ea.range = [];
6933 ea.argopt = {};
6934 ea.argcmd = {};
6935 return ea;
6936}
6937
6938// struct node {
6939// int type
6940// pos pos
6941// node left
6942// node right
6943// node cond
6944// node rest
6945// node[] list
6946// node[] rlist
6947// node[] default_args
6948// node[] body
6949// string op
6950// string str
6951// int depth
6952// variant value
6953// }
6954// TOPLEVEL .body
6955// COMMENT .str
6956// EXCMD .ea .str
6957// FUNCTION .ea .body .left .rlist .default_args .attr .endfunction
6958// ENDFUNCTION .ea
6959// DELFUNCTION .ea .left
6960// RETURN .ea .left
6961// EXCALL .ea .left
6962// LET .ea .op .left .list .rest .right
6963// CONST .ea .op .left .list .rest .right
6964// UNLET .ea .list
6965// LOCKVAR .ea .depth .list
6966// UNLOCKVAR .ea .depth .list
6967// IF .ea .body .cond .elseif .else .endif
6968// ELSEIF .ea .body .cond
6969// ELSE .ea .body
6970// ENDIF .ea
6971// WHILE .ea .body .cond .endwhile
6972// ENDWHILE .ea
6973// FOR .ea .body .left .list .rest .right .endfor
6974// ENDFOR .ea
6975// CONTINUE .ea
6976// BREAK .ea
6977// TRY .ea .body .catch .finally .endtry
6978// CATCH .ea .body .pattern
6979// FINALLY .ea .body
6980// ENDTRY .ea
6981// THROW .ea .left
6982// EVAL .ea .left
6983// ECHO .ea .list
6984// ECHON .ea .list
6985// ECHOHL .ea .str
6986// ECHOMSG .ea .list
6987// ECHOERR .ea .list
6988// EXECUTE .ea .list
6989// TERNARY .cond .left .right
6990// OR .left .right
6991// AND .left .right
6992// EQUAL .left .right
6993// EQUALCI .left .right
6994// EQUALCS .left .right
6995// NEQUAL .left .right
6996// NEQUALCI .left .right
6997// NEQUALCS .left .right
6998// GREATER .left .right
6999// GREATERCI .left .right
7000// GREATERCS .left .right
7001// GEQUAL .left .right
7002// GEQUALCI .left .right
7003// GEQUALCS .left .right
7004// SMALLER .left .right
7005// SMALLERCI .left .right
7006// SMALLERCS .left .right
7007// SEQUAL .left .right
7008// SEQUALCI .left .right
7009// SEQUALCS .left .right
7010// MATCH .left .right
7011// MATCHCI .left .right
7012// MATCHCS .left .right
7013// NOMATCH .left .right
7014// NOMATCHCI .left .right
7015// NOMATCHCS .left .right
7016// IS .left .right
7017// ISCI .left .right
7018// ISCS .left .right
7019// ISNOT .left .right
7020// ISNOTCI .left .right
7021// ISNOTCS .left .right
7022// ADD .left .right
7023// SUBTRACT .left .right
7024// CONCAT .left .right
7025// MULTIPLY .left .right
7026// DIVIDE .left .right
7027// REMAINDER .left .right
7028// NOT .left
7029// MINUS .left
7030// PLUS .left
7031// SUBSCRIPT .left .right
7032// SLICE .left .rlist
7033// METHOD .left .right
7034// CALL .left .rlist
7035// DOT .left .right
7036// NUMBER .value
7037// STRING .value
7038// LIST .value
7039// DICT .value
7040// BLOB .value
7041// NESTING .left
7042// OPTION .value
7043// IDENTIFIER .value
7044// CURLYNAME .value
7045// ENV .value
7046// REG .value
7047// CURLYNAMEPART .value
7048// CURLYNAMEEXPR .value
7049// LAMBDA .rlist .left
7050// HEREDOC .rlist .op .body
7051function Node(type) {
7052 return {"type":type};
7053}
7054
7055function Err(msg, pos) {
7056 return viml_printf("vimlparser: %s: line %d col %d", msg, pos.lnum, pos.col);
7057}
7058
7059function VimLParser() { this.__init__.apply(this, arguments); }
7060VimLParser.prototype.__init__ = function() {
7061 var a000 = Array.prototype.slice.call(arguments, 0);
7062 if (viml_len(a000) > 0) {
7063 this.neovim = a000[0];
7064 }
7065 else {
7066 this.neovim = 0;
7067 }
7068 this.find_command_cache = {};
7069}
7070
7071VimLParser.prototype.push_context = function(node) {
7072 viml_insert(this.context, node);
7073}
7074
7075VimLParser.prototype.pop_context = function() {
7076 viml_remove(this.context, 0);
7077}
7078
7079VimLParser.prototype.find_context = function(type) {
7080 var i = 0;
7081 var __c3 = this.context;
7082 for (var __i3 = 0; __i3 < __c3.length; ++__i3) {
7083 var node = __c3[__i3];
7084 if (node.type == type) {
7085 return i;
7086 }
7087 i += 1;
7088 }
7089 return -1;
7090}
7091
7092VimLParser.prototype.add_node = function(node) {
7093 viml_add(this.context[0].body, node);
7094}
7095
7096VimLParser.prototype.check_missing_endfunction = function(ends, pos) {
7097 if (this.context[0].type == NODE_FUNCTION) {
7098 throw Err(viml_printf("E126: Missing :endfunction: %s", ends), pos);
7099 }
7100}
7101
7102VimLParser.prototype.check_missing_endif = function(ends, pos) {
7103 if (this.context[0].type == NODE_IF || this.context[0].type == NODE_ELSEIF || this.context[0].type == NODE_ELSE) {
7104 throw Err(viml_printf("E171: Missing :endif: %s", ends), pos);
7105 }
7106}
7107
7108VimLParser.prototype.check_missing_endtry = function(ends, pos) {
7109 if (this.context[0].type == NODE_TRY || this.context[0].type == NODE_CATCH || this.context[0].type == NODE_FINALLY) {
7110 throw Err(viml_printf("E600: Missing :endtry: %s", ends), pos);
7111 }
7112}
7113
7114VimLParser.prototype.check_missing_endwhile = function(ends, pos) {
7115 if (this.context[0].type == NODE_WHILE) {
7116 throw Err(viml_printf("E170: Missing :endwhile: %s", ends), pos);
7117 }
7118}
7119
7120VimLParser.prototype.check_missing_endfor = function(ends, pos) {
7121 if (this.context[0].type == NODE_FOR) {
7122 throw Err(viml_printf("E170: Missing :endfor: %s", ends), pos);
7123 }
7124}
7125
7126VimLParser.prototype.parse = function(reader) {
7127 this.reader = reader;
7128 this.context = [];
7129 var toplevel = Node(NODE_TOPLEVEL);
7130 toplevel.pos = this.reader.getpos();
7131 toplevel.body = [];
7132 this.push_context(toplevel);
7133 while (this.reader.peek() != "<EOF>") {
7134 this.parse_one_cmd();
7135 }
7136 this.check_missing_endfunction("TOPLEVEL", this.reader.getpos());
7137 this.check_missing_endif("TOPLEVEL", this.reader.getpos());
7138 this.check_missing_endtry("TOPLEVEL", this.reader.getpos());
7139 this.check_missing_endwhile("TOPLEVEL", this.reader.getpos());
7140 this.check_missing_endfor("TOPLEVEL", this.reader.getpos());
7141 this.pop_context();
7142 return toplevel;
7143}
7144
7145VimLParser.prototype.parse_one_cmd = function() {
7146 this.ea = ExArg();
7147 if (this.reader.peekn(2) == "#!") {
7148 this.parse_hashbang();
7149 this.reader.get();
7150 return;
7151 }
7152 this.reader.skip_white_and_colon();
7153 if (this.reader.peekn(1) == "") {
7154 this.reader.get();
7155 return;
7156 }
7157 if (this.reader.peekn(1) == "\"") {
7158 this.parse_comment();
7159 this.reader.get();
7160 return;
7161 }
7162 this.ea.linepos = this.reader.getpos();
7163 this.parse_command_modifiers();
7164 this.parse_range();
7165 this.parse_command();
7166 this.parse_trail();
7167}
7168
7169// FIXME:
7170VimLParser.prototype.parse_command_modifiers = function() {
7171 var modifiers = [];
7172 while (TRUE) {
7173 var pos = this.reader.tell();
7174 var d = "";
7175 if (isdigit(this.reader.peekn(1))) {
7176 var d = this.reader.read_digit();
7177 this.reader.skip_white();
7178 }
7179 var k = this.reader.read_alpha();
7180 var c = this.reader.peekn(1);
7181 this.reader.skip_white();
7182 if (viml_stridx("aboveleft", k) == 0 && viml_len(k) >= 3) {
7183 // abo\%[veleft]
7184 viml_add(modifiers, {"name":"aboveleft"});
7185 }
7186 else if (viml_stridx("belowright", k) == 0 && viml_len(k) >= 3) {
7187 // bel\%[owright]
7188 viml_add(modifiers, {"name":"belowright"});
7189 }
7190 else if (viml_stridx("browse", k) == 0 && viml_len(k) >= 3) {
7191 // bro\%[wse]
7192 viml_add(modifiers, {"name":"browse"});
7193 }
7194 else if (viml_stridx("botright", k) == 0 && viml_len(k) >= 2) {
7195 // bo\%[tright]
7196 viml_add(modifiers, {"name":"botright"});
7197 }
7198 else if (viml_stridx("confirm", k) == 0 && viml_len(k) >= 4) {
7199 // conf\%[irm]
7200 viml_add(modifiers, {"name":"confirm"});
7201 }
7202 else if (viml_stridx("keepmarks", k) == 0 && viml_len(k) >= 3) {
7203 // kee\%[pmarks]
7204 viml_add(modifiers, {"name":"keepmarks"});
7205 }
7206 else if (viml_stridx("keepalt", k) == 0 && viml_len(k) >= 5) {
7207 // keepa\%[lt]
7208 viml_add(modifiers, {"name":"keepalt"});
7209 }
7210 else if (viml_stridx("keepjumps", k) == 0 && viml_len(k) >= 5) {
7211 // keepj\%[umps]
7212 viml_add(modifiers, {"name":"keepjumps"});
7213 }
7214 else if (viml_stridx("keeppatterns", k) == 0 && viml_len(k) >= 5) {
7215 // keepp\%[atterns]
7216 viml_add(modifiers, {"name":"keeppatterns"});
7217 }
7218 else if (viml_stridx("hide", k) == 0 && viml_len(k) >= 3) {
7219 // hid\%[e]
7220 if (this.ends_excmds(c)) {
7221 break;
7222 }
7223 viml_add(modifiers, {"name":"hide"});
7224 }
7225 else if (viml_stridx("lockmarks", k) == 0 && viml_len(k) >= 3) {
7226 // loc\%[kmarks]
7227 viml_add(modifiers, {"name":"lockmarks"});
7228 }
7229 else if (viml_stridx("leftabove", k) == 0 && viml_len(k) >= 5) {
7230 // lefta\%[bove]
7231 viml_add(modifiers, {"name":"leftabove"});
7232 }
7233 else if (viml_stridx("noautocmd", k) == 0 && viml_len(k) >= 3) {
7234 // noa\%[utocmd]
7235 viml_add(modifiers, {"name":"noautocmd"});
7236 }
7237 else if (viml_stridx("noswapfile", k) == 0 && viml_len(k) >= 3) {
7238 // :nos\%[wapfile]
7239 viml_add(modifiers, {"name":"noswapfile"});
7240 }
7241 else if (viml_stridx("rightbelow", k) == 0 && viml_len(k) >= 6) {
7242 // rightb\%[elow]
7243 viml_add(modifiers, {"name":"rightbelow"});
7244 }
7245 else if (viml_stridx("sandbox", k) == 0 && viml_len(k) >= 3) {
7246 // san\%[dbox]
7247 viml_add(modifiers, {"name":"sandbox"});
7248 }
7249 else if (viml_stridx("silent", k) == 0 && viml_len(k) >= 3) {
7250 // sil\%[ent]
7251 if (c == "!") {
7252 this.reader.get();
7253 viml_add(modifiers, {"name":"silent", "bang":1});
7254 }
7255 else {
7256 viml_add(modifiers, {"name":"silent", "bang":0});
7257 }
7258 }
7259 else if (k == "tab") {
7260 // tab
7261 if (d != "") {
7262 viml_add(modifiers, {"name":"tab", "count":viml_str2nr(d, 10)});
7263 }
7264 else {
7265 viml_add(modifiers, {"name":"tab"});
7266 }
7267 }
7268 else if (viml_stridx("topleft", k) == 0 && viml_len(k) >= 2) {
7269 // to\%[pleft]
7270 viml_add(modifiers, {"name":"topleft"});
7271 }
7272 else if (viml_stridx("unsilent", k) == 0 && viml_len(k) >= 3) {
7273 // uns\%[ilent]
7274 viml_add(modifiers, {"name":"unsilent"});
7275 }
7276 else if (viml_stridx("vertical", k) == 0 && viml_len(k) >= 4) {
7277 // vert\%[ical]
7278 viml_add(modifiers, {"name":"vertical"});
7279 }
7280 else if (viml_stridx("verbose", k) == 0 && viml_len(k) >= 4) {
7281 // verb\%[ose]
7282 if (d != "") {
7283 viml_add(modifiers, {"name":"verbose", "count":viml_str2nr(d, 10)});
7284 }
7285 else {
7286 viml_add(modifiers, {"name":"verbose", "count":1});
7287 }
7288 }
7289 else {
7290 this.reader.seek_set(pos);
7291 break;
7292 }
7293 }
7294 this.ea.modifiers = modifiers;
7295}
7296
7297// FIXME:
7298VimLParser.prototype.parse_range = function() {
7299 var tokens = [];
7300 while (TRUE) {
7301 while (TRUE) {
7302 this.reader.skip_white();
7303 var c = this.reader.peekn(1);
7304 if (c == "") {
7305 break;
7306 }
7307 if (c == ".") {
7308 viml_add(tokens, this.reader.getn(1));
7309 }
7310 else if (c == "$") {
7311 viml_add(tokens, this.reader.getn(1));
7312 }
7313 else if (c == "'") {
7314 this.reader.getn(1);
7315 var m = this.reader.getn(1);
7316 if (m == "") {
7317 break;
7318 }
7319 viml_add(tokens, "'" + m);
7320 }
7321 else if (c == "/") {
7322 this.reader.getn(1);
7323 var __tmp = this.parse_pattern(c);
7324 var pattern = __tmp[0];
7325 var _ = __tmp[1];
7326 viml_add(tokens, pattern);
7327 }
7328 else if (c == "?") {
7329 this.reader.getn(1);
7330 var __tmp = this.parse_pattern(c);
7331 var pattern = __tmp[0];
7332 var _ = __tmp[1];
7333 viml_add(tokens, pattern);
7334 }
7335 else if (c == "\\") {
7336 var m = this.reader.p(1);
7337 if (m == "&" || m == "?" || m == "/") {
7338 this.reader.seek_cur(2);
7339 viml_add(tokens, "\\" + m);
7340 }
7341 else {
7342 throw Err("E10: \\\\ should be followed by /, ? or &", this.reader.getpos());
7343 }
7344 }
7345 else if (isdigit(c)) {
7346 viml_add(tokens, this.reader.read_digit());
7347 }
7348 while (TRUE) {
7349 this.reader.skip_white();
7350 if (this.reader.peekn(1) == "") {
7351 break;
7352 }
7353 var n = this.reader.read_integer();
7354 if (n == "") {
7355 break;
7356 }
7357 viml_add(tokens, n);
7358 }
7359 if (this.reader.p(0) != "/" && this.reader.p(0) != "?") {
7360 break;
7361 }
7362 }
7363 if (this.reader.peekn(1) == "%") {
7364 viml_add(tokens, this.reader.getn(1));
7365 }
7366 else if (this.reader.peekn(1) == "*") {
7367 // && &cpoptions !~ '\*'
7368 viml_add(tokens, this.reader.getn(1));
7369 }
7370 if (this.reader.peekn(1) == ";") {
7371 viml_add(tokens, this.reader.getn(1));
7372 continue;
7373 }
7374 else if (this.reader.peekn(1) == ",") {
7375 viml_add(tokens, this.reader.getn(1));
7376 continue;
7377 }
7378 break;
7379 }
7380 this.ea.range = tokens;
7381}
7382
7383// FIXME:
7384VimLParser.prototype.parse_pattern = function(delimiter) {
7385 var pattern = "";
7386 var endc = "";
7387 var inbracket = 0;
7388 while (TRUE) {
7389 var c = this.reader.getn(1);
7390 if (c == "") {
7391 break;
7392 }
7393 if (c == delimiter && inbracket == 0) {
7394 var endc = c;
7395 break;
7396 }
7397 pattern += c;
7398 if (c == "\\") {
7399 var c = this.reader.peekn(1);
7400 if (c == "") {
7401 throw Err("E682: Invalid search pattern or delimiter", this.reader.getpos());
7402 }
7403 this.reader.getn(1);
7404 pattern += c;
7405 }
7406 else if (c == "[") {
7407 inbracket += 1;
7408 }
7409 else if (c == "]") {
7410 inbracket -= 1;
7411 }
7412 }
7413 return [pattern, endc];
7414}
7415
7416VimLParser.prototype.parse_command = function() {
7417 this.reader.skip_white_and_colon();
7418 this.ea.cmdpos = this.reader.getpos();
7419 if (this.reader.peekn(1) == "" || this.reader.peekn(1) == "\"") {
7420 if (!viml_empty(this.ea.modifiers) || !viml_empty(this.ea.range)) {
7421 this.parse_cmd_modifier_range();
7422 }
7423 return;
7424 }
7425 this.ea.cmd = this.find_command();
7426 if (this.ea.cmd === NIL) {
7427 this.reader.setpos(this.ea.cmdpos);
7428 throw Err(viml_printf("E492: Not an editor command: %s", this.reader.peekline()), this.ea.cmdpos);
7429 }
7430 if (this.reader.peekn(1) == "!" && this.ea.cmd.name != "substitute" && this.ea.cmd.name != "smagic" && this.ea.cmd.name != "snomagic") {
7431 this.reader.getn(1);
7432 this.ea.forceit = TRUE;
7433 }
7434 else {
7435 this.ea.forceit = FALSE;
7436 }
7437 if (!viml_eqregh(this.ea.cmd.flags, "\\<BANG\\>") && this.ea.forceit && !viml_eqregh(this.ea.cmd.flags, "\\<USERCMD\\>")) {
7438 throw Err("E477: No ! allowed", this.ea.cmdpos);
7439 }
7440 if (this.ea.cmd.name != "!") {
7441 this.reader.skip_white();
7442 }
7443 this.ea.argpos = this.reader.getpos();
7444 if (viml_eqregh(this.ea.cmd.flags, "\\<ARGOPT\\>")) {
7445 this.parse_argopt();
7446 }
7447 if (this.ea.cmd.name == "write" || this.ea.cmd.name == "update") {
7448 if (this.reader.p(0) == ">") {
7449 if (this.reader.p(1) != ">") {
7450 throw Err("E494: Use w or w>>", this.ea.cmdpos);
7451 }
7452 this.reader.seek_cur(2);
7453 this.reader.skip_white();
7454 this.ea.append = 1;
7455 }
7456 else if (this.reader.peekn(1) == "!" && this.ea.cmd.name == "write") {
7457 this.reader.getn(1);
7458 this.ea.usefilter = TRUE;
7459 }
7460 }
7461 if (this.ea.cmd.name == "read") {
7462 if (this.ea.forceit) {
7463 this.ea.usefilter = TRUE;
7464 this.ea.forceit = FALSE;
7465 }
7466 else if (this.reader.peekn(1) == "!") {
7467 this.reader.getn(1);
7468 this.ea.usefilter = TRUE;
7469 }
7470 }
7471 if (this.ea.cmd.name == "<" || this.ea.cmd.name == ">") {
7472 this.ea.amount = 1;
7473 while (this.reader.peekn(1) == this.ea.cmd.name) {
7474 this.reader.getn(1);
7475 this.ea.amount += 1;
7476 }
7477 this.reader.skip_white();
7478 }
7479 if (viml_eqregh(this.ea.cmd.flags, "\\<EDITCMD\\>") && !this.ea.usefilter) {
7480 this.parse_argcmd();
7481 }
7482 this._parse_command(this.ea.cmd.parser);
7483}
7484
7485// TODO: self[a:parser]
7486VimLParser.prototype._parse_command = function(parser) {
7487 if (parser == "parse_cmd_append") {
7488 this.parse_cmd_append();
7489 }
7490 else if (parser == "parse_cmd_break") {
7491 this.parse_cmd_break();
7492 }
7493 else if (parser == "parse_cmd_call") {
7494 this.parse_cmd_call();
7495 }
7496 else if (parser == "parse_cmd_catch") {
7497 this.parse_cmd_catch();
7498 }
7499 else if (parser == "parse_cmd_common") {
7500 this.parse_cmd_common();
7501 }
7502 else if (parser == "parse_cmd_continue") {
7503 this.parse_cmd_continue();
7504 }
7505 else if (parser == "parse_cmd_delfunction") {
7506 this.parse_cmd_delfunction();
7507 }
7508 else if (parser == "parse_cmd_echo") {
7509 this.parse_cmd_echo();
7510 }
7511 else if (parser == "parse_cmd_echoerr") {
7512 this.parse_cmd_echoerr();
7513 }
7514 else if (parser == "parse_cmd_echohl") {
7515 this.parse_cmd_echohl();
7516 }
7517 else if (parser == "parse_cmd_echomsg") {
7518 this.parse_cmd_echomsg();
7519 }
7520 else if (parser == "parse_cmd_echon") {
7521 this.parse_cmd_echon();
7522 }
7523 else if (parser == "parse_cmd_else") {
7524 this.parse_cmd_else();
7525 }
7526 else if (parser == "parse_cmd_elseif") {
7527 this.parse_cmd_elseif();
7528 }
7529 else if (parser == "parse_cmd_endfor") {
7530 this.parse_cmd_endfor();
7531 }
7532 else if (parser == "parse_cmd_endfunction") {
7533 this.parse_cmd_endfunction();
7534 }
7535 else if (parser == "parse_cmd_endif") {
7536 this.parse_cmd_endif();
7537 }
7538 else if (parser == "parse_cmd_endtry") {
7539 this.parse_cmd_endtry();
7540 }
7541 else if (parser == "parse_cmd_endwhile") {
7542 this.parse_cmd_endwhile();
7543 }
7544 else if (parser == "parse_cmd_execute") {
7545 this.parse_cmd_execute();
7546 }
7547 else if (parser == "parse_cmd_finally") {
7548 this.parse_cmd_finally();
7549 }
7550 else if (parser == "parse_cmd_finish") {
7551 this.parse_cmd_finish();
7552 }
7553 else if (parser == "parse_cmd_for") {
7554 this.parse_cmd_for();
7555 }
7556 else if (parser == "parse_cmd_function") {
7557 this.parse_cmd_function();
7558 }
7559 else if (parser == "parse_cmd_if") {
7560 this.parse_cmd_if();
7561 }
7562 else if (parser == "parse_cmd_insert") {
7563 this.parse_cmd_insert();
7564 }
7565 else if (parser == "parse_cmd_let") {
7566 this.parse_cmd_let();
7567 }
7568 else if (parser == "parse_cmd_const") {
7569 this.parse_cmd_const();
7570 }
7571 else if (parser == "parse_cmd_loadkeymap") {
7572 this.parse_cmd_loadkeymap();
7573 }
7574 else if (parser == "parse_cmd_lockvar") {
7575 this.parse_cmd_lockvar();
7576 }
7577 else if (parser == "parse_cmd_lua") {
7578 this.parse_cmd_lua();
7579 }
7580 else if (parser == "parse_cmd_modifier_range") {
7581 this.parse_cmd_modifier_range();
7582 }
7583 else if (parser == "parse_cmd_mzscheme") {
7584 this.parse_cmd_mzscheme();
7585 }
7586 else if (parser == "parse_cmd_perl") {
7587 this.parse_cmd_perl();
7588 }
7589 else if (parser == "parse_cmd_python") {
7590 this.parse_cmd_python();
7591 }
7592 else if (parser == "parse_cmd_python3") {
7593 this.parse_cmd_python3();
7594 }
7595 else if (parser == "parse_cmd_return") {
7596 this.parse_cmd_return();
7597 }
7598 else if (parser == "parse_cmd_ruby") {
7599 this.parse_cmd_ruby();
7600 }
7601 else if (parser == "parse_cmd_tcl") {
7602 this.parse_cmd_tcl();
7603 }
7604 else if (parser == "parse_cmd_throw") {
7605 this.parse_cmd_throw();
7606 }
7607 else if (parser == "parse_cmd_eval") {
7608 this.parse_cmd_eval();
7609 }
7610 else if (parser == "parse_cmd_try") {
7611 this.parse_cmd_try();
7612 }
7613 else if (parser == "parse_cmd_unlet") {
7614 this.parse_cmd_unlet();
7615 }
7616 else if (parser == "parse_cmd_unlockvar") {
7617 this.parse_cmd_unlockvar();
7618 }
7619 else if (parser == "parse_cmd_usercmd") {
7620 this.parse_cmd_usercmd();
7621 }
7622 else if (parser == "parse_cmd_while") {
7623 this.parse_cmd_while();
7624 }
7625 else if (parser == "parse_wincmd") {
7626 this.parse_wincmd();
7627 }
7628 else if (parser == "parse_cmd_syntax") {
7629 this.parse_cmd_syntax();
7630 }
7631 else {
7632 throw viml_printf("unknown parser: %s", viml_string(parser));
7633 }
7634}
7635
7636VimLParser.prototype.find_command = function() {
7637 var c = this.reader.peekn(1);
7638 var name = "";
7639 if (c == "k") {
7640 this.reader.getn(1);
7641 var name = "k";
7642 }
7643 else if (c == "s" && viml_eqregh(this.reader.peekn(5), "\\v^s%(c[^sr][^i][^p]|g|i[^mlg]|I|r[^e])")) {
7644 this.reader.getn(1);
7645 var name = "substitute";
7646 }
7647 else if (viml_eqregh(c, "[@*!=><&~#]")) {
7648 this.reader.getn(1);
7649 var name = c;
7650 }
7651 else if (this.reader.peekn(2) == "py") {
7652 var name = this.reader.read_alnum();
7653 }
7654 else {
7655 var pos = this.reader.tell();
7656 var name = this.reader.read_alpha();
7657 if (name != "del" && viml_eqregh(name, "\\v^d%[elete][lp]$")) {
7658 this.reader.seek_set(pos);
7659 var name = this.reader.getn(viml_len(name) - 1);
7660 }
7661 }
7662 if (name == "") {
7663 return NIL;
7664 }
7665 if (viml_has_key(this.find_command_cache, name)) {
7666 return this.find_command_cache[name];
7667 }
7668 var cmd = NIL;
7669 var __c4 = this.builtin_commands;
7670 for (var __i4 = 0; __i4 < __c4.length; ++__i4) {
7671 var x = __c4[__i4];
7672 if (viml_stridx(x.name, name) == 0 && viml_len(name) >= x.minlen) {
7673 delete cmd;
7674 var cmd = x;
7675 break;
7676 }
7677 }
7678 if (this.neovim) {
7679 var __c5 = this.neovim_additional_commands;
7680 for (var __i5 = 0; __i5 < __c5.length; ++__i5) {
7681 var x = __c5[__i5];
7682 if (viml_stridx(x.name, name) == 0 && viml_len(name) >= x.minlen) {
7683 delete cmd;
7684 var cmd = x;
7685 break;
7686 }
7687 }
7688 var __c6 = this.neovim_removed_commands;
7689 for (var __i6 = 0; __i6 < __c6.length; ++__i6) {
7690 var x = __c6[__i6];
7691 if (viml_stridx(x.name, name) == 0 && viml_len(name) >= x.minlen) {
7692 delete cmd;
7693 var cmd = NIL;
7694 break;
7695 }
7696 }
7697 }
7698 // FIXME: user defined command
7699 if ((cmd === NIL || cmd.name == "Print") && viml_eqregh(name, "^[A-Z]")) {
7700 name += this.reader.read_alnum();
7701 delete cmd;
7702 var cmd = {"name":name, "flags":"USERCMD", "parser":"parse_cmd_usercmd"};
7703 }
7704 this.find_command_cache[name] = cmd;
7705 return cmd;
7706}
7707
7708// TODO:
7709VimLParser.prototype.parse_hashbang = function() {
7710 this.reader.getn(-1);
7711}
7712
7713// TODO:
7714// ++opt=val
7715VimLParser.prototype.parse_argopt = function() {
7716 while (this.reader.p(0) == "+" && this.reader.p(1) == "+") {
7717 var s = this.reader.peekn(20);
7718 if (viml_eqregh(s, "^++bin\\>")) {
7719 this.reader.getn(5);
7720 this.ea.force_bin = 1;
7721 }
7722 else if (viml_eqregh(s, "^++nobin\\>")) {
7723 this.reader.getn(7);
7724 this.ea.force_bin = 2;
7725 }
7726 else if (viml_eqregh(s, "^++edit\\>")) {
7727 this.reader.getn(6);
7728 this.ea.read_edit = 1;
7729 }
7730 else if (viml_eqregh(s, "^++ff=\\(dos\\|unix\\|mac\\)\\>")) {
7731 this.reader.getn(5);
7732 this.ea.force_ff = this.reader.read_alpha();
7733 }
7734 else if (viml_eqregh(s, "^++fileformat=\\(dos\\|unix\\|mac\\)\\>")) {
7735 this.reader.getn(13);
7736 this.ea.force_ff = this.reader.read_alpha();
7737 }
7738 else if (viml_eqregh(s, "^++enc=\\S")) {
7739 this.reader.getn(6);
7740 this.ea.force_enc = this.reader.read_nonwhite();
7741 }
7742 else if (viml_eqregh(s, "^++encoding=\\S")) {
7743 this.reader.getn(11);
7744 this.ea.force_enc = this.reader.read_nonwhite();
7745 }
7746 else if (viml_eqregh(s, "^++bad=\\(keep\\|drop\\|.\\)\\>")) {
7747 this.reader.getn(6);
7748 if (viml_eqregh(s, "^++bad=keep")) {
7749 this.ea.bad_char = this.reader.getn(4);
7750 }
7751 else if (viml_eqregh(s, "^++bad=drop")) {
7752 this.ea.bad_char = this.reader.getn(4);
7753 }
7754 else {
7755 this.ea.bad_char = this.reader.getn(1);
7756 }
7757 }
7758 else if (viml_eqregh(s, "^++")) {
7759 throw Err("E474: Invalid Argument", this.reader.getpos());
7760 }
7761 else {
7762 break;
7763 }
7764 this.reader.skip_white();
7765 }
7766}
7767
7768// TODO:
7769// +command
7770VimLParser.prototype.parse_argcmd = function() {
7771 if (this.reader.peekn(1) == "+") {
7772 this.reader.getn(1);
7773 if (this.reader.peekn(1) == " ") {
7774 this.ea.do_ecmd_cmd = "$";
7775 }
7776 else {
7777 this.ea.do_ecmd_cmd = this.read_cmdarg();
7778 }
7779 }
7780}
7781
7782VimLParser.prototype.read_cmdarg = function() {
7783 var r = "";
7784 while (TRUE) {
7785 var c = this.reader.peekn(1);
7786 if (c == "" || iswhite(c)) {
7787 break;
7788 }
7789 this.reader.getn(1);
7790 if (c == "\\") {
7791 var c = this.reader.getn(1);
7792 }
7793 r += c;
7794 }
7795 return r;
7796}
7797
7798VimLParser.prototype.parse_comment = function() {
7799 var npos = this.reader.getpos();
7800 var c = this.reader.get();
7801 if (c != "\"") {
7802 throw Err(viml_printf("unexpected character: %s", c), npos);
7803 }
7804 var node = Node(NODE_COMMENT);
7805 node.pos = npos;
7806 node.str = this.reader.getn(-1);
7807 this.add_node(node);
7808}
7809
7810VimLParser.prototype.parse_trail = function() {
7811 this.reader.skip_white();
7812 var c = this.reader.peek();
7813 if (c == "<EOF>") {
7814 // pass
7815 }
7816 else if (c == "<EOL>") {
7817 this.reader.get();
7818 }
7819 else if (c == "|") {
7820 this.reader.get();
7821 }
7822 else if (c == "\"") {
7823 this.parse_comment();
7824 this.reader.get();
7825 }
7826 else {
7827 throw Err(viml_printf("E488: Trailing characters: %s", c), this.reader.getpos());
7828 }
7829}
7830
7831// modifier or range only command line
7832VimLParser.prototype.parse_cmd_modifier_range = function() {
7833 var node = Node(NODE_EXCMD);
7834 node.pos = this.ea.cmdpos;
7835 node.ea = this.ea;
7836 node.str = this.reader.getstr(this.ea.linepos, this.reader.getpos());
7837 this.add_node(node);
7838}
7839
7840// TODO:
7841VimLParser.prototype.parse_cmd_common = function() {
7842 var end = this.reader.getpos();
7843 if (viml_eqregh(this.ea.cmd.flags, "\\<TRLBAR\\>") && !this.ea.usefilter) {
7844 var end = this.separate_nextcmd();
7845 }
7846 else if (this.ea.cmd.name == "!" || this.ea.cmd.name == "global" || this.ea.cmd.name == "vglobal" || this.ea.usefilter) {
7847 while (TRUE) {
7848 var end = this.reader.getpos();
7849 if (this.reader.getn(1) == "") {
7850 break;
7851 }
7852 }
7853 }
7854 else {
7855 while (TRUE) {
7856 var end = this.reader.getpos();
7857 if (this.reader.getn(1) == "") {
7858 break;
7859 }
7860 }
7861 }
7862 var node = Node(NODE_EXCMD);
7863 node.pos = this.ea.cmdpos;
7864 node.ea = this.ea;
7865 node.str = this.reader.getstr(this.ea.linepos, end);
7866 this.add_node(node);
7867}
7868
7869VimLParser.prototype.separate_nextcmd = function() {
7870 if (this.ea.cmd.name == "vimgrep" || this.ea.cmd.name == "vimgrepadd" || this.ea.cmd.name == "lvimgrep" || this.ea.cmd.name == "lvimgrepadd") {
7871 this.skip_vimgrep_pat();
7872 }
7873 var pc = "";
7874 var end = this.reader.getpos();
7875 var nospend = end;
7876 while (TRUE) {
7877 var end = this.reader.getpos();
7878 if (!iswhite(pc)) {
7879 var nospend = end;
7880 }
7881 var c = this.reader.peek();
7882 if (c == "<EOF>" || c == "<EOL>") {
7883 break;
7884 }
7885 else if (c == "\x16") {
7886 // <C-V>
7887 this.reader.get();
7888 var end = this.reader.getpos();
7889 var nospend = this.reader.getpos();
7890 var c = this.reader.peek();
7891 if (c == "<EOF>" || c == "<EOL>") {
7892 break;
7893 }
7894 this.reader.get();
7895 }
7896 else if (this.reader.peekn(2) == "`=" && viml_eqregh(this.ea.cmd.flags, "\\<\\(XFILE\\|FILES\\|FILE1\\)\\>")) {
7897 this.reader.getn(2);
7898 this.parse_expr();
7899 var c = this.reader.peekn(1);
7900 if (c != "`") {
7901 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
7902 }
7903 this.reader.getn(1);
7904 }
7905 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 != "@")) {
7906 var has_cpo_bar = FALSE;
7907 // &cpoptions =~ 'b'
7908 if ((!has_cpo_bar || !viml_eqregh(this.ea.cmd.flags, "\\<USECTRLV\\>")) && pc == "\\") {
7909 this.reader.get();
7910 }
7911 else {
7912 break;
7913 }
7914 }
7915 else {
7916 this.reader.get();
7917 }
7918 var pc = c;
7919 }
7920 if (!viml_eqregh(this.ea.cmd.flags, "\\<NOTRLCOM\\>")) {
7921 var end = nospend;
7922 }
7923 return end;
7924}
7925
7926// FIXME
7927VimLParser.prototype.skip_vimgrep_pat = function() {
7928 if (this.reader.peekn(1) == "") {
7929 // pass
7930 }
7931 else if (isidc(this.reader.peekn(1))) {
7932 // :vimgrep pattern fname
7933 this.reader.read_nonwhite();
7934 }
7935 else {
7936 // :vimgrep /pattern/[g][j] fname
7937 var c = this.reader.getn(1);
7938 var __tmp = this.parse_pattern(c);
7939 var _ = __tmp[0];
7940 var endc = __tmp[1];
7941 if (c != endc) {
7942 return;
7943 }
7944 while (this.reader.p(0) == "g" || this.reader.p(0) == "j") {
7945 this.reader.getn(1);
7946 }
7947 }
7948}
7949
7950VimLParser.prototype.parse_cmd_append = function() {
7951 this.reader.setpos(this.ea.linepos);
7952 var cmdline = this.reader.readline();
7953 var lines = [cmdline];
7954 var m = ".";
7955 while (TRUE) {
7956 if (this.reader.peek() == "<EOF>") {
7957 break;
7958 }
7959 var line = this.reader.getn(-1);
7960 viml_add(lines, line);
7961 if (line == m) {
7962 break;
7963 }
7964 this.reader.get();
7965 }
7966 var node = Node(NODE_EXCMD);
7967 node.pos = this.ea.cmdpos;
7968 node.ea = this.ea;
7969 node.str = viml_join(lines, "\n");
7970 this.add_node(node);
7971}
7972
7973VimLParser.prototype.parse_cmd_insert = function() {
7974 this.parse_cmd_append();
7975}
7976
7977VimLParser.prototype.parse_cmd_loadkeymap = function() {
7978 this.reader.setpos(this.ea.linepos);
7979 var cmdline = this.reader.readline();
7980 var lines = [cmdline];
7981 while (TRUE) {
7982 if (this.reader.peek() == "<EOF>") {
7983 break;
7984 }
7985 var line = this.reader.readline();
7986 viml_add(lines, line);
7987 }
7988 var node = Node(NODE_EXCMD);
7989 node.pos = this.ea.cmdpos;
7990 node.ea = this.ea;
7991 node.str = viml_join(lines, "\n");
7992 this.add_node(node);
7993}
7994
7995VimLParser.prototype.parse_cmd_lua = function() {
7996 var lines = [];
7997 this.reader.skip_white();
7998 if (this.reader.peekn(2) == "<<") {
7999 this.reader.getn(2);
8000 this.reader.skip_white();
8001 var m = this.reader.readline();
8002 if (m == "") {
8003 var m = ".";
8004 }
8005 this.reader.setpos(this.ea.linepos);
8006 var cmdline = this.reader.getn(-1);
8007 var lines = [cmdline];
8008 this.reader.get();
8009 while (TRUE) {
8010 if (this.reader.peek() == "<EOF>") {
8011 break;
8012 }
8013 var line = this.reader.getn(-1);
8014 viml_add(lines, line);
8015 if (line == m) {
8016 break;
8017 }
8018 this.reader.get();
8019 }
8020 }
8021 else {
8022 this.reader.setpos(this.ea.linepos);
8023 var cmdline = this.reader.getn(-1);
8024 var lines = [cmdline];
8025 }
8026 var node = Node(NODE_EXCMD);
8027 node.pos = this.ea.cmdpos;
8028 node.ea = this.ea;
8029 node.str = viml_join(lines, "\n");
8030 this.add_node(node);
8031}
8032
8033VimLParser.prototype.parse_cmd_mzscheme = function() {
8034 this.parse_cmd_lua();
8035}
8036
8037VimLParser.prototype.parse_cmd_perl = function() {
8038 this.parse_cmd_lua();
8039}
8040
8041VimLParser.prototype.parse_cmd_python = function() {
8042 this.parse_cmd_lua();
8043}
8044
8045VimLParser.prototype.parse_cmd_python3 = function() {
8046 this.parse_cmd_lua();
8047}
8048
8049VimLParser.prototype.parse_cmd_ruby = function() {
8050 this.parse_cmd_lua();
8051}
8052
8053VimLParser.prototype.parse_cmd_tcl = function() {
8054 this.parse_cmd_lua();
8055}
8056
8057VimLParser.prototype.parse_cmd_finish = function() {
8058 this.parse_cmd_common();
8059 if (this.context[0].type == NODE_TOPLEVEL) {
8060 this.reader.seek_end(0);
8061 }
8062}
8063
8064// FIXME
8065VimLParser.prototype.parse_cmd_usercmd = function() {
8066 this.parse_cmd_common();
8067}
8068
8069VimLParser.prototype.parse_cmd_function = function() {
8070 var pos = this.reader.tell();
8071 this.reader.skip_white();
8072 // :function
8073 if (this.ends_excmds(this.reader.peek())) {
8074 this.reader.seek_set(pos);
8075 this.parse_cmd_common();
8076 return;
8077 }
8078 // :function /pattern
8079 if (this.reader.peekn(1) == "/") {
8080 this.reader.seek_set(pos);
8081 this.parse_cmd_common();
8082 return;
8083 }
8084 var left = this.parse_lvalue_func();
8085 this.reader.skip_white();
8086 if (left.type == NODE_IDENTIFIER) {
8087 var s = left.value;
8088 var ss = viml_split(s, "\\zs");
8089 if (ss[0] != "<" && ss[0] != "_" && !isupper(ss[0]) && viml_stridx(s, ":") == -1 && viml_stridx(s, "#") == -1) {
8090 throw Err(viml_printf("E128: Function name must start with a capital or contain a colon: %s", s), left.pos);
8091 }
8092 }
8093 // :function {name}
8094 if (this.reader.peekn(1) != "(") {
8095 this.reader.seek_set(pos);
8096 this.parse_cmd_common();
8097 return;
8098 }
8099 // :function[!] {name}([arguments]) [range] [abort] [dict] [closure]
8100 var node = Node(NODE_FUNCTION);
8101 node.pos = this.ea.cmdpos;
8102 node.body = [];
8103 node.ea = this.ea;
8104 node.left = left;
8105 node.rlist = [];
8106 node.default_args = [];
8107 node.attr = {"range":0, "abort":0, "dict":0, "closure":0};
8108 node.endfunction = NIL;
8109 this.reader.getn(1);
8110 var tokenizer = new ExprTokenizer(this.reader);
8111 if (tokenizer.peek().type == TOKEN_PCLOSE) {
8112 tokenizer.get();
8113 }
8114 else {
8115 var named = {};
8116 while (TRUE) {
8117 var varnode = Node(NODE_IDENTIFIER);
8118 var token = tokenizer.get();
8119 if (token.type == TOKEN_IDENTIFIER) {
8120 if (!isargname(token.value) || token.value == "firstline" || token.value == "lastline") {
8121 throw Err(viml_printf("E125: Illegal argument: %s", token.value), token.pos);
8122 }
8123 else if (viml_has_key(named, token.value)) {
8124 throw Err(viml_printf("E853: Duplicate argument name: %s", token.value), token.pos);
8125 }
8126 named[token.value] = 1;
8127 varnode.pos = token.pos;
8128 varnode.value = token.value;
8129 viml_add(node.rlist, varnode);
8130 if (tokenizer.peek().type == TOKEN_EQ) {
8131 tokenizer.get();
8132 viml_add(node.default_args, this.parse_expr());
8133 }
8134 else if (viml_len(node.default_args) > 0) {
8135 throw Err("E989: Non-default argument follows default argument", varnode.pos);
8136 }
8137 // XXX: Vim doesn't skip white space before comma. F(a ,b) => E475
8138 if (iswhite(this.reader.p(0)) && tokenizer.peek().type == TOKEN_COMMA) {
8139 throw Err("E475: Invalid argument: White space is not allowed before comma", this.reader.getpos());
8140 }
8141 var token = tokenizer.get();
8142 if (token.type == TOKEN_COMMA) {
8143 // XXX: Vim allows last comma. F(a, b, ) => OK
8144 if (tokenizer.peek().type == TOKEN_PCLOSE) {
8145 tokenizer.get();
8146 break;
8147 }
8148 }
8149 else if (token.type == TOKEN_PCLOSE) {
8150 break;
8151 }
8152 else {
8153 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
8154 }
8155 }
8156 else if (token.type == TOKEN_DOTDOTDOT) {
8157 varnode.pos = token.pos;
8158 varnode.value = token.value;
8159 viml_add(node.rlist, varnode);
8160 var token = tokenizer.get();
8161 if (token.type == TOKEN_PCLOSE) {
8162 break;
8163 }
8164 else {
8165 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
8166 }
8167 }
8168 else {
8169 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
8170 }
8171 }
8172 }
8173 while (TRUE) {
8174 this.reader.skip_white();
8175 var epos = this.reader.getpos();
8176 var key = this.reader.read_alpha();
8177 if (key == "") {
8178 break;
8179 }
8180 else if (key == "range") {
8181 node.attr.range = TRUE;
8182 }
8183 else if (key == "abort") {
8184 node.attr.abort = TRUE;
8185 }
8186 else if (key == "dict") {
8187 node.attr.dict = TRUE;
8188 }
8189 else if (key == "closure") {
8190 node.attr.closure = TRUE;
8191 }
8192 else {
8193 throw Err(viml_printf("unexpected token: %s", key), epos);
8194 }
8195 }
8196 this.add_node(node);
8197 this.push_context(node);
8198}
8199
8200VimLParser.prototype.parse_cmd_endfunction = function() {
8201 this.check_missing_endif("ENDFUNCTION", this.ea.cmdpos);
8202 this.check_missing_endtry("ENDFUNCTION", this.ea.cmdpos);
8203 this.check_missing_endwhile("ENDFUNCTION", this.ea.cmdpos);
8204 this.check_missing_endfor("ENDFUNCTION", this.ea.cmdpos);
8205 if (this.context[0].type != NODE_FUNCTION) {
8206 throw Err("E193: :endfunction not inside a function", this.ea.cmdpos);
8207 }
8208 this.reader.getn(-1);
8209 var node = Node(NODE_ENDFUNCTION);
8210 node.pos = this.ea.cmdpos;
8211 node.ea = this.ea;
8212 this.context[0].endfunction = node;
8213 this.pop_context();
8214}
8215
8216VimLParser.prototype.parse_cmd_delfunction = function() {
8217 var node = Node(NODE_DELFUNCTION);
8218 node.pos = this.ea.cmdpos;
8219 node.ea = this.ea;
8220 node.left = this.parse_lvalue_func();
8221 this.add_node(node);
8222}
8223
8224VimLParser.prototype.parse_cmd_return = function() {
8225 if (this.find_context(NODE_FUNCTION) == -1) {
8226 throw Err("E133: :return not inside a function", this.ea.cmdpos);
8227 }
8228 var node = Node(NODE_RETURN);
8229 node.pos = this.ea.cmdpos;
8230 node.ea = this.ea;
8231 node.left = NIL;
8232 this.reader.skip_white();
8233 var c = this.reader.peek();
8234 if (c == "\"" || !this.ends_excmds(c)) {
8235 node.left = this.parse_expr();
8236 }
8237 this.add_node(node);
8238}
8239
8240VimLParser.prototype.parse_cmd_call = function() {
8241 var node = Node(NODE_EXCALL);
8242 node.pos = this.ea.cmdpos;
8243 node.ea = this.ea;
8244 this.reader.skip_white();
8245 var c = this.reader.peek();
8246 if (this.ends_excmds(c)) {
8247 throw Err("E471: Argument required", this.reader.getpos());
8248 }
8249 node.left = this.parse_expr();
8250 if (node.left.type != NODE_CALL) {
8251 throw Err("Not an function call", node.left.pos);
8252 }
8253 this.add_node(node);
8254}
8255
8256VimLParser.prototype.parse_heredoc = function() {
8257 var node = Node(NODE_HEREDOC);
8258 node.pos = this.ea.cmdpos;
8259 node.op = "";
8260 node.rlist = [];
8261 node.body = [];
8262 while (TRUE) {
8263 this.reader.skip_white();
8264 var key = this.reader.read_word();
8265 if (key == "") {
8266 break;
8267 }
8268 if (!islower(key[0])) {
8269 node.op = key;
8270 break;
8271 }
8272 else {
8273 viml_add(node.rlist, key);
8274 }
8275 }
8276 if (node.op == "") {
8277 throw Err("E172: Missing marker", this.reader.getpos());
8278 }
8279 this.parse_trail();
8280 while (TRUE) {
8281 if (this.reader.peek() == "<EOF>") {
8282 break;
8283 }
8284 var line = this.reader.getn(-1);
8285 if (line == node.op) {
8286 return node;
8287 }
8288 viml_add(node.body, line);
8289 this.reader.get();
8290 }
8291 throw Err(viml_printf("E990: Missing end marker '%s'", node.op), this.reader.getpos());
8292}
8293
8294VimLParser.prototype.parse_cmd_let = function() {
8295 var pos = this.reader.tell();
8296 this.reader.skip_white();
8297 // :let
8298 if (this.ends_excmds(this.reader.peek())) {
8299 this.reader.seek_set(pos);
8300 this.parse_cmd_common();
8301 return;
8302 }
8303 var lhs = this.parse_letlhs();
8304 this.reader.skip_white();
8305 var s1 = this.reader.peekn(1);
8306 var s2 = this.reader.peekn(2);
8307 // TODO check scriptversion?
8308 if (s2 == "..") {
8309 var s2 = this.reader.peekn(3);
8310 }
8311 else if (s2 == "=<") {
8312 var s2 = this.reader.peekn(3);
8313 }
8314 // :let {var-name} ..
8315 if (this.ends_excmds(s1) || s2 != "+=" && s2 != "-=" && s2 != ".=" && s2 != "..=" && s2 != "*=" && s2 != "/=" && s2 != "%=" && s2 != "=<<" && s1 != "=") {
8316 this.reader.seek_set(pos);
8317 this.parse_cmd_common();
8318 return;
8319 }
8320 // :let left op right
8321 var node = Node(NODE_LET);
8322 node.pos = this.ea.cmdpos;
8323 node.ea = this.ea;
8324 node.op = "";
8325 node.left = lhs.left;
8326 node.list = lhs.list;
8327 node.rest = lhs.rest;
8328 node.right = NIL;
8329 if (s2 == "+=" || s2 == "-=" || s2 == ".=" || s2 == "..=" || s2 == "*=" || s2 == "/=" || s2 == "%=") {
8330 this.reader.getn(viml_len(s2));
8331 node.op = s2;
8332 }
8333 else if (s2 == "=<<") {
8334 this.reader.getn(viml_len(s2));
8335 this.reader.skip_white();
8336 node.op = s2;
8337 node.right = this.parse_heredoc();
8338 this.add_node(node);
8339 return;
8340 }
8341 else if (s1 == "=") {
8342 this.reader.getn(1);
8343 node.op = s1;
8344 }
8345 else {
8346 throw "NOT REACHED";
8347 }
8348 node.right = this.parse_expr();
8349 this.add_node(node);
8350}
8351
8352VimLParser.prototype.parse_cmd_const = function() {
8353 var pos = this.reader.tell();
8354 this.reader.skip_white();
8355 // :const
8356 if (this.ends_excmds(this.reader.peek())) {
8357 this.reader.seek_set(pos);
8358 this.parse_cmd_common();
8359 return;
8360 }
8361 var lhs = this.parse_constlhs();
8362 this.reader.skip_white();
8363 var s1 = this.reader.peekn(1);
8364 // :const {var-name}
8365 if (this.ends_excmds(s1) || s1 != "=") {
8366 this.reader.seek_set(pos);
8367 this.parse_cmd_common();
8368 return;
8369 }
8370 // :const left op right
8371 var node = Node(NODE_CONST);
8372 node.pos = this.ea.cmdpos;
8373 node.ea = this.ea;
8374 this.reader.getn(1);
8375 node.op = s1;
8376 node.left = lhs.left;
8377 node.list = lhs.list;
8378 node.rest = lhs.rest;
8379 node.right = this.parse_expr();
8380 this.add_node(node);
8381}
8382
8383VimLParser.prototype.parse_cmd_unlet = function() {
8384 var node = Node(NODE_UNLET);
8385 node.pos = this.ea.cmdpos;
8386 node.ea = this.ea;
8387 node.list = this.parse_lvaluelist();
8388 this.add_node(node);
8389}
8390
8391VimLParser.prototype.parse_cmd_lockvar = function() {
8392 var node = Node(NODE_LOCKVAR);
8393 node.pos = this.ea.cmdpos;
8394 node.ea = this.ea;
8395 node.depth = NIL;
8396 node.list = [];
8397 this.reader.skip_white();
8398 if (isdigit(this.reader.peekn(1))) {
8399 node.depth = viml_str2nr(this.reader.read_digit(), 10);
8400 }
8401 node.list = this.parse_lvaluelist();
8402 this.add_node(node);
8403}
8404
8405VimLParser.prototype.parse_cmd_unlockvar = function() {
8406 var node = Node(NODE_UNLOCKVAR);
8407 node.pos = this.ea.cmdpos;
8408 node.ea = this.ea;
8409 node.depth = NIL;
8410 node.list = [];
8411 this.reader.skip_white();
8412 if (isdigit(this.reader.peekn(1))) {
8413 node.depth = viml_str2nr(this.reader.read_digit(), 10);
8414 }
8415 node.list = this.parse_lvaluelist();
8416 this.add_node(node);
8417}
8418
8419VimLParser.prototype.parse_cmd_if = function() {
8420 var node = Node(NODE_IF);
8421 node.pos = this.ea.cmdpos;
8422 node.body = [];
8423 node.ea = this.ea;
8424 node.cond = this.parse_expr();
8425 node.elseif = [];
8426 node._else = NIL;
8427 node.endif = NIL;
8428 this.add_node(node);
8429 this.push_context(node);
8430}
8431
8432VimLParser.prototype.parse_cmd_elseif = function() {
8433 if (this.context[0].type != NODE_IF && this.context[0].type != NODE_ELSEIF) {
8434 throw Err("E582: :elseif without :if", this.ea.cmdpos);
8435 }
8436 if (this.context[0].type != NODE_IF) {
8437 this.pop_context();
8438 }
8439 var node = Node(NODE_ELSEIF);
8440 node.pos = this.ea.cmdpos;
8441 node.body = [];
8442 node.ea = this.ea;
8443 node.cond = this.parse_expr();
8444 viml_add(this.context[0].elseif, node);
8445 this.push_context(node);
8446}
8447
8448VimLParser.prototype.parse_cmd_else = function() {
8449 if (this.context[0].type != NODE_IF && this.context[0].type != NODE_ELSEIF) {
8450 throw Err("E581: :else without :if", this.ea.cmdpos);
8451 }
8452 if (this.context[0].type != NODE_IF) {
8453 this.pop_context();
8454 }
8455 var node = Node(NODE_ELSE);
8456 node.pos = this.ea.cmdpos;
8457 node.body = [];
8458 node.ea = this.ea;
8459 this.context[0]._else = node;
8460 this.push_context(node);
8461}
8462
8463VimLParser.prototype.parse_cmd_endif = function() {
8464 if (this.context[0].type != NODE_IF && this.context[0].type != NODE_ELSEIF && this.context[0].type != NODE_ELSE) {
8465 throw Err("E580: :endif without :if", this.ea.cmdpos);
8466 }
8467 if (this.context[0].type != NODE_IF) {
8468 this.pop_context();
8469 }
8470 var node = Node(NODE_ENDIF);
8471 node.pos = this.ea.cmdpos;
8472 node.ea = this.ea;
8473 this.context[0].endif = node;
8474 this.pop_context();
8475}
8476
8477VimLParser.prototype.parse_cmd_while = function() {
8478 var node = Node(NODE_WHILE);
8479 node.pos = this.ea.cmdpos;
8480 node.body = [];
8481 node.ea = this.ea;
8482 node.cond = this.parse_expr();
8483 node.endwhile = NIL;
8484 this.add_node(node);
8485 this.push_context(node);
8486}
8487
8488VimLParser.prototype.parse_cmd_endwhile = function() {
8489 if (this.context[0].type != NODE_WHILE) {
8490 throw Err("E588: :endwhile without :while", this.ea.cmdpos);
8491 }
8492 var node = Node(NODE_ENDWHILE);
8493 node.pos = this.ea.cmdpos;
8494 node.ea = this.ea;
8495 this.context[0].endwhile = node;
8496 this.pop_context();
8497}
8498
8499VimLParser.prototype.parse_cmd_for = function() {
8500 var node = Node(NODE_FOR);
8501 node.pos = this.ea.cmdpos;
8502 node.body = [];
8503 node.ea = this.ea;
8504 node.left = NIL;
8505 node.right = NIL;
8506 node.endfor = NIL;
8507 var lhs = this.parse_letlhs();
8508 node.left = lhs.left;
8509 node.list = lhs.list;
8510 node.rest = lhs.rest;
8511 this.reader.skip_white();
8512 var epos = this.reader.getpos();
8513 if (this.reader.read_alpha() != "in") {
8514 throw Err("Missing \"in\" after :for", epos);
8515 }
8516 node.right = this.parse_expr();
8517 this.add_node(node);
8518 this.push_context(node);
8519}
8520
8521VimLParser.prototype.parse_cmd_endfor = function() {
8522 if (this.context[0].type != NODE_FOR) {
8523 throw Err("E588: :endfor without :for", this.ea.cmdpos);
8524 }
8525 var node = Node(NODE_ENDFOR);
8526 node.pos = this.ea.cmdpos;
8527 node.ea = this.ea;
8528 this.context[0].endfor = node;
8529 this.pop_context();
8530}
8531
8532VimLParser.prototype.parse_cmd_continue = function() {
8533 if (this.find_context(NODE_WHILE) == -1 && this.find_context(NODE_FOR) == -1) {
8534 throw Err("E586: :continue without :while or :for", this.ea.cmdpos);
8535 }
8536 var node = Node(NODE_CONTINUE);
8537 node.pos = this.ea.cmdpos;
8538 node.ea = this.ea;
8539 this.add_node(node);
8540}
8541
8542VimLParser.prototype.parse_cmd_break = function() {
8543 if (this.find_context(NODE_WHILE) == -1 && this.find_context(NODE_FOR) == -1) {
8544 throw Err("E587: :break without :while or :for", this.ea.cmdpos);
8545 }
8546 var node = Node(NODE_BREAK);
8547 node.pos = this.ea.cmdpos;
8548 node.ea = this.ea;
8549 this.add_node(node);
8550}
8551
8552VimLParser.prototype.parse_cmd_try = function() {
8553 var node = Node(NODE_TRY);
8554 node.pos = this.ea.cmdpos;
8555 node.body = [];
8556 node.ea = this.ea;
8557 node.catch = [];
8558 node._finally = NIL;
8559 node.endtry = NIL;
8560 this.add_node(node);
8561 this.push_context(node);
8562}
8563
8564VimLParser.prototype.parse_cmd_catch = function() {
8565 if (this.context[0].type == NODE_FINALLY) {
8566 throw Err("E604: :catch after :finally", this.ea.cmdpos);
8567 }
8568 else if (this.context[0].type != NODE_TRY && this.context[0].type != NODE_CATCH) {
8569 throw Err("E603: :catch without :try", this.ea.cmdpos);
8570 }
8571 if (this.context[0].type != NODE_TRY) {
8572 this.pop_context();
8573 }
8574 var node = Node(NODE_CATCH);
8575 node.pos = this.ea.cmdpos;
8576 node.body = [];
8577 node.ea = this.ea;
8578 node.pattern = NIL;
8579 this.reader.skip_white();
8580 if (!this.ends_excmds(this.reader.peek())) {
8581 var __tmp = this.parse_pattern(this.reader.get());
8582 node.pattern = __tmp[0];
8583 var _ = __tmp[1];
8584 }
8585 viml_add(this.context[0].catch, node);
8586 this.push_context(node);
8587}
8588
8589VimLParser.prototype.parse_cmd_finally = function() {
8590 if (this.context[0].type != NODE_TRY && this.context[0].type != NODE_CATCH) {
8591 throw Err("E606: :finally without :try", this.ea.cmdpos);
8592 }
8593 if (this.context[0].type != NODE_TRY) {
8594 this.pop_context();
8595 }
8596 var node = Node(NODE_FINALLY);
8597 node.pos = this.ea.cmdpos;
8598 node.body = [];
8599 node.ea = this.ea;
8600 this.context[0]._finally = node;
8601 this.push_context(node);
8602}
8603
8604VimLParser.prototype.parse_cmd_endtry = function() {
8605 if (this.context[0].type != NODE_TRY && this.context[0].type != NODE_CATCH && this.context[0].type != NODE_FINALLY) {
8606 throw Err("E602: :endtry without :try", this.ea.cmdpos);
8607 }
8608 if (this.context[0].type != NODE_TRY) {
8609 this.pop_context();
8610 }
8611 var node = Node(NODE_ENDTRY);
8612 node.pos = this.ea.cmdpos;
8613 node.ea = this.ea;
8614 this.context[0].endtry = node;
8615 this.pop_context();
8616}
8617
8618VimLParser.prototype.parse_cmd_throw = function() {
8619 var node = Node(NODE_THROW);
8620 node.pos = this.ea.cmdpos;
8621 node.ea = this.ea;
8622 node.left = this.parse_expr();
8623 this.add_node(node);
8624}
8625
8626VimLParser.prototype.parse_cmd_eval = function() {
8627 var node = Node(NODE_EVAL);
8628 node.pos = this.ea.cmdpos;
8629 node.ea = this.ea;
8630 node.left = this.parse_expr();
8631 this.add_node(node);
8632}
8633
8634VimLParser.prototype.parse_cmd_echo = function() {
8635 var node = Node(NODE_ECHO);
8636 node.pos = this.ea.cmdpos;
8637 node.ea = this.ea;
8638 node.list = this.parse_exprlist();
8639 this.add_node(node);
8640}
8641
8642VimLParser.prototype.parse_cmd_echon = function() {
8643 var node = Node(NODE_ECHON);
8644 node.pos = this.ea.cmdpos;
8645 node.ea = this.ea;
8646 node.list = this.parse_exprlist();
8647 this.add_node(node);
8648}
8649
8650VimLParser.prototype.parse_cmd_echohl = function() {
8651 var node = Node(NODE_ECHOHL);
8652 node.pos = this.ea.cmdpos;
8653 node.ea = this.ea;
8654 node.str = "";
8655 while (!this.ends_excmds(this.reader.peek())) {
8656 node.str += this.reader.get();
8657 }
8658 this.add_node(node);
8659}
8660
8661VimLParser.prototype.parse_cmd_echomsg = function() {
8662 var node = Node(NODE_ECHOMSG);
8663 node.pos = this.ea.cmdpos;
8664 node.ea = this.ea;
8665 node.list = this.parse_exprlist();
8666 this.add_node(node);
8667}
8668
8669VimLParser.prototype.parse_cmd_echoerr = function() {
8670 var node = Node(NODE_ECHOERR);
8671 node.pos = this.ea.cmdpos;
8672 node.ea = this.ea;
8673 node.list = this.parse_exprlist();
8674 this.add_node(node);
8675}
8676
8677VimLParser.prototype.parse_cmd_execute = function() {
8678 var node = Node(NODE_EXECUTE);
8679 node.pos = this.ea.cmdpos;
8680 node.ea = this.ea;
8681 node.list = this.parse_exprlist();
8682 this.add_node(node);
8683}
8684
8685VimLParser.prototype.parse_expr = function() {
8686 return new ExprParser(this.reader).parse();
8687}
8688
8689VimLParser.prototype.parse_exprlist = function() {
8690 var list = [];
8691 while (TRUE) {
8692 this.reader.skip_white();
8693 var c = this.reader.peek();
8694 if (c != "\"" && this.ends_excmds(c)) {
8695 break;
8696 }
8697 var node = this.parse_expr();
8698 viml_add(list, node);
8699 }
8700 return list;
8701}
8702
8703VimLParser.prototype.parse_lvalue_func = function() {
8704 var p = new LvalueParser(this.reader);
8705 var node = p.parse();
8706 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) {
8707 return node;
8708 }
8709 throw Err("Invalid Expression", node.pos);
8710}
8711
8712// FIXME:
8713VimLParser.prototype.parse_lvalue = function() {
8714 var p = new LvalueParser(this.reader);
8715 var node = p.parse();
8716 if (node.type == NODE_IDENTIFIER) {
8717 if (!isvarname(node.value)) {
8718 throw Err(viml_printf("E461: Illegal variable name: %s", node.value), node.pos);
8719 }
8720 }
8721 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) {
8722 return node;
8723 }
8724 throw Err("Invalid Expression", node.pos);
8725}
8726
8727// TODO: merge with s:VimLParser.parse_lvalue()
8728VimLParser.prototype.parse_constlvalue = function() {
8729 var p = new LvalueParser(this.reader);
8730 var node = p.parse();
8731 if (node.type == NODE_IDENTIFIER) {
8732 if (!isvarname(node.value)) {
8733 throw Err(viml_printf("E461: Illegal variable name: %s", node.value), node.pos);
8734 }
8735 }
8736 if (node.type == NODE_IDENTIFIER || node.type == NODE_CURLYNAME) {
8737 return node;
8738 }
8739 else if (node.type == NODE_SUBSCRIPT || node.type == NODE_SLICE || node.type == NODE_DOT) {
8740 throw Err("E996: Cannot lock a list or dict", node.pos);
8741 }
8742 else if (node.type == NODE_OPTION) {
8743 throw Err("E996: Cannot lock an option", node.pos);
8744 }
8745 else if (node.type == NODE_ENV) {
8746 throw Err("E996: Cannot lock an environment variable", node.pos);
8747 }
8748 else if (node.type == NODE_REG) {
8749 throw Err("E996: Cannot lock a register", node.pos);
8750 }
8751 throw Err("Invalid Expression", node.pos);
8752}
8753
8754VimLParser.prototype.parse_lvaluelist = function() {
8755 var list = [];
8756 var node = this.parse_expr();
8757 viml_add(list, node);
8758 while (TRUE) {
8759 this.reader.skip_white();
8760 if (this.ends_excmds(this.reader.peek())) {
8761 break;
8762 }
8763 var node = this.parse_lvalue();
8764 viml_add(list, node);
8765 }
8766 return list;
8767}
8768
8769// FIXME:
8770VimLParser.prototype.parse_letlhs = function() {
8771 var lhs = {"left":NIL, "list":NIL, "rest":NIL};
8772 var tokenizer = new ExprTokenizer(this.reader);
8773 if (tokenizer.peek().type == TOKEN_SQOPEN) {
8774 tokenizer.get();
8775 lhs.list = [];
8776 while (TRUE) {
8777 var node = this.parse_lvalue();
8778 viml_add(lhs.list, node);
8779 var token = tokenizer.get();
8780 if (token.type == TOKEN_SQCLOSE) {
8781 break;
8782 }
8783 else if (token.type == TOKEN_COMMA) {
8784 continue;
8785 }
8786 else if (token.type == TOKEN_SEMICOLON) {
8787 var node = this.parse_lvalue();
8788 lhs.rest = node;
8789 var token = tokenizer.get();
8790 if (token.type == TOKEN_SQCLOSE) {
8791 break;
8792 }
8793 else {
8794 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
8795 }
8796 }
8797 else {
8798 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
8799 }
8800 }
8801 }
8802 else {
8803 lhs.left = this.parse_lvalue();
8804 }
8805 return lhs;
8806}
8807
8808// TODO: merge with s:VimLParser.parse_letlhs() ?
8809VimLParser.prototype.parse_constlhs = function() {
8810 var lhs = {"left":NIL, "list":NIL, "rest":NIL};
8811 var tokenizer = new ExprTokenizer(this.reader);
8812 if (tokenizer.peek().type == TOKEN_SQOPEN) {
8813 tokenizer.get();
8814 lhs.list = [];
8815 while (TRUE) {
8816 var node = this.parse_lvalue();
8817 viml_add(lhs.list, node);
8818 var token = tokenizer.get();
8819 if (token.type == TOKEN_SQCLOSE) {
8820 break;
8821 }
8822 else if (token.type == TOKEN_COMMA) {
8823 continue;
8824 }
8825 else if (token.type == TOKEN_SEMICOLON) {
8826 var node = this.parse_lvalue();
8827 lhs.rest = node;
8828 var token = tokenizer.get();
8829 if (token.type == TOKEN_SQCLOSE) {
8830 break;
8831 }
8832 else {
8833 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
8834 }
8835 }
8836 else {
8837 throw Err(viml_printf("E475 Invalid argument: %s", token.value), token.pos);
8838 }
8839 }
8840 }
8841 else {
8842 lhs.left = this.parse_constlvalue();
8843 }
8844 return lhs;
8845}
8846
8847VimLParser.prototype.ends_excmds = function(c) {
8848 return c == "" || c == "|" || c == "\"" || c == "<EOF>" || c == "<EOL>";
8849}
8850
8851// FIXME: validate argument
8852VimLParser.prototype.parse_wincmd = function() {
8853 var c = this.reader.getn(1);
8854 if (c == "") {
8855 throw Err("E471: Argument required", this.reader.getpos());
8856 }
8857 else if (c == "g" || c == "\x07") {
8858 // <C-G>
8859 var c2 = this.reader.getn(1);
8860 if (c2 == "" || iswhite(c2)) {
8861 throw Err("E474: Invalid Argument", this.reader.getpos());
8862 }
8863 }
8864 var end = this.reader.getpos();
8865 this.reader.skip_white();
8866 if (!this.ends_excmds(this.reader.peek())) {
8867 throw Err("E474: Invalid Argument", this.reader.getpos());
8868 }
8869 var node = Node(NODE_EXCMD);
8870 node.pos = this.ea.cmdpos;
8871 node.ea = this.ea;
8872 node.str = this.reader.getstr(this.ea.linepos, end);
8873 this.add_node(node);
8874}
8875
8876// FIXME: validate argument
8877VimLParser.prototype.parse_cmd_syntax = function() {
8878 var end = this.reader.getpos();
8879 while (TRUE) {
8880 var end = this.reader.getpos();
8881 var c = this.reader.peek();
8882 if (c == "/" || c == "'" || c == "\"") {
8883 this.reader.getn(1);
8884 this.parse_pattern(c);
8885 }
8886 else if (c == "=") {
8887 this.reader.getn(1);
8888 this.parse_pattern(" ");
8889 }
8890 else if (this.ends_excmds(c)) {
8891 break;
8892 }
8893 this.reader.getn(1);
8894 }
8895 var node = Node(NODE_EXCMD);
8896 node.pos = this.ea.cmdpos;
8897 node.ea = this.ea;
8898 node.str = this.reader.getstr(this.ea.linepos, end);
8899 this.add_node(node);
8900}
8901
8902VimLParser.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"}];
8903VimLParser.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"}];
8904// To find new builtin_commands, run the below script.
8905// $ scripts/update_builtin_commands.sh /path/to/vim/src/ex_cmds.h
8906VimLParser.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"}];
8907// To find new builtin_functions, run the below script.
8908// $ scripts/update_builtin_functions.sh /path/to/vim/src/evalfunc.c
8909VimLParser.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"}];
8910function ExprTokenizer() { this.__init__.apply(this, arguments); }
8911ExprTokenizer.prototype.__init__ = function(reader) {
8912 this.reader = reader;
8913 this.cache = {};
8914}
8915
8916ExprTokenizer.prototype.token = function(type, value, pos) {
8917 return {"type":type, "value":value, "pos":pos};
8918}
8919
8920ExprTokenizer.prototype.peek = function() {
8921 var pos = this.reader.tell();
8922 var r = this.get();
8923 this.reader.seek_set(pos);
8924 return r;
8925}
8926
8927ExprTokenizer.prototype.get = function() {
8928 // FIXME: remove dirty hack
8929 if (viml_has_key(this.cache, this.reader.tell())) {
8930 var x = this.cache[this.reader.tell()];
8931 this.reader.seek_set(x[0]);
8932 return x[1];
8933 }
8934 var pos = this.reader.tell();
8935 this.reader.skip_white();
8936 var r = this.get2();
8937 this.cache[pos] = [this.reader.tell(), r];
8938 return r;
8939}
8940
8941ExprTokenizer.prototype.get2 = function() {
8942 var r = this.reader;
8943 var pos = r.getpos();
8944 var c = r.peek();
8945 if (c == "<EOF>") {
8946 return this.token(TOKEN_EOF, c, pos);
8947 }
8948 else if (c == "<EOL>") {
8949 r.seek_cur(1);
8950 return this.token(TOKEN_EOL, c, pos);
8951 }
8952 else if (iswhite(c)) {
8953 var s = r.read_white();
8954 return this.token(TOKEN_SPACE, s, pos);
8955 }
8956 else if (c == "0" && (r.p(1) == "X" || r.p(1) == "x") && isxdigit(r.p(2))) {
8957 var s = r.getn(3);
8958 s += r.read_xdigit();
8959 return this.token(TOKEN_NUMBER, s, pos);
8960 }
8961 else if (c == "0" && (r.p(1) == "B" || r.p(1) == "b") && (r.p(2) == "0" || r.p(2) == "1")) {
8962 var s = r.getn(3);
8963 s += r.read_bdigit();
8964 return this.token(TOKEN_NUMBER, s, pos);
8965 }
8966 else if (c == "0" && (r.p(1) == "Z" || r.p(1) == "z") && r.p(2) != ".") {
8967 var s = r.getn(2);
8968 s += r.read_blob();
8969 return this.token(TOKEN_BLOB, s, pos);
8970 }
8971 else if (isdigit(c)) {
8972 var s = r.read_digit();
8973 if (r.p(0) == "." && isdigit(r.p(1))) {
8974 s += r.getn(1);
8975 s += r.read_digit();
8976 if ((r.p(0) == "E" || r.p(0) == "e") && (isdigit(r.p(1)) || (r.p(1) == "-" || r.p(1) == "+") && isdigit(r.p(2)))) {
8977 s += r.getn(2);
8978 s += r.read_digit();
8979 }
8980 }
8981 return this.token(TOKEN_NUMBER, s, pos);
8982 }
8983 else if (c == "i" && r.p(1) == "s" && !isidc(r.p(2))) {
8984 if (r.p(2) == "?") {
8985 r.seek_cur(3);
8986 return this.token(TOKEN_ISCI, "is?", pos);
8987 }
8988 else if (r.p(2) == "#") {
8989 r.seek_cur(3);
8990 return this.token(TOKEN_ISCS, "is#", pos);
8991 }
8992 else {
8993 r.seek_cur(2);
8994 return this.token(TOKEN_IS, "is", pos);
8995 }
8996 }
8997 else if (c == "i" && r.p(1) == "s" && r.p(2) == "n" && r.p(3) == "o" && r.p(4) == "t" && !isidc(r.p(5))) {
8998 if (r.p(5) == "?") {
8999 r.seek_cur(6);
9000 return this.token(TOKEN_ISNOTCI, "isnot?", pos);
9001 }
9002 else if (r.p(5) == "#") {
9003 r.seek_cur(6);
9004 return this.token(TOKEN_ISNOTCS, "isnot#", pos);
9005 }
9006 else {
9007 r.seek_cur(5);
9008 return this.token(TOKEN_ISNOT, "isnot", pos);
9009 }
9010 }
9011 else if (isnamec1(c)) {
9012 var s = r.read_name();
9013 return this.token(TOKEN_IDENTIFIER, s, pos);
9014 }
9015 else if (c == "|" && r.p(1) == "|") {
9016 r.seek_cur(2);
9017 return this.token(TOKEN_OROR, "||", pos);
9018 }
9019 else if (c == "&" && r.p(1) == "&") {
9020 r.seek_cur(2);
9021 return this.token(TOKEN_ANDAND, "&&", pos);
9022 }
9023 else if (c == "=" && r.p(1) == "=") {
9024 if (r.p(2) == "?") {
9025 r.seek_cur(3);
9026 return this.token(TOKEN_EQEQCI, "==?", pos);
9027 }
9028 else if (r.p(2) == "#") {
9029 r.seek_cur(3);
9030 return this.token(TOKEN_EQEQCS, "==#", pos);
9031 }
9032 else {
9033 r.seek_cur(2);
9034 return this.token(TOKEN_EQEQ, "==", pos);
9035 }
9036 }
9037 else if (c == "!" && r.p(1) == "=") {
9038 if (r.p(2) == "?") {
9039 r.seek_cur(3);
9040 return this.token(TOKEN_NEQCI, "!=?", pos);
9041 }
9042 else if (r.p(2) == "#") {
9043 r.seek_cur(3);
9044 return this.token(TOKEN_NEQCS, "!=#", pos);
9045 }
9046 else {
9047 r.seek_cur(2);
9048 return this.token(TOKEN_NEQ, "!=", pos);
9049 }
9050 }
9051 else if (c == ">" && r.p(1) == "=") {
9052 if (r.p(2) == "?") {
9053 r.seek_cur(3);
9054 return this.token(TOKEN_GTEQCI, ">=?", pos);
9055 }
9056 else if (r.p(2) == "#") {
9057 r.seek_cur(3);
9058 return this.token(TOKEN_GTEQCS, ">=#", pos);
9059 }
9060 else {
9061 r.seek_cur(2);
9062 return this.token(TOKEN_GTEQ, ">=", pos);
9063 }
9064 }
9065 else if (c == "<" && r.p(1) == "=") {
9066 if (r.p(2) == "?") {
9067 r.seek_cur(3);
9068 return this.token(TOKEN_LTEQCI, "<=?", pos);
9069 }
9070 else if (r.p(2) == "#") {
9071 r.seek_cur(3);
9072 return this.token(TOKEN_LTEQCS, "<=#", pos);
9073 }
9074 else {
9075 r.seek_cur(2);
9076 return this.token(TOKEN_LTEQ, "<=", pos);
9077 }
9078 }
9079 else if (c == "=" && r.p(1) == "~") {
9080 if (r.p(2) == "?") {
9081 r.seek_cur(3);
9082 return this.token(TOKEN_MATCHCI, "=~?", pos);
9083 }
9084 else if (r.p(2) == "#") {
9085 r.seek_cur(3);
9086 return this.token(TOKEN_MATCHCS, "=~#", pos);
9087 }
9088 else {
9089 r.seek_cur(2);
9090 return this.token(TOKEN_MATCH, "=~", pos);
9091 }
9092 }
9093 else if (c == "!" && r.p(1) == "~") {
9094 if (r.p(2) == "?") {
9095 r.seek_cur(3);
9096 return this.token(TOKEN_NOMATCHCI, "!~?", pos);
9097 }
9098 else if (r.p(2) == "#") {
9099 r.seek_cur(3);
9100 return this.token(TOKEN_NOMATCHCS, "!~#", pos);
9101 }
9102 else {
9103 r.seek_cur(2);
9104 return this.token(TOKEN_NOMATCH, "!~", pos);
9105 }
9106 }
9107 else if (c == ">") {
9108 if (r.p(1) == "?") {
9109 r.seek_cur(2);
9110 return this.token(TOKEN_GTCI, ">?", pos);
9111 }
9112 else if (r.p(1) == "#") {
9113 r.seek_cur(2);
9114 return this.token(TOKEN_GTCS, ">#", pos);
9115 }
9116 else {
9117 r.seek_cur(1);
9118 return this.token(TOKEN_GT, ">", pos);
9119 }
9120 }
9121 else if (c == "<") {
9122 if (r.p(1) == "?") {
9123 r.seek_cur(2);
9124 return this.token(TOKEN_LTCI, "<?", pos);
9125 }
9126 else if (r.p(1) == "#") {
9127 r.seek_cur(2);
9128 return this.token(TOKEN_LTCS, "<#", pos);
9129 }
9130 else {
9131 r.seek_cur(1);
9132 return this.token(TOKEN_LT, "<", pos);
9133 }
9134 }
9135 else if (c == "+") {
9136 r.seek_cur(1);
9137 return this.token(TOKEN_PLUS, "+", pos);
9138 }
9139 else if (c == "-") {
9140 if (r.p(1) == ">") {
9141 r.seek_cur(2);
9142 return this.token(TOKEN_ARROW, "->", pos);
9143 }
9144 else {
9145 r.seek_cur(1);
9146 return this.token(TOKEN_MINUS, "-", pos);
9147 }
9148 }
9149 else if (c == ".") {
9150 if (r.p(1) == "." && r.p(2) == ".") {
9151 r.seek_cur(3);
9152 return this.token(TOKEN_DOTDOTDOT, "...", pos);
9153 }
9154 else if (r.p(1) == ".") {
9155 r.seek_cur(2);
9156 return this.token(TOKEN_DOTDOT, "..", pos);
9157 // TODO check scriptversion?
9158 }
9159 else {
9160 r.seek_cur(1);
9161 return this.token(TOKEN_DOT, ".", pos);
9162 // TODO check scriptversion?
9163 }
9164 }
9165 else if (c == "*") {
9166 r.seek_cur(1);
9167 return this.token(TOKEN_STAR, "*", pos);
9168 }
9169 else if (c == "/") {
9170 r.seek_cur(1);
9171 return this.token(TOKEN_SLASH, "/", pos);
9172 }
9173 else if (c == "%") {
9174 r.seek_cur(1);
9175 return this.token(TOKEN_PERCENT, "%", pos);
9176 }
9177 else if (c == "!") {
9178 r.seek_cur(1);
9179 return this.token(TOKEN_NOT, "!", pos);
9180 }
9181 else if (c == "?") {
9182 r.seek_cur(1);
9183 return this.token(TOKEN_QUESTION, "?", pos);
9184 }
9185 else if (c == ":") {
9186 r.seek_cur(1);
9187 return this.token(TOKEN_COLON, ":", pos);
9188 }
9189 else if (c == "#") {
9190 if (r.p(1) == "{") {
9191 r.seek_cur(2);
9192 return this.token(TOKEN_LITCOPEN, "#{", pos);
9193 }
9194 else {
9195 r.seek_cur(1);
9196 return this.token(TOKEN_SHARP, "#", pos);
9197 }
9198 }
9199 else if (c == "(") {
9200 r.seek_cur(1);
9201 return this.token(TOKEN_POPEN, "(", pos);
9202 }
9203 else if (c == ")") {
9204 r.seek_cur(1);
9205 return this.token(TOKEN_PCLOSE, ")", pos);
9206 }
9207 else if (c == "[") {
9208 r.seek_cur(1);
9209 return this.token(TOKEN_SQOPEN, "[", pos);
9210 }
9211 else if (c == "]") {
9212 r.seek_cur(1);
9213 return this.token(TOKEN_SQCLOSE, "]", pos);
9214 }
9215 else if (c == "{") {
9216 r.seek_cur(1);
9217 return this.token(TOKEN_COPEN, "{", pos);
9218 }
9219 else if (c == "}") {
9220 r.seek_cur(1);
9221 return this.token(TOKEN_CCLOSE, "}", pos);
9222 }
9223 else if (c == ",") {
9224 r.seek_cur(1);
9225 return this.token(TOKEN_COMMA, ",", pos);
9226 }
9227 else if (c == "'") {
9228 r.seek_cur(1);
9229 return this.token(TOKEN_SQUOTE, "'", pos);
9230 }
9231 else if (c == "\"") {
9232 r.seek_cur(1);
9233 return this.token(TOKEN_DQUOTE, "\"", pos);
9234 }
9235 else if (c == "$") {
9236 var s = r.getn(1);
9237 s += r.read_word();
9238 return this.token(TOKEN_ENV, s, pos);
9239 }
9240 else if (c == "@") {
9241 // @<EOL> is treated as @"
9242 return this.token(TOKEN_REG, r.getn(2), pos);
9243 }
9244 else if (c == "&") {
9245 var s = "";
9246 if ((r.p(1) == "g" || r.p(1) == "l") && r.p(2) == ":") {
9247 var s = r.getn(3) + r.read_word();
9248 }
9249 else {
9250 var s = r.getn(1) + r.read_word();
9251 }
9252 return this.token(TOKEN_OPTION, s, pos);
9253 }
9254 else if (c == "=") {
9255 r.seek_cur(1);
9256 return this.token(TOKEN_EQ, "=", pos);
9257 }
9258 else if (c == "|") {
9259 r.seek_cur(1);
9260 return this.token(TOKEN_OR, "|", pos);
9261 }
9262 else if (c == ";") {
9263 r.seek_cur(1);
9264 return this.token(TOKEN_SEMICOLON, ";", pos);
9265 }
9266 else if (c == "`") {
9267 r.seek_cur(1);
9268 return this.token(TOKEN_BACKTICK, "`", pos);
9269 }
9270 else {
9271 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
9272 }
9273}
9274
9275ExprTokenizer.prototype.get_sstring = function() {
9276 this.reader.skip_white();
9277 var c = this.reader.p(0);
9278 if (c != "'") {
9279 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
9280 }
9281 this.reader.seek_cur(1);
9282 var s = "";
9283 while (TRUE) {
9284 var c = this.reader.p(0);
9285 if (c == "<EOF>" || c == "<EOL>") {
9286 throw Err("unexpected EOL", this.reader.getpos());
9287 }
9288 else if (c == "'") {
9289 this.reader.seek_cur(1);
9290 if (this.reader.p(0) == "'") {
9291 this.reader.seek_cur(1);
9292 s += "''";
9293 }
9294 else {
9295 break;
9296 }
9297 }
9298 else {
9299 this.reader.seek_cur(1);
9300 s += c;
9301 }
9302 }
9303 return s;
9304}
9305
9306ExprTokenizer.prototype.get_dstring = function() {
9307 this.reader.skip_white();
9308 var c = this.reader.p(0);
9309 if (c != "\"") {
9310 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
9311 }
9312 this.reader.seek_cur(1);
9313 var s = "";
9314 while (TRUE) {
9315 var c = this.reader.p(0);
9316 if (c == "<EOF>" || c == "<EOL>") {
9317 throw Err("unexpectd EOL", this.reader.getpos());
9318 }
9319 else if (c == "\"") {
9320 this.reader.seek_cur(1);
9321 break;
9322 }
9323 else if (c == "\\") {
9324 this.reader.seek_cur(1);
9325 s += c;
9326 var c = this.reader.p(0);
9327 if (c == "<EOF>" || c == "<EOL>") {
9328 throw Err("ExprTokenizer: unexpected EOL", this.reader.getpos());
9329 }
9330 this.reader.seek_cur(1);
9331 s += c;
9332 }
9333 else {
9334 this.reader.seek_cur(1);
9335 s += c;
9336 }
9337 }
9338 return s;
9339}
9340
9341ExprTokenizer.prototype.parse_dict_literal_key = function() {
9342 this.reader.skip_white();
9343 var c = this.reader.peek();
9344 if (!isalnum(c) && c != "_" && c != "-") {
9345 throw Err(viml_printf("unexpected character: %s", c), this.reader.getpos());
9346 }
9347 var node = Node(NODE_STRING);
9348 var s = c;
9349 this.reader.seek_cur(1);
9350 node.pos = this.reader.getpos();
9351 while (TRUE) {
9352 var c = this.reader.p(0);
9353 if (c == "<EOF>" || c == "<EOL>") {
9354 throw Err("unexpectd EOL", this.reader.getpos());
9355 }
9356 if (!isalnum(c) && c != "_" && c != "-") {
9357 break;
9358 }
9359 this.reader.seek_cur(1);
9360 s += c;
9361 }
9362 node.value = "'" + s + "'";
9363 return node;
9364}
9365
9366function ExprParser() { this.__init__.apply(this, arguments); }
9367ExprParser.prototype.__init__ = function(reader) {
9368 this.reader = reader;
9369 this.tokenizer = new ExprTokenizer(reader);
9370}
9371
9372ExprParser.prototype.parse = function() {
9373 return this.parse_expr1();
9374}
9375
9376// expr1: expr2 ? expr1 : expr1
9377ExprParser.prototype.parse_expr1 = function() {
9378 var left = this.parse_expr2();
9379 var pos = this.reader.tell();
9380 var token = this.tokenizer.get();
9381 if (token.type == TOKEN_QUESTION) {
9382 var node = Node(NODE_TERNARY);
9383 node.pos = token.pos;
9384 node.cond = left;
9385 node.left = this.parse_expr1();
9386 var token = this.tokenizer.get();
9387 if (token.type != TOKEN_COLON) {
9388 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
9389 }
9390 node.right = this.parse_expr1();
9391 var left = node;
9392 }
9393 else {
9394 this.reader.seek_set(pos);
9395 }
9396 return left;
9397}
9398
9399// expr2: expr3 || expr3 ..
9400ExprParser.prototype.parse_expr2 = function() {
9401 var left = this.parse_expr3();
9402 while (TRUE) {
9403 var pos = this.reader.tell();
9404 var token = this.tokenizer.get();
9405 if (token.type == TOKEN_OROR) {
9406 var node = Node(NODE_OR);
9407 node.pos = token.pos;
9408 node.left = left;
9409 node.right = this.parse_expr3();
9410 var left = node;
9411 }
9412 else {
9413 this.reader.seek_set(pos);
9414 break;
9415 }
9416 }
9417 return left;
9418}
9419
9420// expr3: expr4 && expr4
9421ExprParser.prototype.parse_expr3 = function() {
9422 var left = this.parse_expr4();
9423 while (TRUE) {
9424 var pos = this.reader.tell();
9425 var token = this.tokenizer.get();
9426 if (token.type == TOKEN_ANDAND) {
9427 var node = Node(NODE_AND);
9428 node.pos = token.pos;
9429 node.left = left;
9430 node.right = this.parse_expr4();
9431 var left = node;
9432 }
9433 else {
9434 this.reader.seek_set(pos);
9435 break;
9436 }
9437 }
9438 return left;
9439}
9440
9441// expr4: expr5 == expr5
9442// expr5 != expr5
9443// expr5 > expr5
9444// expr5 >= expr5
9445// expr5 < expr5
9446// expr5 <= expr5
9447// expr5 =~ expr5
9448// expr5 !~ expr5
9449//
9450// expr5 ==? expr5
9451// expr5 ==# expr5
9452// etc.
9453//
9454// expr5 is expr5
9455// expr5 isnot expr5
9456ExprParser.prototype.parse_expr4 = function() {
9457 var left = this.parse_expr5();
9458 var pos = this.reader.tell();
9459 var token = this.tokenizer.get();
9460 if (token.type == TOKEN_EQEQ) {
9461 var node = Node(NODE_EQUAL);
9462 node.pos = token.pos;
9463 node.left = left;
9464 node.right = this.parse_expr5();
9465 var left = node;
9466 }
9467 else if (token.type == TOKEN_EQEQCI) {
9468 var node = Node(NODE_EQUALCI);
9469 node.pos = token.pos;
9470 node.left = left;
9471 node.right = this.parse_expr5();
9472 var left = node;
9473 }
9474 else if (token.type == TOKEN_EQEQCS) {
9475 var node = Node(NODE_EQUALCS);
9476 node.pos = token.pos;
9477 node.left = left;
9478 node.right = this.parse_expr5();
9479 var left = node;
9480 }
9481 else if (token.type == TOKEN_NEQ) {
9482 var node = Node(NODE_NEQUAL);
9483 node.pos = token.pos;
9484 node.left = left;
9485 node.right = this.parse_expr5();
9486 var left = node;
9487 }
9488 else if (token.type == TOKEN_NEQCI) {
9489 var node = Node(NODE_NEQUALCI);
9490 node.pos = token.pos;
9491 node.left = left;
9492 node.right = this.parse_expr5();
9493 var left = node;
9494 }
9495 else if (token.type == TOKEN_NEQCS) {
9496 var node = Node(NODE_NEQUALCS);
9497 node.pos = token.pos;
9498 node.left = left;
9499 node.right = this.parse_expr5();
9500 var left = node;
9501 }
9502 else if (token.type == TOKEN_GT) {
9503 var node = Node(NODE_GREATER);
9504 node.pos = token.pos;
9505 node.left = left;
9506 node.right = this.parse_expr5();
9507 var left = node;
9508 }
9509 else if (token.type == TOKEN_GTCI) {
9510 var node = Node(NODE_GREATERCI);
9511 node.pos = token.pos;
9512 node.left = left;
9513 node.right = this.parse_expr5();
9514 var left = node;
9515 }
9516 else if (token.type == TOKEN_GTCS) {
9517 var node = Node(NODE_GREATERCS);
9518 node.pos = token.pos;
9519 node.left = left;
9520 node.right = this.parse_expr5();
9521 var left = node;
9522 }
9523 else if (token.type == TOKEN_GTEQ) {
9524 var node = Node(NODE_GEQUAL);
9525 node.pos = token.pos;
9526 node.left = left;
9527 node.right = this.parse_expr5();
9528 var left = node;
9529 }
9530 else if (token.type == TOKEN_GTEQCI) {
9531 var node = Node(NODE_GEQUALCI);
9532 node.pos = token.pos;
9533 node.left = left;
9534 node.right = this.parse_expr5();
9535 var left = node;
9536 }
9537 else if (token.type == TOKEN_GTEQCS) {
9538 var node = Node(NODE_GEQUALCS);
9539 node.pos = token.pos;
9540 node.left = left;
9541 node.right = this.parse_expr5();
9542 var left = node;
9543 }
9544 else if (token.type == TOKEN_LT) {
9545 var node = Node(NODE_SMALLER);
9546 node.pos = token.pos;
9547 node.left = left;
9548 node.right = this.parse_expr5();
9549 var left = node;
9550 }
9551 else if (token.type == TOKEN_LTCI) {
9552 var node = Node(NODE_SMALLERCI);
9553 node.pos = token.pos;
9554 node.left = left;
9555 node.right = this.parse_expr5();
9556 var left = node;
9557 }
9558 else if (token.type == TOKEN_LTCS) {
9559 var node = Node(NODE_SMALLERCS);
9560 node.pos = token.pos;
9561 node.left = left;
9562 node.right = this.parse_expr5();
9563 var left = node;
9564 }
9565 else if (token.type == TOKEN_LTEQ) {
9566 var node = Node(NODE_SEQUAL);
9567 node.pos = token.pos;
9568 node.left = left;
9569 node.right = this.parse_expr5();
9570 var left = node;
9571 }
9572 else if (token.type == TOKEN_LTEQCI) {
9573 var node = Node(NODE_SEQUALCI);
9574 node.pos = token.pos;
9575 node.left = left;
9576 node.right = this.parse_expr5();
9577 var left = node;
9578 }
9579 else if (token.type == TOKEN_LTEQCS) {
9580 var node = Node(NODE_SEQUALCS);
9581 node.pos = token.pos;
9582 node.left = left;
9583 node.right = this.parse_expr5();
9584 var left = node;
9585 }
9586 else if (token.type == TOKEN_MATCH) {
9587 var node = Node(NODE_MATCH);
9588 node.pos = token.pos;
9589 node.left = left;
9590 node.right = this.parse_expr5();
9591 var left = node;
9592 }
9593 else if (token.type == TOKEN_MATCHCI) {
9594 var node = Node(NODE_MATCHCI);
9595 node.pos = token.pos;
9596 node.left = left;
9597 node.right = this.parse_expr5();
9598 var left = node;
9599 }
9600 else if (token.type == TOKEN_MATCHCS) {
9601 var node = Node(NODE_MATCHCS);
9602 node.pos = token.pos;
9603 node.left = left;
9604 node.right = this.parse_expr5();
9605 var left = node;
9606 }
9607 else if (token.type == TOKEN_NOMATCH) {
9608 var node = Node(NODE_NOMATCH);
9609 node.pos = token.pos;
9610 node.left = left;
9611 node.right = this.parse_expr5();
9612 var left = node;
9613 }
9614 else if (token.type == TOKEN_NOMATCHCI) {
9615 var node = Node(NODE_NOMATCHCI);
9616 node.pos = token.pos;
9617 node.left = left;
9618 node.right = this.parse_expr5();
9619 var left = node;
9620 }
9621 else if (token.type == TOKEN_NOMATCHCS) {
9622 var node = Node(NODE_NOMATCHCS);
9623 node.pos = token.pos;
9624 node.left = left;
9625 node.right = this.parse_expr5();
9626 var left = node;
9627 }
9628 else if (token.type == TOKEN_IS) {
9629 var node = Node(NODE_IS);
9630 node.pos = token.pos;
9631 node.left = left;
9632 node.right = this.parse_expr5();
9633 var left = node;
9634 }
9635 else if (token.type == TOKEN_ISCI) {
9636 var node = Node(NODE_ISCI);
9637 node.pos = token.pos;
9638 node.left = left;
9639 node.right = this.parse_expr5();
9640 var left = node;
9641 }
9642 else if (token.type == TOKEN_ISCS) {
9643 var node = Node(NODE_ISCS);
9644 node.pos = token.pos;
9645 node.left = left;
9646 node.right = this.parse_expr5();
9647 var left = node;
9648 }
9649 else if (token.type == TOKEN_ISNOT) {
9650 var node = Node(NODE_ISNOT);
9651 node.pos = token.pos;
9652 node.left = left;
9653 node.right = this.parse_expr5();
9654 var left = node;
9655 }
9656 else if (token.type == TOKEN_ISNOTCI) {
9657 var node = Node(NODE_ISNOTCI);
9658 node.pos = token.pos;
9659 node.left = left;
9660 node.right = this.parse_expr5();
9661 var left = node;
9662 }
9663 else if (token.type == TOKEN_ISNOTCS) {
9664 var node = Node(NODE_ISNOTCS);
9665 node.pos = token.pos;
9666 node.left = left;
9667 node.right = this.parse_expr5();
9668 var left = node;
9669 }
9670 else {
9671 this.reader.seek_set(pos);
9672 }
9673 return left;
9674}
9675
9676// expr5: expr6 + expr6 ..
9677// expr6 - expr6 ..
9678// expr6 . expr6 ..
9679// expr6 .. expr6 ..
9680ExprParser.prototype.parse_expr5 = function() {
9681 var left = this.parse_expr6();
9682 while (TRUE) {
9683 var pos = this.reader.tell();
9684 var token = this.tokenizer.get();
9685 if (token.type == TOKEN_PLUS) {
9686 var node = Node(NODE_ADD);
9687 node.pos = token.pos;
9688 node.left = left;
9689 node.right = this.parse_expr6();
9690 var left = node;
9691 }
9692 else if (token.type == TOKEN_MINUS) {
9693 var node = Node(NODE_SUBTRACT);
9694 node.pos = token.pos;
9695 node.left = left;
9696 node.right = this.parse_expr6();
9697 var left = node;
9698 }
9699 else if (token.type == TOKEN_DOTDOT) {
9700 // TODO check scriptversion?
9701 var node = Node(NODE_CONCAT);
9702 node.pos = token.pos;
9703 node.left = left;
9704 node.right = this.parse_expr6();
9705 var left = node;
9706 }
9707 else if (token.type == TOKEN_DOT) {
9708 // TODO check scriptversion?
9709 var node = Node(NODE_CONCAT);
9710 node.pos = token.pos;
9711 node.left = left;
9712 node.right = this.parse_expr6();
9713 var left = node;
9714 }
9715 else {
9716 this.reader.seek_set(pos);
9717 break;
9718 }
9719 }
9720 return left;
9721}
9722
9723// expr6: expr7 * expr7 ..
9724// expr7 / expr7 ..
9725// expr7 % expr7 ..
9726ExprParser.prototype.parse_expr6 = function() {
9727 var left = this.parse_expr7();
9728 while (TRUE) {
9729 var pos = this.reader.tell();
9730 var token = this.tokenizer.get();
9731 if (token.type == TOKEN_STAR) {
9732 var node = Node(NODE_MULTIPLY);
9733 node.pos = token.pos;
9734 node.left = left;
9735 node.right = this.parse_expr7();
9736 var left = node;
9737 }
9738 else if (token.type == TOKEN_SLASH) {
9739 var node = Node(NODE_DIVIDE);
9740 node.pos = token.pos;
9741 node.left = left;
9742 node.right = this.parse_expr7();
9743 var left = node;
9744 }
9745 else if (token.type == TOKEN_PERCENT) {
9746 var node = Node(NODE_REMAINDER);
9747 node.pos = token.pos;
9748 node.left = left;
9749 node.right = this.parse_expr7();
9750 var left = node;
9751 }
9752 else {
9753 this.reader.seek_set(pos);
9754 break;
9755 }
9756 }
9757 return left;
9758}
9759
9760// expr7: ! expr7
9761// - expr7
9762// + expr7
9763ExprParser.prototype.parse_expr7 = function() {
9764 var pos = this.reader.tell();
9765 var token = this.tokenizer.get();
9766 if (token.type == TOKEN_NOT) {
9767 var node = Node(NODE_NOT);
9768 node.pos = token.pos;
9769 node.left = this.parse_expr7();
9770 return node;
9771 }
9772 else if (token.type == TOKEN_MINUS) {
9773 var node = Node(NODE_MINUS);
9774 node.pos = token.pos;
9775 node.left = this.parse_expr7();
9776 return node;
9777 }
9778 else if (token.type == TOKEN_PLUS) {
9779 var node = Node(NODE_PLUS);
9780 node.pos = token.pos;
9781 node.left = this.parse_expr7();
9782 return node;
9783 }
9784 else {
9785 this.reader.seek_set(pos);
9786 var node = this.parse_expr8();
9787 return node;
9788 }
9789}
9790
9791// expr8: expr8[expr1]
9792// expr8[expr1 : expr1]
9793// expr8.name
9794// expr8->name(expr1, ...)
9795// expr8->s:user_func(expr1, ...)
9796// expr8->{lambda}(expr1, ...)
9797// expr8(expr1, ...)
9798ExprParser.prototype.parse_expr8 = function() {
9799 var left = this.parse_expr9();
9800 while (TRUE) {
9801 var pos = this.reader.tell();
9802 var c = this.reader.peek();
9803 var token = this.tokenizer.get();
9804 if (!iswhite(c) && token.type == TOKEN_SQOPEN) {
9805 var npos = token.pos;
9806 if (this.tokenizer.peek().type == TOKEN_COLON) {
9807 this.tokenizer.get();
9808 var node = Node(NODE_SLICE);
9809 node.pos = npos;
9810 node.left = left;
9811 node.rlist = [NIL, NIL];
9812 var token = this.tokenizer.peek();
9813 if (token.type != TOKEN_SQCLOSE) {
9814 node.rlist[1] = this.parse_expr1();
9815 }
9816 var token = this.tokenizer.get();
9817 if (token.type != TOKEN_SQCLOSE) {
9818 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
9819 }
9820 var left = node;
9821 }
9822 else {
9823 var right = this.parse_expr1();
9824 if (this.tokenizer.peek().type == TOKEN_COLON) {
9825 this.tokenizer.get();
9826 var node = Node(NODE_SLICE);
9827 node.pos = npos;
9828 node.left = left;
9829 node.rlist = [right, NIL];
9830 var token = this.tokenizer.peek();
9831 if (token.type != TOKEN_SQCLOSE) {
9832 node.rlist[1] = this.parse_expr1();
9833 }
9834 var token = this.tokenizer.get();
9835 if (token.type != TOKEN_SQCLOSE) {
9836 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
9837 }
9838 var left = node;
9839 }
9840 else {
9841 var node = Node(NODE_SUBSCRIPT);
9842 node.pos = npos;
9843 node.left = left;
9844 node.right = right;
9845 var token = this.tokenizer.get();
9846 if (token.type != TOKEN_SQCLOSE) {
9847 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
9848 }
9849 var left = node;
9850 }
9851 }
9852 delete node;
9853 }
9854 else if (token.type == TOKEN_ARROW) {
9855 var funcname_or_lambda = this.parse_expr9();
9856 var token = this.tokenizer.get();
9857 if (token.type != TOKEN_POPEN) {
9858 throw Err("E107: Missing parentheses: lambda", token.pos);
9859 }
9860 var right = Node(NODE_CALL);
9861 right.pos = token.pos;
9862 right.left = funcname_or_lambda;
9863 right.rlist = this.parse_rlist();
9864 var node = Node(NODE_METHOD);
9865 node.pos = token.pos;
9866 node.left = left;
9867 node.right = right;
9868 var left = node;
9869 delete node;
9870 }
9871 else if (token.type == TOKEN_POPEN) {
9872 var node = Node(NODE_CALL);
9873 node.pos = token.pos;
9874 node.left = left;
9875 node.rlist = this.parse_rlist();
9876 var left = node;
9877 delete node;
9878 }
9879 else if (!iswhite(c) && token.type == TOKEN_DOT) {
9880 // TODO check scriptversion?
9881 var node = this.parse_dot(token, left);
9882 if (node === NIL) {
9883 this.reader.seek_set(pos);
9884 break;
9885 }
9886 var left = node;
9887 delete node;
9888 }
9889 else {
9890 this.reader.seek_set(pos);
9891 break;
9892 }
9893 }
9894 return left;
9895}
9896
9897ExprParser.prototype.parse_rlist = function() {
9898 var rlist = [];
9899 var token = this.tokenizer.peek();
9900 if (this.tokenizer.peek().type == TOKEN_PCLOSE) {
9901 this.tokenizer.get();
9902 }
9903 else {
9904 while (TRUE) {
9905 viml_add(rlist, this.parse_expr1());
9906 var token = this.tokenizer.get();
9907 if (token.type == TOKEN_COMMA) {
9908 // XXX: Vim allows foo(a, b, ). Lint should warn it.
9909 if (this.tokenizer.peek().type == TOKEN_PCLOSE) {
9910 this.tokenizer.get();
9911 break;
9912 }
9913 }
9914 else if (token.type == TOKEN_PCLOSE) {
9915 break;
9916 }
9917 else {
9918 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
9919 }
9920 }
9921 }
9922 if (viml_len(rlist) > MAX_FUNC_ARGS) {
9923 // TODO: funcname E740: Too many arguments for function: %s
9924 throw Err("E740: Too many arguments for function", token.pos);
9925 }
9926 return rlist;
9927}
9928
9929// expr9: number
9930// "string"
9931// 'string'
9932// [expr1, ...]
9933// {expr1: expr1, ...}
9934// #{literal_key1: expr1, ...}
9935// {args -> expr1}
9936// &option
9937// (expr1)
9938// variable
9939// var{ria}ble
9940// $VAR
9941// @r
9942// function(expr1, ...)
9943// func{ti}on(expr1, ...)
9944ExprParser.prototype.parse_expr9 = function() {
9945 var pos = this.reader.tell();
9946 var token = this.tokenizer.get();
9947 var node = Node(-1);
9948 if (token.type == TOKEN_NUMBER) {
9949 var node = Node(NODE_NUMBER);
9950 node.pos = token.pos;
9951 node.value = token.value;
9952 }
9953 else if (token.type == TOKEN_BLOB) {
9954 var node = Node(NODE_BLOB);
9955 node.pos = token.pos;
9956 node.value = token.value;
9957 }
9958 else if (token.type == TOKEN_DQUOTE) {
9959 this.reader.seek_set(pos);
9960 var node = Node(NODE_STRING);
9961 node.pos = token.pos;
9962 node.value = "\"" + this.tokenizer.get_dstring() + "\"";
9963 }
9964 else if (token.type == TOKEN_SQUOTE) {
9965 this.reader.seek_set(pos);
9966 var node = Node(NODE_STRING);
9967 node.pos = token.pos;
9968 node.value = "'" + this.tokenizer.get_sstring() + "'";
9969 }
9970 else if (token.type == TOKEN_SQOPEN) {
9971 var node = Node(NODE_LIST);
9972 node.pos = token.pos;
9973 node.value = [];
9974 var token = this.tokenizer.peek();
9975 if (token.type == TOKEN_SQCLOSE) {
9976 this.tokenizer.get();
9977 }
9978 else {
9979 while (TRUE) {
9980 viml_add(node.value, this.parse_expr1());
9981 var token = this.tokenizer.peek();
9982 if (token.type == TOKEN_COMMA) {
9983 this.tokenizer.get();
9984 if (this.tokenizer.peek().type == TOKEN_SQCLOSE) {
9985 this.tokenizer.get();
9986 break;
9987 }
9988 }
9989 else if (token.type == TOKEN_SQCLOSE) {
9990 this.tokenizer.get();
9991 break;
9992 }
9993 else {
9994 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
9995 }
9996 }
9997 }
9998 }
9999 else if (token.type == TOKEN_COPEN || token.type == TOKEN_LITCOPEN) {
10000 var is_litdict = token.type == TOKEN_LITCOPEN;
10001 var savepos = this.reader.tell();
10002 var nodepos = token.pos;
10003 var token = this.tokenizer.get();
10004 var lambda = token.type == TOKEN_ARROW;
10005 if (!lambda && !(token.type == TOKEN_SQUOTE || token.type == TOKEN_DQUOTE)) {
10006 // if the token type is stirng, we cannot peek next token and we can
10007 // assume it's not lambda.
10008 var token2 = this.tokenizer.peek();
10009 var lambda = token2.type == TOKEN_ARROW || token2.type == TOKEN_COMMA;
10010 }
10011 // fallback to dict or {expr} if true
10012 var fallback = FALSE;
10013 if (lambda) {
10014 // lambda {token,...} {->...} {token->...}
10015 var node = Node(NODE_LAMBDA);
10016 node.pos = nodepos;
10017 node.rlist = [];
10018 var named = {};
10019 while (TRUE) {
10020 if (token.type == TOKEN_ARROW) {
10021 break;
10022 }
10023 else if (token.type == TOKEN_IDENTIFIER) {
10024 if (!isargname(token.value)) {
10025 throw Err(viml_printf("E125: Illegal argument: %s", token.value), token.pos);
10026 }
10027 else if (viml_has_key(named, token.value)) {
10028 throw Err(viml_printf("E853: Duplicate argument name: %s", token.value), token.pos);
10029 }
10030 named[token.value] = 1;
10031 var varnode = Node(NODE_IDENTIFIER);
10032 varnode.pos = token.pos;
10033 varnode.value = token.value;
10034 // XXX: Vim doesn't skip white space before comma. {a ,b -> ...} => E475
10035 if (iswhite(this.reader.p(0)) && this.tokenizer.peek().type == TOKEN_COMMA) {
10036 throw Err("E475: Invalid argument: White space is not allowed before comma", this.reader.getpos());
10037 }
10038 var token = this.tokenizer.get();
10039 viml_add(node.rlist, varnode);
10040 if (token.type == TOKEN_COMMA) {
10041 // XXX: Vim allows last comma. {a, b, -> ...} => OK
10042 var token = this.tokenizer.peek();
10043 if (token.type == TOKEN_ARROW) {
10044 this.tokenizer.get();
10045 break;
10046 }
10047 }
10048 else if (token.type == TOKEN_ARROW) {
10049 break;
10050 }
10051 else {
10052 throw Err(viml_printf("unexpected token: %s, type: %d", token.value, token.type), token.pos);
10053 }
10054 }
10055 else if (token.type == TOKEN_DOTDOTDOT) {
10056 var varnode = Node(NODE_IDENTIFIER);
10057 varnode.pos = token.pos;
10058 varnode.value = token.value;
10059 viml_add(node.rlist, varnode);
10060 var token = this.tokenizer.peek();
10061 if (token.type == TOKEN_ARROW) {
10062 this.tokenizer.get();
10063 break;
10064 }
10065 else {
10066 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
10067 }
10068 }
10069 else {
10070 var fallback = TRUE;
10071 break;
10072 }
10073 var token = this.tokenizer.get();
10074 }
10075 if (!fallback) {
10076 node.left = this.parse_expr1();
10077 var token = this.tokenizer.get();
10078 if (token.type != TOKEN_CCLOSE) {
10079 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
10080 }
10081 return node;
10082 }
10083 }
10084 // dict
10085 var node = Node(NODE_DICT);
10086 node.pos = nodepos;
10087 node.value = [];
10088 this.reader.seek_set(savepos);
10089 var token = this.tokenizer.peek();
10090 if (token.type == TOKEN_CCLOSE) {
10091 this.tokenizer.get();
10092 return node;
10093 }
10094 while (1) {
10095 var key = is_litdict ? this.tokenizer.parse_dict_literal_key() : this.parse_expr1();
10096 var token = this.tokenizer.get();
10097 if (token.type == TOKEN_CCLOSE) {
10098 if (!viml_empty(node.value)) {
10099 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
10100 }
10101 this.reader.seek_set(pos);
10102 var node = this.parse_identifier();
10103 break;
10104 }
10105 if (token.type != TOKEN_COLON) {
10106 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
10107 }
10108 var val = this.parse_expr1();
10109 viml_add(node.value, [key, val]);
10110 var token = this.tokenizer.get();
10111 if (token.type == TOKEN_COMMA) {
10112 if (this.tokenizer.peek().type == TOKEN_CCLOSE) {
10113 this.tokenizer.get();
10114 break;
10115 }
10116 }
10117 else if (token.type == TOKEN_CCLOSE) {
10118 break;
10119 }
10120 else {
10121 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
10122 }
10123 }
10124 return node;
10125 }
10126 else if (token.type == TOKEN_POPEN) {
10127 var node = this.parse_expr1();
10128 var token = this.tokenizer.get();
10129 if (token.type != TOKEN_PCLOSE) {
10130 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
10131 }
10132 }
10133 else if (token.type == TOKEN_OPTION) {
10134 var node = Node(NODE_OPTION);
10135 node.pos = token.pos;
10136 node.value = token.value;
10137 }
10138 else if (token.type == TOKEN_IDENTIFIER) {
10139 this.reader.seek_set(pos);
10140 var node = this.parse_identifier();
10141 }
10142 else if (FALSE && (token.type == TOKEN_COLON || token.type == TOKEN_SHARP)) {
10143 // XXX: no parse error but invalid expression
10144 this.reader.seek_set(pos);
10145 var node = this.parse_identifier();
10146 }
10147 else if (token.type == TOKEN_LT && viml_equalci(this.reader.peekn(4), "SID>")) {
10148 this.reader.seek_set(pos);
10149 var node = this.parse_identifier();
10150 }
10151 else if (token.type == TOKEN_IS || token.type == TOKEN_ISCS || token.type == TOKEN_ISNOT || token.type == TOKEN_ISNOTCS) {
10152 this.reader.seek_set(pos);
10153 var node = this.parse_identifier();
10154 }
10155 else if (token.type == TOKEN_ENV) {
10156 var node = Node(NODE_ENV);
10157 node.pos = token.pos;
10158 node.value = token.value;
10159 }
10160 else if (token.type == TOKEN_REG) {
10161 var node = Node(NODE_REG);
10162 node.pos = token.pos;
10163 node.value = token.value;
10164 }
10165 else {
10166 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
10167 }
10168 return node;
10169}
10170
10171// SUBSCRIPT or CONCAT
10172// dict "." [0-9A-Za-z_]+ => (subscript dict key)
10173// str "." expr6 => (concat str expr6)
10174ExprParser.prototype.parse_dot = function(token, left) {
10175 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) {
10176 return NIL;
10177 }
10178 if (!iswordc(this.reader.p(0))) {
10179 return NIL;
10180 }
10181 var pos = this.reader.getpos();
10182 var name = this.reader.read_word();
10183 if (isnamec(this.reader.p(0))) {
10184 // XXX: foo is str => ok, foo is obj => invalid expression
10185 // foo.s:bar or foo.bar#baz
10186 return NIL;
10187 }
10188 var node = Node(NODE_DOT);
10189 node.pos = token.pos;
10190 node.left = left;
10191 node.right = Node(NODE_IDENTIFIER);
10192 node.right.pos = pos;
10193 node.right.value = name;
10194 return node;
10195}
10196
10197// CONCAT
10198// str ".." expr6 => (concat str expr6)
10199ExprParser.prototype.parse_concat = function(token, left) {
10200 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) {
10201 return NIL;
10202 }
10203 if (!iswordc(this.reader.p(0))) {
10204 return NIL;
10205 }
10206 var pos = this.reader.getpos();
10207 var name = this.reader.read_word();
10208 if (isnamec(this.reader.p(0))) {
10209 // XXX: foo is str => ok, foo is obj => invalid expression
10210 // foo.s:bar or foo.bar#baz
10211 return NIL;
10212 }
10213 var node = Node(NODE_CONCAT);
10214 node.pos = token.pos;
10215 node.left = left;
10216 node.right = Node(NODE_IDENTIFIER);
10217 node.right.pos = pos;
10218 node.right.value = name;
10219 return node;
10220}
10221
10222ExprParser.prototype.parse_identifier = function() {
10223 this.reader.skip_white();
10224 var npos = this.reader.getpos();
10225 var curly_parts = this.parse_curly_parts();
10226 if (viml_len(curly_parts) == 1 && curly_parts[0].type == NODE_CURLYNAMEPART) {
10227 var node = Node(NODE_IDENTIFIER);
10228 node.pos = npos;
10229 node.value = curly_parts[0].value;
10230 return node;
10231 }
10232 else {
10233 var node = Node(NODE_CURLYNAME);
10234 node.pos = npos;
10235 node.value = curly_parts;
10236 return node;
10237 }
10238}
10239
10240ExprParser.prototype.parse_curly_parts = function() {
10241 var curly_parts = [];
10242 var c = this.reader.peek();
10243 var pos = this.reader.getpos();
10244 if (c == "<" && viml_equalci(this.reader.peekn(5), "<SID>")) {
10245 var name = this.reader.getn(5);
10246 var node = Node(NODE_CURLYNAMEPART);
10247 node.curly = FALSE;
10248 // Keep backword compatibility for the curly attribute
10249 node.pos = pos;
10250 node.value = name;
10251 viml_add(curly_parts, node);
10252 }
10253 while (TRUE) {
10254 var c = this.reader.peek();
10255 if (isnamec(c)) {
10256 var pos = this.reader.getpos();
10257 var name = this.reader.read_name();
10258 var node = Node(NODE_CURLYNAMEPART);
10259 node.curly = FALSE;
10260 // Keep backword compatibility for the curly attribute
10261 node.pos = pos;
10262 node.value = name;
10263 viml_add(curly_parts, node);
10264 }
10265 else if (c == "{") {
10266 this.reader.get();
10267 var pos = this.reader.getpos();
10268 var node = Node(NODE_CURLYNAMEEXPR);
10269 node.curly = TRUE;
10270 // Keep backword compatibility for the curly attribute
10271 node.pos = pos;
10272 node.value = this.parse_expr1();
10273 viml_add(curly_parts, node);
10274 this.reader.skip_white();
10275 var c = this.reader.p(0);
10276 if (c != "}") {
10277 throw Err(viml_printf("unexpected token: %s", c), this.reader.getpos());
10278 }
10279 this.reader.seek_cur(1);
10280 }
10281 else {
10282 break;
10283 }
10284 }
10285 return curly_parts;
10286}
10287
10288function LvalueParser() { ExprParser.apply(this, arguments); this.__init__.apply(this, arguments); }
10289LvalueParser.prototype = Object.create(ExprParser.prototype);
10290LvalueParser.prototype.parse = function() {
10291 return this.parse_lv8();
10292}
10293
10294// expr8: expr8[expr1]
10295// expr8[expr1 : expr1]
10296// expr8.name
10297LvalueParser.prototype.parse_lv8 = function() {
10298 var left = this.parse_lv9();
10299 while (TRUE) {
10300 var pos = this.reader.tell();
10301 var c = this.reader.peek();
10302 var token = this.tokenizer.get();
10303 if (!iswhite(c) && token.type == TOKEN_SQOPEN) {
10304 var npos = token.pos;
10305 var node = Node(-1);
10306 if (this.tokenizer.peek().type == TOKEN_COLON) {
10307 this.tokenizer.get();
10308 var node = Node(NODE_SLICE);
10309 node.pos = npos;
10310 node.left = left;
10311 node.rlist = [NIL, NIL];
10312 var token = this.tokenizer.peek();
10313 if (token.type != TOKEN_SQCLOSE) {
10314 node.rlist[1] = this.parse_expr1();
10315 }
10316 var token = this.tokenizer.get();
10317 if (token.type != TOKEN_SQCLOSE) {
10318 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
10319 }
10320 }
10321 else {
10322 var right = this.parse_expr1();
10323 if (this.tokenizer.peek().type == TOKEN_COLON) {
10324 this.tokenizer.get();
10325 var node = Node(NODE_SLICE);
10326 node.pos = npos;
10327 node.left = left;
10328 node.rlist = [right, NIL];
10329 var token = this.tokenizer.peek();
10330 if (token.type != TOKEN_SQCLOSE) {
10331 node.rlist[1] = this.parse_expr1();
10332 }
10333 var token = this.tokenizer.get();
10334 if (token.type != TOKEN_SQCLOSE) {
10335 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
10336 }
10337 }
10338 else {
10339 var node = Node(NODE_SUBSCRIPT);
10340 node.pos = npos;
10341 node.left = left;
10342 node.right = right;
10343 var token = this.tokenizer.get();
10344 if (token.type != TOKEN_SQCLOSE) {
10345 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
10346 }
10347 }
10348 }
10349 var left = node;
10350 delete node;
10351 }
10352 else if (!iswhite(c) && token.type == TOKEN_DOT) {
10353 var node = this.parse_dot(token, left);
10354 if (node === NIL) {
10355 this.reader.seek_set(pos);
10356 break;
10357 }
10358 var left = node;
10359 delete node;
10360 }
10361 else {
10362 this.reader.seek_set(pos);
10363 break;
10364 }
10365 }
10366 return left;
10367}
10368
10369// expr9: &option
10370// variable
10371// var{ria}ble
10372// $VAR
10373// @r
10374LvalueParser.prototype.parse_lv9 = function() {
10375 var pos = this.reader.tell();
10376 var token = this.tokenizer.get();
10377 var node = Node(-1);
10378 if (token.type == TOKEN_COPEN) {
10379 this.reader.seek_set(pos);
10380 var node = this.parse_identifier();
10381 }
10382 else if (token.type == TOKEN_OPTION) {
10383 var node = Node(NODE_OPTION);
10384 node.pos = token.pos;
10385 node.value = token.value;
10386 }
10387 else if (token.type == TOKEN_IDENTIFIER) {
10388 this.reader.seek_set(pos);
10389 var node = this.parse_identifier();
10390 }
10391 else if (token.type == TOKEN_LT && viml_equalci(this.reader.peekn(4), "SID>")) {
10392 this.reader.seek_set(pos);
10393 var node = this.parse_identifier();
10394 }
10395 else if (token.type == TOKEN_ENV) {
10396 var node = Node(NODE_ENV);
10397 node.pos = token.pos;
10398 node.value = token.value;
10399 }
10400 else if (token.type == TOKEN_REG) {
10401 var node = Node(NODE_REG);
10402 node.pos = token.pos;
10403 node.pos = token.pos;
10404 node.value = token.value;
10405 }
10406 else {
10407 throw Err(viml_printf("unexpected token: %s", token.value), token.pos);
10408 }
10409 return node;
10410}
10411
10412function StringReader() { this.__init__.apply(this, arguments); }
10413StringReader.prototype.__init__ = function(lines) {
10414 this.buf = [];
10415 this.pos = [];
10416 var lnum = 0;
10417 var offset = 0;
10418 while (lnum < viml_len(lines)) {
10419 var col = 0;
10420 var __c7 = viml_split(lines[lnum], "\\zs");
10421 for (var __i7 = 0; __i7 < __c7.length; ++__i7) {
10422 var c = __c7[__i7];
10423 viml_add(this.buf, c);
10424 viml_add(this.pos, [lnum + 1, col + 1, offset]);
10425 col += viml_len(c);
10426 offset += viml_len(c);
10427 }
10428 while (lnum + 1 < viml_len(lines) && viml_eqregh(lines[lnum + 1], "^\\s*\\\\")) {
10429 var skip = TRUE;
10430 var col = 0;
10431 var __c8 = viml_split(lines[lnum + 1], "\\zs");
10432 for (var __i8 = 0; __i8 < __c8.length; ++__i8) {
10433 var c = __c8[__i8];
10434 if (skip) {
10435 if (c == "\\") {
10436 var skip = FALSE;
10437 }
10438 }
10439 else {
10440 viml_add(this.buf, c);
10441 viml_add(this.pos, [lnum + 2, col + 1, offset]);
10442 }
10443 col += viml_len(c);
10444 offset += viml_len(c);
10445 }
10446 lnum += 1;
10447 offset += 1;
10448 }
10449 viml_add(this.buf, "<EOL>");
10450 viml_add(this.pos, [lnum + 1, col + 1, offset]);
10451 lnum += 1;
10452 offset += 1;
10453 }
10454 // for <EOF>
10455 viml_add(this.pos, [lnum + 1, 0, offset]);
10456 this.i = 0;
10457}
10458
10459StringReader.prototype.eof = function() {
10460 return this.i >= viml_len(this.buf);
10461}
10462
10463StringReader.prototype.tell = function() {
10464 return this.i;
10465}
10466
10467StringReader.prototype.seek_set = function(i) {
10468 this.i = i;
10469}
10470
10471StringReader.prototype.seek_cur = function(i) {
10472 this.i = this.i + i;
10473}
10474
10475StringReader.prototype.seek_end = function(i) {
10476 this.i = viml_len(this.buf) + i;
10477}
10478
10479StringReader.prototype.p = function(i) {
10480 if (this.i >= viml_len(this.buf)) {
10481 return "<EOF>";
10482 }
10483 return this.buf[this.i + i];
10484}
10485
10486StringReader.prototype.peek = function() {
10487 if (this.i >= viml_len(this.buf)) {
10488 return "<EOF>";
10489 }
10490 return this.buf[this.i];
10491}
10492
10493StringReader.prototype.get = function() {
10494 if (this.i >= viml_len(this.buf)) {
10495 return "<EOF>";
10496 }
10497 this.i += 1;
10498 return this.buf[this.i - 1];
10499}
10500
10501StringReader.prototype.peekn = function(n) {
10502 var pos = this.tell();
10503 var r = this.getn(n);
10504 this.seek_set(pos);
10505 return r;
10506}
10507
10508StringReader.prototype.getn = function(n) {
10509 var r = "";
10510 var j = 0;
10511 while (this.i < viml_len(this.buf) && (n < 0 || j < n)) {
10512 var c = this.buf[this.i];
10513 if (c == "<EOL>") {
10514 break;
10515 }
10516 r += c;
10517 this.i += 1;
10518 j += 1;
10519 }
10520 return r;
10521}
10522
10523StringReader.prototype.peekline = function() {
10524 return this.peekn(-1);
10525}
10526
10527StringReader.prototype.readline = function() {
10528 var r = this.getn(-1);
10529 this.get();
10530 return r;
10531}
10532
10533StringReader.prototype.getstr = function(begin, end) {
10534 var r = "";
10535 var __c9 = viml_range(begin.i, end.i - 1);
10536 for (var __i9 = 0; __i9 < __c9.length; ++__i9) {
10537 var i = __c9[__i9];
10538 if (i >= viml_len(this.buf)) {
10539 break;
10540 }
10541 var c = this.buf[i];
10542 if (c == "<EOL>") {
10543 var c = "\n";
10544 }
10545 r += c;
10546 }
10547 return r;
10548}
10549
10550StringReader.prototype.getpos = function() {
10551 var __tmp = this.pos[this.i];
10552 var lnum = __tmp[0];
10553 var col = __tmp[1];
10554 var offset = __tmp[2];
10555 return {"i":this.i, "lnum":lnum, "col":col, "offset":offset};
10556}
10557
10558StringReader.prototype.setpos = function(pos) {
10559 this.i = pos.i;
10560}
10561
10562StringReader.prototype.read_alpha = function() {
10563 var r = "";
10564 while (isalpha(this.peekn(1))) {
10565 r += this.getn(1);
10566 }
10567 return r;
10568}
10569
10570StringReader.prototype.read_alnum = function() {
10571 var r = "";
10572 while (isalnum(this.peekn(1))) {
10573 r += this.getn(1);
10574 }
10575 return r;
10576}
10577
10578StringReader.prototype.read_digit = function() {
10579 var r = "";
10580 while (isdigit(this.peekn(1))) {
10581 r += this.getn(1);
10582 }
10583 return r;
10584}
10585
10586StringReader.prototype.read_odigit = function() {
10587 var r = "";
10588 while (isodigit(this.peekn(1))) {
10589 r += this.getn(1);
10590 }
10591 return r;
10592}
10593
10594StringReader.prototype.read_blob = function() {
10595 var r = "";
10596 while (1) {
10597 var s = this.peekn(2);
10598 if (viml_eqregh(s, "^[0-9A-Fa-f][0-9A-Fa-f]$")) {
10599 r += this.getn(2);
10600 }
10601 else if (viml_eqregh(s, "^\\.[0-9A-Fa-f]$")) {
10602 r += this.getn(1);
10603 }
10604 else if (viml_eqregh(s, "^[0-9A-Fa-f][^0-9A-Fa-f]$")) {
10605 throw Err("E973: Blob literal should have an even number of hex characters:" + s, this.getpos());
10606 }
10607 else {
10608 break;
10609 }
10610 }
10611 return r;
10612}
10613
10614StringReader.prototype.read_xdigit = function() {
10615 var r = "";
10616 while (isxdigit(this.peekn(1))) {
10617 r += this.getn(1);
10618 }
10619 return r;
10620}
10621
10622StringReader.prototype.read_bdigit = function() {
10623 var r = "";
10624 while (this.peekn(1) == "0" || this.peekn(1) == "1") {
10625 r += this.getn(1);
10626 }
10627 return r;
10628}
10629
10630StringReader.prototype.read_integer = function() {
10631 var r = "";
10632 var c = this.peekn(1);
10633 if (c == "-" || c == "+") {
10634 var r = this.getn(1);
10635 }
10636 return r + this.read_digit();
10637}
10638
10639StringReader.prototype.read_word = function() {
10640 var r = "";
10641 while (iswordc(this.peekn(1))) {
10642 r += this.getn(1);
10643 }
10644 return r;
10645}
10646
10647StringReader.prototype.read_white = function() {
10648 var r = "";
10649 while (iswhite(this.peekn(1))) {
10650 r += this.getn(1);
10651 }
10652 return r;
10653}
10654
10655StringReader.prototype.read_nonwhite = function() {
10656 var r = "";
10657 var ch = this.peekn(1);
10658 while (!iswhite(ch) && ch != "") {
10659 r += this.getn(1);
10660 var ch = this.peekn(1);
10661 }
10662 return r;
10663}
10664
10665StringReader.prototype.read_name = function() {
10666 var r = "";
10667 while (isnamec(this.peekn(1))) {
10668 r += this.getn(1);
10669 }
10670 return r;
10671}
10672
10673StringReader.prototype.skip_white = function() {
10674 while (iswhite(this.peekn(1))) {
10675 this.seek_cur(1);
10676 }
10677}
10678
10679StringReader.prototype.skip_white_and_colon = function() {
10680 while (TRUE) {
10681 var c = this.peekn(1);
10682 if (!iswhite(c) && c != ":") {
10683 break;
10684 }
10685 this.seek_cur(1);
10686 }
10687}
10688
10689function Compiler() { this.__init__.apply(this, arguments); }
10690Compiler.prototype.__init__ = function() {
10691 this.indent = [""];
10692 this.lines = [];
10693}
10694
10695Compiler.prototype.out = function() {
10696 var a000 = Array.prototype.slice.call(arguments, 0);
10697 if (viml_len(a000) == 1) {
10698 if (a000[0][0] == ")") {
10699 this.lines[this.lines.length - 1] += a000[0];
10700 }
10701 else {
10702 viml_add(this.lines, this.indent[0] + a000[0]);
10703 }
10704 }
10705 else {
10706 viml_add(this.lines, this.indent[0] + viml_printf.apply(null, a000));
10707 }
10708}
10709
10710Compiler.prototype.incindent = function(s) {
10711 viml_insert(this.indent, this.indent[0] + s);
10712}
10713
10714Compiler.prototype.decindent = function() {
10715 viml_remove(this.indent, 0);
10716}
10717
10718Compiler.prototype.compile = function(node) {
10719 if (node.type == NODE_TOPLEVEL) {
10720 return this.compile_toplevel(node);
10721 }
10722 else if (node.type == NODE_COMMENT) {
10723 this.compile_comment(node);
10724 return NIL;
10725 }
10726 else if (node.type == NODE_EXCMD) {
10727 this.compile_excmd(node);
10728 return NIL;
10729 }
10730 else if (node.type == NODE_FUNCTION) {
10731 this.compile_function(node);
10732 return NIL;
10733 }
10734 else if (node.type == NODE_DELFUNCTION) {
10735 this.compile_delfunction(node);
10736 return NIL;
10737 }
10738 else if (node.type == NODE_RETURN) {
10739 this.compile_return(node);
10740 return NIL;
10741 }
10742 else if (node.type == NODE_EXCALL) {
10743 this.compile_excall(node);
10744 return NIL;
10745 }
10746 else if (node.type == NODE_EVAL) {
10747 this.compile_eval(node);
10748 return NIL;
10749 }
10750 else if (node.type == NODE_LET) {
10751 this.compile_let(node);
10752 return NIL;
10753 }
10754 else if (node.type == NODE_CONST) {
10755 this.compile_const(node);
10756 return NIL;
10757 }
10758 else if (node.type == NODE_UNLET) {
10759 this.compile_unlet(node);
10760 return NIL;
10761 }
10762 else if (node.type == NODE_LOCKVAR) {
10763 this.compile_lockvar(node);
10764 return NIL;
10765 }
10766 else if (node.type == NODE_UNLOCKVAR) {
10767 this.compile_unlockvar(node);
10768 return NIL;
10769 }
10770 else if (node.type == NODE_IF) {
10771 this.compile_if(node);
10772 return NIL;
10773 }
10774 else if (node.type == NODE_WHILE) {
10775 this.compile_while(node);
10776 return NIL;
10777 }
10778 else if (node.type == NODE_FOR) {
10779 this.compile_for(node);
10780 return NIL;
10781 }
10782 else if (node.type == NODE_CONTINUE) {
10783 this.compile_continue(node);
10784 return NIL;
10785 }
10786 else if (node.type == NODE_BREAK) {
10787 this.compile_break(node);
10788 return NIL;
10789 }
10790 else if (node.type == NODE_TRY) {
10791 this.compile_try(node);
10792 return NIL;
10793 }
10794 else if (node.type == NODE_THROW) {
10795 this.compile_throw(node);
10796 return NIL;
10797 }
10798 else if (node.type == NODE_ECHO) {
10799 this.compile_echo(node);
10800 return NIL;
10801 }
10802 else if (node.type == NODE_ECHON) {
10803 this.compile_echon(node);
10804 return NIL;
10805 }
10806 else if (node.type == NODE_ECHOHL) {
10807 this.compile_echohl(node);
10808 return NIL;
10809 }
10810 else if (node.type == NODE_ECHOMSG) {
10811 this.compile_echomsg(node);
10812 return NIL;
10813 }
10814 else if (node.type == NODE_ECHOERR) {
10815 this.compile_echoerr(node);
10816 return NIL;
10817 }
10818 else if (node.type == NODE_EXECUTE) {
10819 this.compile_execute(node);
10820 return NIL;
10821 }
10822 else if (node.type == NODE_TERNARY) {
10823 return this.compile_ternary(node);
10824 }
10825 else if (node.type == NODE_OR) {
10826 return this.compile_or(node);
10827 }
10828 else if (node.type == NODE_AND) {
10829 return this.compile_and(node);
10830 }
10831 else if (node.type == NODE_EQUAL) {
10832 return this.compile_equal(node);
10833 }
10834 else if (node.type == NODE_EQUALCI) {
10835 return this.compile_equalci(node);
10836 }
10837 else if (node.type == NODE_EQUALCS) {
10838 return this.compile_equalcs(node);
10839 }
10840 else if (node.type == NODE_NEQUAL) {
10841 return this.compile_nequal(node);
10842 }
10843 else if (node.type == NODE_NEQUALCI) {
10844 return this.compile_nequalci(node);
10845 }
10846 else if (node.type == NODE_NEQUALCS) {
10847 return this.compile_nequalcs(node);
10848 }
10849 else if (node.type == NODE_GREATER) {
10850 return this.compile_greater(node);
10851 }
10852 else if (node.type == NODE_GREATERCI) {
10853 return this.compile_greaterci(node);
10854 }
10855 else if (node.type == NODE_GREATERCS) {
10856 return this.compile_greatercs(node);
10857 }
10858 else if (node.type == NODE_GEQUAL) {
10859 return this.compile_gequal(node);
10860 }
10861 else if (node.type == NODE_GEQUALCI) {
10862 return this.compile_gequalci(node);
10863 }
10864 else if (node.type == NODE_GEQUALCS) {
10865 return this.compile_gequalcs(node);
10866 }
10867 else if (node.type == NODE_SMALLER) {
10868 return this.compile_smaller(node);
10869 }
10870 else if (node.type == NODE_SMALLERCI) {
10871 return this.compile_smallerci(node);
10872 }
10873 else if (node.type == NODE_SMALLERCS) {
10874 return this.compile_smallercs(node);
10875 }
10876 else if (node.type == NODE_SEQUAL) {
10877 return this.compile_sequal(node);
10878 }
10879 else if (node.type == NODE_SEQUALCI) {
10880 return this.compile_sequalci(node);
10881 }
10882 else if (node.type == NODE_SEQUALCS) {
10883 return this.compile_sequalcs(node);
10884 }
10885 else if (node.type == NODE_MATCH) {
10886 return this.compile_match(node);
10887 }
10888 else if (node.type == NODE_MATCHCI) {
10889 return this.compile_matchci(node);
10890 }
10891 else if (node.type == NODE_MATCHCS) {
10892 return this.compile_matchcs(node);
10893 }
10894 else if (node.type == NODE_NOMATCH) {
10895 return this.compile_nomatch(node);
10896 }
10897 else if (node.type == NODE_NOMATCHCI) {
10898 return this.compile_nomatchci(node);
10899 }
10900 else if (node.type == NODE_NOMATCHCS) {
10901 return this.compile_nomatchcs(node);
10902 }
10903 else if (node.type == NODE_IS) {
10904 return this.compile_is(node);
10905 }
10906 else if (node.type == NODE_ISCI) {
10907 return this.compile_isci(node);
10908 }
10909 else if (node.type == NODE_ISCS) {
10910 return this.compile_iscs(node);
10911 }
10912 else if (node.type == NODE_ISNOT) {
10913 return this.compile_isnot(node);
10914 }
10915 else if (node.type == NODE_ISNOTCI) {
10916 return this.compile_isnotci(node);
10917 }
10918 else if (node.type == NODE_ISNOTCS) {
10919 return this.compile_isnotcs(node);
10920 }
10921 else if (node.type == NODE_ADD) {
10922 return this.compile_add(node);
10923 }
10924 else if (node.type == NODE_SUBTRACT) {
10925 return this.compile_subtract(node);
10926 }
10927 else if (node.type == NODE_CONCAT) {
10928 return this.compile_concat(node);
10929 }
10930 else if (node.type == NODE_MULTIPLY) {
10931 return this.compile_multiply(node);
10932 }
10933 else if (node.type == NODE_DIVIDE) {
10934 return this.compile_divide(node);
10935 }
10936 else if (node.type == NODE_REMAINDER) {
10937 return this.compile_remainder(node);
10938 }
10939 else if (node.type == NODE_NOT) {
10940 return this.compile_not(node);
10941 }
10942 else if (node.type == NODE_PLUS) {
10943 return this.compile_plus(node);
10944 }
10945 else if (node.type == NODE_MINUS) {
10946 return this.compile_minus(node);
10947 }
10948 else if (node.type == NODE_SUBSCRIPT) {
10949 return this.compile_subscript(node);
10950 }
10951 else if (node.type == NODE_SLICE) {
10952 return this.compile_slice(node);
10953 }
10954 else if (node.type == NODE_DOT) {
10955 return this.compile_dot(node);
10956 }
10957 else if (node.type == NODE_METHOD) {
10958 return this.compile_method(node);
10959 }
10960 else if (node.type == NODE_CALL) {
10961 return this.compile_call(node);
10962 }
10963 else if (node.type == NODE_NUMBER) {
10964 return this.compile_number(node);
10965 }
10966 else if (node.type == NODE_BLOB) {
10967 return this.compile_blob(node);
10968 }
10969 else if (node.type == NODE_STRING) {
10970 return this.compile_string(node);
10971 }
10972 else if (node.type == NODE_LIST) {
10973 return this.compile_list(node);
10974 }
10975 else if (node.type == NODE_DICT) {
10976 return this.compile_dict(node);
10977 }
10978 else if (node.type == NODE_OPTION) {
10979 return this.compile_option(node);
10980 }
10981 else if (node.type == NODE_IDENTIFIER) {
10982 return this.compile_identifier(node);
10983 }
10984 else if (node.type == NODE_CURLYNAME) {
10985 return this.compile_curlyname(node);
10986 }
10987 else if (node.type == NODE_ENV) {
10988 return this.compile_env(node);
10989 }
10990 else if (node.type == NODE_REG) {
10991 return this.compile_reg(node);
10992 }
10993 else if (node.type == NODE_CURLYNAMEPART) {
10994 return this.compile_curlynamepart(node);
10995 }
10996 else if (node.type == NODE_CURLYNAMEEXPR) {
10997 return this.compile_curlynameexpr(node);
10998 }
10999 else if (node.type == NODE_LAMBDA) {
11000 return this.compile_lambda(node);
11001 }
11002 else if (node.type == NODE_HEREDOC) {
11003 return this.compile_heredoc(node);
11004 }
11005 else {
11006 throw viml_printf("Compiler: unknown node: %s", viml_string(node));
11007 }
11008 return NIL;
11009}
11010
11011Compiler.prototype.compile_body = function(body) {
11012 var __c10 = body;
11013 for (var __i10 = 0; __i10 < __c10.length; ++__i10) {
11014 var node = __c10[__i10];
11015 this.compile(node);
11016 }
11017}
11018
11019Compiler.prototype.compile_toplevel = function(node) {
11020 this.compile_body(node.body);
11021 return this.lines;
11022}
11023
11024Compiler.prototype.compile_comment = function(node) {
11025 this.out(";%s", node.str);
11026}
11027
11028Compiler.prototype.compile_excmd = function(node) {
11029 this.out("(excmd \"%s\")", viml_escape(node.str, "\\\""));
11030}
11031
11032Compiler.prototype.compile_function = function(node) {
11033 var left = this.compile(node.left);
11034 var rlist = node.rlist.map((function(vval) { return this.compile(vval); }).bind(this));
11035 var default_args = node.default_args.map((function(vval) { return this.compile(vval); }).bind(this));
11036 if (!viml_empty(rlist)) {
11037 var remaining = FALSE;
11038 if (rlist[rlist.length - 1] == "...") {
11039 viml_remove(rlist, -1);
11040 var remaining = TRUE;
11041 }
11042 var __c11 = viml_range(viml_len(rlist));
11043 for (var __i11 = 0; __i11 < __c11.length; ++__i11) {
11044 var i = __c11[__i11];
11045 if (i < viml_len(rlist) - viml_len(default_args)) {
11046 left += viml_printf(" %s", rlist[i]);
11047 }
11048 else {
11049 left += viml_printf(" (%s %s)", rlist[i], default_args[i + viml_len(default_args) - viml_len(rlist)]);
11050 }
11051 }
11052 if (remaining) {
11053 left += " . ...";
11054 }
11055 }
11056 this.out("(function (%s)", left);
11057 this.incindent(" ");
11058 this.compile_body(node.body);
11059 this.out(")");
11060 this.decindent();
11061}
11062
11063Compiler.prototype.compile_delfunction = function(node) {
11064 this.out("(delfunction %s)", this.compile(node.left));
11065}
11066
11067Compiler.prototype.compile_return = function(node) {
11068 if (node.left === NIL) {
11069 this.out("(return)");
11070 }
11071 else {
11072 this.out("(return %s)", this.compile(node.left));
11073 }
11074}
11075
11076Compiler.prototype.compile_excall = function(node) {
11077 this.out("(call %s)", this.compile(node.left));
11078}
11079
11080Compiler.prototype.compile_eval = function(node) {
11081 this.out("(eval %s)", this.compile(node.left));
11082}
11083
11084Compiler.prototype.compile_let = function(node) {
11085 var left = "";
11086 if (node.left !== NIL) {
11087 var left = this.compile(node.left);
11088 }
11089 else {
11090 var left = viml_join(node.list.map((function(vval) { return this.compile(vval); }).bind(this)), " ");
11091 if (node.rest !== NIL) {
11092 left += " . " + this.compile(node.rest);
11093 }
11094 var left = "(" + left + ")";
11095 }
11096 var right = this.compile(node.right);
11097 this.out("(let %s %s %s)", node.op, left, right);
11098}
11099
11100// TODO: merge with s:Compiler.compile_let() ?
11101Compiler.prototype.compile_const = function(node) {
11102 var left = "";
11103 if (node.left !== NIL) {
11104 var left = this.compile(node.left);
11105 }
11106 else {
11107 var left = viml_join(node.list.map((function(vval) { return this.compile(vval); }).bind(this)), " ");
11108 if (node.rest !== NIL) {
11109 left += " . " + this.compile(node.rest);
11110 }
11111 var left = "(" + left + ")";
11112 }
11113 var right = this.compile(node.right);
11114 this.out("(const %s %s %s)", node.op, left, right);
11115}
11116
11117Compiler.prototype.compile_unlet = function(node) {
11118 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
11119 this.out("(unlet %s)", viml_join(list, " "));
11120}
11121
11122Compiler.prototype.compile_lockvar = function(node) {
11123 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
11124 if (node.depth === NIL) {
11125 this.out("(lockvar %s)", viml_join(list, " "));
11126 }
11127 else {
11128 this.out("(lockvar %s %s)", node.depth, viml_join(list, " "));
11129 }
11130}
11131
11132Compiler.prototype.compile_unlockvar = function(node) {
11133 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
11134 if (node.depth === NIL) {
11135 this.out("(unlockvar %s)", viml_join(list, " "));
11136 }
11137 else {
11138 this.out("(unlockvar %s %s)", node.depth, viml_join(list, " "));
11139 }
11140}
11141
11142Compiler.prototype.compile_if = function(node) {
11143 this.out("(if %s", this.compile(node.cond));
11144 this.incindent(" ");
11145 this.compile_body(node.body);
11146 this.decindent();
11147 var __c12 = node.elseif;
11148 for (var __i12 = 0; __i12 < __c12.length; ++__i12) {
11149 var enode = __c12[__i12];
11150 this.out(" elseif %s", this.compile(enode.cond));
11151 this.incindent(" ");
11152 this.compile_body(enode.body);
11153 this.decindent();
11154 }
11155 if (node._else !== NIL) {
11156 this.out(" else");
11157 this.incindent(" ");
11158 this.compile_body(node._else.body);
11159 this.decindent();
11160 }
11161 this.incindent(" ");
11162 this.out(")");
11163 this.decindent();
11164}
11165
11166Compiler.prototype.compile_while = function(node) {
11167 this.out("(while %s", this.compile(node.cond));
11168 this.incindent(" ");
11169 this.compile_body(node.body);
11170 this.out(")");
11171 this.decindent();
11172}
11173
11174Compiler.prototype.compile_for = function(node) {
11175 var left = "";
11176 if (node.left !== NIL) {
11177 var left = this.compile(node.left);
11178 }
11179 else {
11180 var left = viml_join(node.list.map((function(vval) { return this.compile(vval); }).bind(this)), " ");
11181 if (node.rest !== NIL) {
11182 left += " . " + this.compile(node.rest);
11183 }
11184 var left = "(" + left + ")";
11185 }
11186 var right = this.compile(node.right);
11187 this.out("(for %s %s", left, right);
11188 this.incindent(" ");
11189 this.compile_body(node.body);
11190 this.out(")");
11191 this.decindent();
11192}
11193
11194Compiler.prototype.compile_continue = function(node) {
11195 this.out("(continue)");
11196}
11197
11198Compiler.prototype.compile_break = function(node) {
11199 this.out("(break)");
11200}
11201
11202Compiler.prototype.compile_try = function(node) {
11203 this.out("(try");
11204 this.incindent(" ");
11205 this.compile_body(node.body);
11206 var __c13 = node.catch;
11207 for (var __i13 = 0; __i13 < __c13.length; ++__i13) {
11208 var cnode = __c13[__i13];
11209 if (cnode.pattern !== NIL) {
11210 this.decindent();
11211 this.out(" catch /%s/", cnode.pattern);
11212 this.incindent(" ");
11213 this.compile_body(cnode.body);
11214 }
11215 else {
11216 this.decindent();
11217 this.out(" catch");
11218 this.incindent(" ");
11219 this.compile_body(cnode.body);
11220 }
11221 }
11222 if (node._finally !== NIL) {
11223 this.decindent();
11224 this.out(" finally");
11225 this.incindent(" ");
11226 this.compile_body(node._finally.body);
11227 }
11228 this.out(")");
11229 this.decindent();
11230}
11231
11232Compiler.prototype.compile_throw = function(node) {
11233 this.out("(throw %s)", this.compile(node.left));
11234}
11235
11236Compiler.prototype.compile_echo = function(node) {
11237 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
11238 this.out("(echo %s)", viml_join(list, " "));
11239}
11240
11241Compiler.prototype.compile_echon = function(node) {
11242 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
11243 this.out("(echon %s)", viml_join(list, " "));
11244}
11245
11246Compiler.prototype.compile_echohl = function(node) {
11247 this.out("(echohl \"%s\")", viml_escape(node.str, "\\\""));
11248}
11249
11250Compiler.prototype.compile_echomsg = function(node) {
11251 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
11252 this.out("(echomsg %s)", viml_join(list, " "));
11253}
11254
11255Compiler.prototype.compile_echoerr = function(node) {
11256 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
11257 this.out("(echoerr %s)", viml_join(list, " "));
11258}
11259
11260Compiler.prototype.compile_execute = function(node) {
11261 var list = node.list.map((function(vval) { return this.compile(vval); }).bind(this));
11262 this.out("(execute %s)", viml_join(list, " "));
11263}
11264
11265Compiler.prototype.compile_ternary = function(node) {
11266 return viml_printf("(?: %s %s %s)", this.compile(node.cond), this.compile(node.left), this.compile(node.right));
11267}
11268
11269Compiler.prototype.compile_or = function(node) {
11270 return viml_printf("(|| %s %s)", this.compile(node.left), this.compile(node.right));
11271}
11272
11273Compiler.prototype.compile_and = function(node) {
11274 return viml_printf("(&& %s %s)", this.compile(node.left), this.compile(node.right));
11275}
11276
11277Compiler.prototype.compile_equal = function(node) {
11278 return viml_printf("(== %s %s)", this.compile(node.left), this.compile(node.right));
11279}
11280
11281Compiler.prototype.compile_equalci = function(node) {
11282 return viml_printf("(==? %s %s)", this.compile(node.left), this.compile(node.right));
11283}
11284
11285Compiler.prototype.compile_equalcs = function(node) {
11286 return viml_printf("(==# %s %s)", this.compile(node.left), this.compile(node.right));
11287}
11288
11289Compiler.prototype.compile_nequal = function(node) {
11290 return viml_printf("(!= %s %s)", this.compile(node.left), this.compile(node.right));
11291}
11292
11293Compiler.prototype.compile_nequalci = function(node) {
11294 return viml_printf("(!=? %s %s)", this.compile(node.left), this.compile(node.right));
11295}
11296
11297Compiler.prototype.compile_nequalcs = function(node) {
11298 return viml_printf("(!=# %s %s)", this.compile(node.left), this.compile(node.right));
11299}
11300
11301Compiler.prototype.compile_greater = function(node) {
11302 return viml_printf("(> %s %s)", this.compile(node.left), this.compile(node.right));
11303}
11304
11305Compiler.prototype.compile_greaterci = function(node) {
11306 return viml_printf("(>? %s %s)", this.compile(node.left), this.compile(node.right));
11307}
11308
11309Compiler.prototype.compile_greatercs = function(node) {
11310 return viml_printf("(># %s %s)", this.compile(node.left), this.compile(node.right));
11311}
11312
11313Compiler.prototype.compile_gequal = function(node) {
11314 return viml_printf("(>= %s %s)", this.compile(node.left), this.compile(node.right));
11315}
11316
11317Compiler.prototype.compile_gequalci = function(node) {
11318 return viml_printf("(>=? %s %s)", this.compile(node.left), this.compile(node.right));
11319}
11320
11321Compiler.prototype.compile_gequalcs = function(node) {
11322 return viml_printf("(>=# %s %s)", this.compile(node.left), this.compile(node.right));
11323}
11324
11325Compiler.prototype.compile_smaller = function(node) {
11326 return viml_printf("(< %s %s)", this.compile(node.left), this.compile(node.right));
11327}
11328
11329Compiler.prototype.compile_smallerci = function(node) {
11330 return viml_printf("(<? %s %s)", this.compile(node.left), this.compile(node.right));
11331}
11332
11333Compiler.prototype.compile_smallercs = function(node) {
11334 return viml_printf("(<# %s %s)", this.compile(node.left), this.compile(node.right));
11335}
11336
11337Compiler.prototype.compile_sequal = function(node) {
11338 return viml_printf("(<= %s %s)", this.compile(node.left), this.compile(node.right));
11339}
11340
11341Compiler.prototype.compile_sequalci = function(node) {
11342 return viml_printf("(<=? %s %s)", this.compile(node.left), this.compile(node.right));
11343}
11344
11345Compiler.prototype.compile_sequalcs = function(node) {
11346 return viml_printf("(<=# %s %s)", this.compile(node.left), this.compile(node.right));
11347}
11348
11349Compiler.prototype.compile_match = function(node) {
11350 return viml_printf("(=~ %s %s)", this.compile(node.left), this.compile(node.right));
11351}
11352
11353Compiler.prototype.compile_matchci = function(node) {
11354 return viml_printf("(=~? %s %s)", this.compile(node.left), this.compile(node.right));
11355}
11356
11357Compiler.prototype.compile_matchcs = function(node) {
11358 return viml_printf("(=~# %s %s)", this.compile(node.left), this.compile(node.right));
11359}
11360
11361Compiler.prototype.compile_nomatch = function(node) {
11362 return viml_printf("(!~ %s %s)", this.compile(node.left), this.compile(node.right));
11363}
11364
11365Compiler.prototype.compile_nomatchci = function(node) {
11366 return viml_printf("(!~? %s %s)", this.compile(node.left), this.compile(node.right));
11367}
11368
11369Compiler.prototype.compile_nomatchcs = function(node) {
11370 return viml_printf("(!~# %s %s)", this.compile(node.left), this.compile(node.right));
11371}
11372
11373Compiler.prototype.compile_is = function(node) {
11374 return viml_printf("(is %s %s)", this.compile(node.left), this.compile(node.right));
11375}
11376
11377Compiler.prototype.compile_isci = function(node) {
11378 return viml_printf("(is? %s %s)", this.compile(node.left), this.compile(node.right));
11379}
11380
11381Compiler.prototype.compile_iscs = function(node) {
11382 return viml_printf("(is# %s %s)", this.compile(node.left), this.compile(node.right));
11383}
11384
11385Compiler.prototype.compile_isnot = function(node) {
11386 return viml_printf("(isnot %s %s)", this.compile(node.left), this.compile(node.right));
11387}
11388
11389Compiler.prototype.compile_isnotci = function(node) {
11390 return viml_printf("(isnot? %s %s)", this.compile(node.left), this.compile(node.right));
11391}
11392
11393Compiler.prototype.compile_isnotcs = function(node) {
11394 return viml_printf("(isnot# %s %s)", this.compile(node.left), this.compile(node.right));
11395}
11396
11397Compiler.prototype.compile_add = function(node) {
11398 return viml_printf("(+ %s %s)", this.compile(node.left), this.compile(node.right));
11399}
11400
11401Compiler.prototype.compile_subtract = function(node) {
11402 return viml_printf("(- %s %s)", this.compile(node.left), this.compile(node.right));
11403}
11404
11405Compiler.prototype.compile_concat = function(node) {
11406 return viml_printf("(concat %s %s)", this.compile(node.left), this.compile(node.right));
11407}
11408
11409Compiler.prototype.compile_multiply = function(node) {
11410 return viml_printf("(* %s %s)", this.compile(node.left), this.compile(node.right));
11411}
11412
11413Compiler.prototype.compile_divide = function(node) {
11414 return viml_printf("(/ %s %s)", this.compile(node.left), this.compile(node.right));
11415}
11416
11417Compiler.prototype.compile_remainder = function(node) {
11418 return viml_printf("(%% %s %s)", this.compile(node.left), this.compile(node.right));
11419}
11420
11421Compiler.prototype.compile_not = function(node) {
11422 return viml_printf("(! %s)", this.compile(node.left));
11423}
11424
11425Compiler.prototype.compile_plus = function(node) {
11426 return viml_printf("(+ %s)", this.compile(node.left));
11427}
11428
11429Compiler.prototype.compile_minus = function(node) {
11430 return viml_printf("(- %s)", this.compile(node.left));
11431}
11432
11433Compiler.prototype.compile_subscript = function(node) {
11434 return viml_printf("(subscript %s %s)", this.compile(node.left), this.compile(node.right));
11435}
11436
11437Compiler.prototype.compile_slice = function(node) {
11438 var r0 = node.rlist[0] === NIL ? "nil" : this.compile(node.rlist[0]);
11439 var r1 = node.rlist[1] === NIL ? "nil" : this.compile(node.rlist[1]);
11440 return viml_printf("(slice %s %s %s)", this.compile(node.left), r0, r1);
11441}
11442
11443Compiler.prototype.compile_dot = function(node) {
11444 return viml_printf("(dot %s %s)", this.compile(node.left), this.compile(node.right));
11445}
11446
11447Compiler.prototype.compile_method = function(node) {
11448 return viml_printf("(method %s %s)", this.compile(node.left), this.compile(node.right));
11449}
11450
11451Compiler.prototype.compile_call = function(node) {
11452 var rlist = node.rlist.map((function(vval) { return this.compile(vval); }).bind(this));
11453 if (viml_empty(rlist)) {
11454 return viml_printf("(%s)", this.compile(node.left));
11455 }
11456 else {
11457 return viml_printf("(%s %s)", this.compile(node.left), viml_join(rlist, " "));
11458 }
11459}
11460
11461Compiler.prototype.compile_number = function(node) {
11462 return node.value;
11463}
11464
11465Compiler.prototype.compile_blob = function(node) {
11466 return node.value;
11467}
11468
11469Compiler.prototype.compile_string = function(node) {
11470 return node.value;
11471}
11472
11473Compiler.prototype.compile_list = function(node) {
11474 var value = node.value.map((function(vval) { return this.compile(vval); }).bind(this));
11475 if (viml_empty(value)) {
11476 return "(list)";
11477 }
11478 else {
11479 return viml_printf("(list %s)", viml_join(value, " "));
11480 }
11481}
11482
11483Compiler.prototype.compile_dict = function(node) {
11484 var value = node.value.map((function(vval) { return "(" + this.compile(vval[0]) + " " + this.compile(vval[1]) + ")"; }).bind(this));
11485 if (viml_empty(value)) {
11486 return "(dict)";
11487 }
11488 else {
11489 return viml_printf("(dict %s)", viml_join(value, " "));
11490 }
11491}
11492
11493Compiler.prototype.compile_option = function(node) {
11494 return node.value;
11495}
11496
11497Compiler.prototype.compile_identifier = function(node) {
11498 return node.value;
11499}
11500
11501Compiler.prototype.compile_curlyname = function(node) {
11502 return viml_join(node.value.map((function(vval) { return this.compile(vval); }).bind(this)), "");
11503}
11504
11505Compiler.prototype.compile_env = function(node) {
11506 return node.value;
11507}
11508
11509Compiler.prototype.compile_reg = function(node) {
11510 return node.value;
11511}
11512
11513Compiler.prototype.compile_curlynamepart = function(node) {
11514 return node.value;
11515}
11516
11517Compiler.prototype.compile_curlynameexpr = function(node) {
11518 return "{" + this.compile(node.value) + "}";
11519}
11520
11521Compiler.prototype.escape_string = function(str) {
11522 var m = {"\n":"\\n", "\t":"\\t", "\r":"\\r"};
11523 var out = "\"";
11524 var __c14 = viml_range(viml_len(str));
11525 for (var __i14 = 0; __i14 < __c14.length; ++__i14) {
11526 var i = __c14[__i14];
11527 var c = str[i];
11528 if (viml_has_key(m, c)) {
11529 out += m[c];
11530 }
11531 else {
11532 out += c;
11533 }
11534 }
11535 out += "\"";
11536 return out;
11537}
11538
11539Compiler.prototype.compile_lambda = function(node) {
11540 var rlist = node.rlist.map((function(vval) { return this.compile(vval); }).bind(this));
11541 return viml_printf("(lambda (%s) %s)", viml_join(rlist, " "), this.compile(node.left));
11542}
11543
11544Compiler.prototype.compile_heredoc = function(node) {
11545 if (viml_empty(node.rlist)) {
11546 var rlist = "(list)";
11547 }
11548 else {
11549 var rlist = "(list " + viml_join(node.rlist.map((function(vval) { return this.escape_string(vval); }).bind(this)), " ") + ")";
11550 }
11551 if (viml_empty(node.body)) {
11552 var body = "(list)";
11553 }
11554 else {
11555 var body = "(list " + viml_join(node.body.map((function(vval) { return this.escape_string(vval); }).bind(this)), " ") + ")";
11556 }
11557 var op = this.escape_string(node.op);
11558 return viml_printf("(heredoc %s %s %s)", rlist, op, body);
11559}
11560
11561// TODO: under construction
11562function RegexpParser() { this.__init__.apply(this, arguments); }
11563RegexpParser.prototype.RE_VERY_NOMAGIC = 1;
11564RegexpParser.prototype.RE_NOMAGIC = 2;
11565RegexpParser.prototype.RE_MAGIC = 3;
11566RegexpParser.prototype.RE_VERY_MAGIC = 4;
11567RegexpParser.prototype.__init__ = function(reader, cmd, delim) {
11568 this.reader = reader;
11569 this.cmd = cmd;
11570 this.delim = delim;
11571 this.reg_magic = this.RE_MAGIC;
11572}
11573
11574RegexpParser.prototype.isend = function(c) {
11575 return c == "<EOF>" || c == "<EOL>" || c == this.delim;
11576}
11577
11578RegexpParser.prototype.parse_regexp = function() {
11579 var prevtoken = "";
11580 var ntoken = "";
11581 var ret = [];
11582 if (this.reader.peekn(4) == "\\%#=") {
11583 var epos = this.reader.getpos();
11584 var token = this.reader.getn(5);
11585 if (token != "\\%#=0" && token != "\\%#=1" && token != "\\%#=2") {
11586 throw Err("E864: \\%#= can only be followed by 0, 1, or 2", epos);
11587 }
11588 viml_add(ret, token);
11589 }
11590 while (!this.isend(this.reader.peek())) {
11591 var prevtoken = ntoken;
11592 var __tmp = this.get_token();
11593 var token = __tmp[0];
11594 var ntoken = __tmp[1];
11595 if (ntoken == "\\m") {
11596 this.reg_magic = this.RE_MAGIC;
11597 }
11598 else if (ntoken == "\\M") {
11599 this.reg_magic = this.RE_NOMAGIC;
11600 }
11601 else if (ntoken == "\\v") {
11602 this.reg_magic = this.RE_VERY_MAGIC;
11603 }
11604 else if (ntoken == "\\V") {
11605 this.reg_magic = this.RE_VERY_NOMAGIC;
11606 }
11607 else if (ntoken == "\\*") {
11608 // '*' is not magic as the very first character.
11609 if (prevtoken == "" || prevtoken == "\\^" || prevtoken == "\\&" || prevtoken == "\\|" || prevtoken == "\\(") {
11610 var ntoken = "*";
11611 }
11612 }
11613 else if (ntoken == "\\^") {
11614 // '^' is only magic as the very first character.
11615 if (this.reg_magic != this.RE_VERY_MAGIC && prevtoken != "" && prevtoken != "\\&" && prevtoken != "\\|" && prevtoken != "\\n" && prevtoken != "\\(" && prevtoken != "\\%(") {
11616 var ntoken = "^";
11617 }
11618 }
11619 else if (ntoken == "\\$") {
11620 // '$' is only magic as the very last character
11621 var pos = this.reader.tell();
11622 if (this.reg_magic != this.RE_VERY_MAGIC) {
11623 while (!this.isend(this.reader.peek())) {
11624 var __tmp = this.get_token();
11625 var t = __tmp[0];
11626 var n = __tmp[1];
11627 // XXX: Vim doesn't check \v and \V?
11628 if (n == "\\c" || n == "\\C" || n == "\\m" || n == "\\M" || n == "\\Z") {
11629 continue;
11630 }
11631 if (n != "\\|" && n != "\\&" && n != "\\n" && n != "\\)") {
11632 var ntoken = "$";
11633 }
11634 break;
11635 }
11636 }
11637 this.reader.seek_set(pos);
11638 }
11639 else if (ntoken == "\\?") {
11640 // '?' is literal in '?' command.
11641 if (this.cmd == "?") {
11642 var ntoken = "?";
11643 }
11644 }
11645 viml_add(ret, ntoken);
11646 }
11647 return ret;
11648}
11649
11650// @return [actual_token, normalized_token]
11651RegexpParser.prototype.get_token = function() {
11652 if (this.reg_magic == this.RE_VERY_MAGIC) {
11653 return this.get_token_very_magic();
11654 }
11655 else if (this.reg_magic == this.RE_MAGIC) {
11656 return this.get_token_magic();
11657 }
11658 else if (this.reg_magic == this.RE_NOMAGIC) {
11659 return this.get_token_nomagic();
11660 }
11661 else if (this.reg_magic == this.RE_VERY_NOMAGIC) {
11662 return this.get_token_very_nomagic();
11663 }
11664}
11665
11666RegexpParser.prototype.get_token_very_magic = function() {
11667 if (this.isend(this.reader.peek())) {
11668 return ["<END>", "<END>"];
11669 }
11670 var c = this.reader.get();
11671 if (c == "\\") {
11672 return this.get_token_backslash_common();
11673 }
11674 else if (c == "*") {
11675 return ["*", "\\*"];
11676 }
11677 else if (c == "+") {
11678 return ["+", "\\+"];
11679 }
11680 else if (c == "=") {
11681 return ["=", "\\="];
11682 }
11683 else if (c == "?") {
11684 return ["?", "\\?"];
11685 }
11686 else if (c == "{") {
11687 return this.get_token_brace("{");
11688 }
11689 else if (c == "@") {
11690 return this.get_token_at("@");
11691 }
11692 else if (c == "^") {
11693 return ["^", "\\^"];
11694 }
11695 else if (c == "$") {
11696 return ["$", "\\$"];
11697 }
11698 else if (c == ".") {
11699 return [".", "\\."];
11700 }
11701 else if (c == "<") {
11702 return ["<", "\\<"];
11703 }
11704 else if (c == ">") {
11705 return [">", "\\>"];
11706 }
11707 else if (c == "%") {
11708 return this.get_token_percent("%");
11709 }
11710 else if (c == "[") {
11711 return this.get_token_sq("[");
11712 }
11713 else if (c == "~") {
11714 return ["~", "\\~"];
11715 }
11716 else if (c == "|") {
11717 return ["|", "\\|"];
11718 }
11719 else if (c == "&") {
11720 return ["&", "\\&"];
11721 }
11722 else if (c == "(") {
11723 return ["(", "\\("];
11724 }
11725 else if (c == ")") {
11726 return [")", "\\)"];
11727 }
11728 return [c, c];
11729}
11730
11731RegexpParser.prototype.get_token_magic = function() {
11732 if (this.isend(this.reader.peek())) {
11733 return ["<END>", "<END>"];
11734 }
11735 var c = this.reader.get();
11736 if (c == "\\") {
11737 var pos = this.reader.tell();
11738 var c = this.reader.get();
11739 if (c == "+") {
11740 return ["\\+", "\\+"];
11741 }
11742 else if (c == "=") {
11743 return ["\\=", "\\="];
11744 }
11745 else if (c == "?") {
11746 return ["\\?", "\\?"];
11747 }
11748 else if (c == "{") {
11749 return this.get_token_brace("\\{");
11750 }
11751 else if (c == "@") {
11752 return this.get_token_at("\\@");
11753 }
11754 else if (c == "<") {
11755 return ["\\<", "\\<"];
11756 }
11757 else if (c == ">") {
11758 return ["\\>", "\\>"];
11759 }
11760 else if (c == "%") {
11761 return this.get_token_percent("\\%");
11762 }
11763 else if (c == "|") {
11764 return ["\\|", "\\|"];
11765 }
11766 else if (c == "&") {
11767 return ["\\&", "\\&"];
11768 }
11769 else if (c == "(") {
11770 return ["\\(", "\\("];
11771 }
11772 else if (c == ")") {
11773 return ["\\)", "\\)"];
11774 }
11775 this.reader.seek_set(pos);
11776 return this.get_token_backslash_common();
11777 }
11778 else if (c == "*") {
11779 return ["*", "\\*"];
11780 }
11781 else if (c == "^") {
11782 return ["^", "\\^"];
11783 }
11784 else if (c == "$") {
11785 return ["$", "\\$"];
11786 }
11787 else if (c == ".") {
11788 return [".", "\\."];
11789 }
11790 else if (c == "[") {
11791 return this.get_token_sq("[");
11792 }
11793 else if (c == "~") {
11794 return ["~", "\\~"];
11795 }
11796 return [c, c];
11797}
11798
11799RegexpParser.prototype.get_token_nomagic = function() {
11800 if (this.isend(this.reader.peek())) {
11801 return ["<END>", "<END>"];
11802 }
11803 var c = this.reader.get();
11804 if (c == "\\") {
11805 var pos = this.reader.tell();
11806 var c = this.reader.get();
11807 if (c == "*") {
11808 return ["\\*", "\\*"];
11809 }
11810 else if (c == "+") {
11811 return ["\\+", "\\+"];
11812 }
11813 else if (c == "=") {
11814 return ["\\=", "\\="];
11815 }
11816 else if (c == "?") {
11817 return ["\\?", "\\?"];
11818 }
11819 else if (c == "{") {
11820 return this.get_token_brace("\\{");
11821 }
11822 else if (c == "@") {
11823 return this.get_token_at("\\@");
11824 }
11825 else if (c == ".") {
11826 return ["\\.", "\\."];
11827 }
11828 else if (c == "<") {
11829 return ["\\<", "\\<"];
11830 }
11831 else if (c == ">") {
11832 return ["\\>", "\\>"];
11833 }
11834 else if (c == "%") {
11835 return this.get_token_percent("\\%");
11836 }
11837 else if (c == "~") {
11838 return ["\\~", "\\^"];
11839 }
11840 else if (c == "[") {
11841 return this.get_token_sq("\\[");
11842 }
11843 else if (c == "|") {
11844 return ["\\|", "\\|"];
11845 }
11846 else if (c == "&") {
11847 return ["\\&", "\\&"];
11848 }
11849 else if (c == "(") {
11850 return ["\\(", "\\("];
11851 }
11852 else if (c == ")") {
11853 return ["\\)", "\\)"];
11854 }
11855 this.reader.seek_set(pos);
11856 return this.get_token_backslash_common();
11857 }
11858 else if (c == "^") {
11859 return ["^", "\\^"];
11860 }
11861 else if (c == "$") {
11862 return ["$", "\\$"];
11863 }
11864 return [c, c];
11865}
11866
11867RegexpParser.prototype.get_token_very_nomagic = function() {
11868 if (this.isend(this.reader.peek())) {
11869 return ["<END>", "<END>"];
11870 }
11871 var c = this.reader.get();
11872 if (c == "\\") {
11873 var pos = this.reader.tell();
11874 var c = this.reader.get();
11875 if (c == "*") {
11876 return ["\\*", "\\*"];
11877 }
11878 else if (c == "+") {
11879 return ["\\+", "\\+"];
11880 }
11881 else if (c == "=") {
11882 return ["\\=", "\\="];
11883 }
11884 else if (c == "?") {
11885 return ["\\?", "\\?"];
11886 }
11887 else if (c == "{") {
11888 return this.get_token_brace("\\{");
11889 }
11890 else if (c == "@") {
11891 return this.get_token_at("\\@");
11892 }
11893 else if (c == "^") {
11894 return ["\\^", "\\^"];
11895 }
11896 else if (c == "$") {
11897 return ["\\$", "\\$"];
11898 }
11899 else if (c == "<") {
11900 return ["\\<", "\\<"];
11901 }
11902 else if (c == ">") {
11903 return ["\\>", "\\>"];
11904 }
11905 else if (c == "%") {
11906 return this.get_token_percent("\\%");
11907 }
11908 else if (c == "~") {
11909 return ["\\~", "\\~"];
11910 }
11911 else if (c == "[") {
11912 return this.get_token_sq("\\[");
11913 }
11914 else if (c == "|") {
11915 return ["\\|", "\\|"];
11916 }
11917 else if (c == "&") {
11918 return ["\\&", "\\&"];
11919 }
11920 else if (c == "(") {
11921 return ["\\(", "\\("];
11922 }
11923 else if (c == ")") {
11924 return ["\\)", "\\)"];
11925 }
11926 this.reader.seek_set(pos);
11927 return this.get_token_backslash_common();
11928 }
11929 return [c, c];
11930}
11931
11932RegexpParser.prototype.get_token_backslash_common = function() {
11933 var cclass = "iIkKfFpPsSdDxXoOwWhHaAlLuU";
11934 var c = this.reader.get();
11935 if (c == "\\") {
11936 return ["\\\\", "\\\\"];
11937 }
11938 else if (viml_stridx(cclass, c) != -1) {
11939 return ["\\" + c, "\\" + c];
11940 }
11941 else if (c == "_") {
11942 var epos = this.reader.getpos();
11943 var c = this.reader.get();
11944 if (viml_stridx(cclass, c) != -1) {
11945 return ["\\_" + c, "\\_ . c"];
11946 }
11947 else if (c == "^") {
11948 return ["\\_^", "\\_^"];
11949 }
11950 else if (c == "$") {
11951 return ["\\_$", "\\_$"];
11952 }
11953 else if (c == ".") {
11954 return ["\\_.", "\\_."];
11955 }
11956 else if (c == "[") {
11957 return this.get_token_sq("\\_[");
11958 }
11959 throw Err("E63: invalid use of \\_", epos);
11960 }
11961 else if (viml_stridx("etrb", c) != -1) {
11962 return ["\\" + c, "\\" + c];
11963 }
11964 else if (viml_stridx("123456789", c) != -1) {
11965 return ["\\" + c, "\\" + c];
11966 }
11967 else if (c == "z") {
11968 var epos = this.reader.getpos();
11969 var c = this.reader.get();
11970 if (viml_stridx("123456789", c) != -1) {
11971 return ["\\z" + c, "\\z" + c];
11972 }
11973 else if (c == "s") {
11974 return ["\\zs", "\\zs"];
11975 }
11976 else if (c == "e") {
11977 return ["\\ze", "\\ze"];
11978 }
11979 else if (c == "(") {
11980 return ["\\z(", "\\z("];
11981 }
11982 throw Err("E68: Invalid character after \\z", epos);
11983 }
11984 else if (viml_stridx("cCmMvVZ", c) != -1) {
11985 return ["\\" + c, "\\" + c];
11986 }
11987 else if (c == "%") {
11988 var epos = this.reader.getpos();
11989 var c = this.reader.get();
11990 if (c == "d") {
11991 var r = this.getdecchrs();
11992 if (r != "") {
11993 return ["\\%d" + r, "\\%d" + r];
11994 }
11995 }
11996 else if (c == "o") {
11997 var r = this.getoctchrs();
11998 if (r != "") {
11999 return ["\\%o" + r, "\\%o" + r];
12000 }
12001 }
12002 else if (c == "x") {
12003 var r = this.gethexchrs(2);
12004 if (r != "") {
12005 return ["\\%x" + r, "\\%x" + r];
12006 }
12007 }
12008 else if (c == "u") {
12009 var r = this.gethexchrs(4);
12010 if (r != "") {
12011 return ["\\%u" + r, "\\%u" + r];
12012 }
12013 }
12014 else if (c == "U") {
12015 var r = this.gethexchrs(8);
12016 if (r != "") {
12017 return ["\\%U" + r, "\\%U" + r];
12018 }
12019 }
12020 throw Err("E678: Invalid character after \\%[dxouU]", epos);
12021 }
12022 return ["\\" + c, c];
12023}
12024
12025// \{}
12026RegexpParser.prototype.get_token_brace = function(pre) {
12027 var r = "";
12028 var minus = "";
12029 var comma = "";
12030 var n = "";
12031 var m = "";
12032 if (this.reader.p(0) == "-") {
12033 var minus = this.reader.get();
12034 r += minus;
12035 }
12036 if (isdigit(this.reader.p(0))) {
12037 var n = this.reader.read_digit();
12038 r += n;
12039 }
12040 if (this.reader.p(0) == ",") {
12041 var comma = this.rader.get();
12042 r += comma;
12043 }
12044 if (isdigit(this.reader.p(0))) {
12045 var m = this.reader.read_digit();
12046 r += m;
12047 }
12048 if (this.reader.p(0) == "\\") {
12049 r += this.reader.get();
12050 }
12051 if (this.reader.p(0) != "}") {
12052 throw Err("E554: Syntax error in \\{...}", this.reader.getpos());
12053 }
12054 this.reader.get();
12055 return [pre + r, "\\{" + minus + n + comma + m + "}"];
12056}
12057
12058// \[]
12059RegexpParser.prototype.get_token_sq = function(pre) {
12060 var start = this.reader.tell();
12061 var r = "";
12062 // Complement of range
12063 if (this.reader.p(0) == "^") {
12064 r += this.reader.get();
12065 }
12066 // At the start ']' and '-' mean the literal character.
12067 if (this.reader.p(0) == "]" || this.reader.p(0) == "-") {
12068 r += this.reader.get();
12069 }
12070 while (TRUE) {
12071 var startc = 0;
12072 var c = this.reader.p(0);
12073 if (this.isend(c)) {
12074 // If there is no matching ']', we assume the '[' is a normal character.
12075 this.reader.seek_set(start);
12076 return [pre, "["];
12077 }
12078 else if (c == "]") {
12079 this.reader.seek_cur(1);
12080 return [pre + r + "]", "\\[" + r + "]"];
12081 }
12082 else if (c == "[") {
12083 var e = this.get_token_sq_char_class();
12084 if (e == "") {
12085 var e = this.get_token_sq_equi_class();
12086 if (e == "") {
12087 var e = this.get_token_sq_coll_element();
12088 if (e == "") {
12089 var __tmp = this.get_token_sq_c();
12090 var e = __tmp[0];
12091 var startc = __tmp[1];
12092 }
12093 }
12094 }
12095 r += e;
12096 }
12097 else {
12098 var __tmp = this.get_token_sq_c();
12099 var e = __tmp[0];
12100 var startc = __tmp[1];
12101 r += e;
12102 }
12103 if (startc != 0 && this.reader.p(0) == "-" && !this.isend(this.reader.p(1)) && !(this.reader.p(1) == "\\" && this.reader.p(2) == "n")) {
12104 this.reader.seek_cur(1);
12105 r += "-";
12106 var c = this.reader.p(0);
12107 if (c == "[") {
12108 var e = this.get_token_sq_coll_element();
12109 if (e != "") {
12110 var endc = viml_char2nr(e[2]);
12111 }
12112 else {
12113 var __tmp = this.get_token_sq_c();
12114 var e = __tmp[0];
12115 var endc = __tmp[1];
12116 }
12117 r += e;
12118 }
12119 else {
12120 var __tmp = this.get_token_sq_c();
12121 var e = __tmp[0];
12122 var endc = __tmp[1];
12123 r += e;
12124 }
12125 if (startc > endc || endc > startc + 256) {
12126 throw Err("E16: Invalid range", this.reader.getpos());
12127 }
12128 }
12129 }
12130}
12131
12132// [c]
12133RegexpParser.prototype.get_token_sq_c = function() {
12134 var c = this.reader.p(0);
12135 if (c == "\\") {
12136 this.reader.seek_cur(1);
12137 var c = this.reader.p(0);
12138 if (c == "n") {
12139 this.reader.seek_cur(1);
12140 return ["\\n", 0];
12141 }
12142 else if (c == "r") {
12143 this.reader.seek_cur(1);
12144 return ["\\r", 13];
12145 }
12146 else if (c == "t") {
12147 this.reader.seek_cur(1);
12148 return ["\\t", 9];
12149 }
12150 else if (c == "e") {
12151 this.reader.seek_cur(1);
12152 return ["\\e", 27];
12153 }
12154 else if (c == "b") {
12155 this.reader.seek_cur(1);
12156 return ["\\b", 8];
12157 }
12158 else if (viml_stridx("]^-\\", c) != -1) {
12159 this.reader.seek_cur(1);
12160 return ["\\" + c, viml_char2nr(c)];
12161 }
12162 else if (viml_stridx("doxuU", c) != -1) {
12163 var __tmp = this.get_token_sq_coll_char();
12164 var c = __tmp[0];
12165 var n = __tmp[1];
12166 return [c, n];
12167 }
12168 else {
12169 return ["\\", viml_char2nr("\\")];
12170 }
12171 }
12172 else if (c == "-") {
12173 this.reader.seek_cur(1);
12174 return ["-", viml_char2nr("-")];
12175 }
12176 else {
12177 this.reader.seek_cur(1);
12178 return [c, viml_char2nr(c)];
12179 }
12180}
12181
12182// [\d123]
12183RegexpParser.prototype.get_token_sq_coll_char = function() {
12184 var pos = this.reader.tell();
12185 var c = this.reader.get();
12186 if (c == "d") {
12187 var r = this.getdecchrs();
12188 var n = viml_str2nr(r, 10);
12189 }
12190 else if (c == "o") {
12191 var r = this.getoctchrs();
12192 var n = viml_str2nr(r, 8);
12193 }
12194 else if (c == "x") {
12195 var r = this.gethexchrs(2);
12196 var n = viml_str2nr(r, 16);
12197 }
12198 else if (c == "u") {
12199 var r = this.gethexchrs(4);
12200 var n = viml_str2nr(r, 16);
12201 }
12202 else if (c == "U") {
12203 var r = this.gethexchrs(8);
12204 var n = viml_str2nr(r, 16);
12205 }
12206 else {
12207 var r = "";
12208 }
12209 if (r == "") {
12210 this.reader.seek_set(pos);
12211 return "\\";
12212 }
12213 return ["\\" + c + r, n];
12214}
12215
12216// [[.a.]]
12217RegexpParser.prototype.get_token_sq_coll_element = function() {
12218 if (this.reader.p(0) == "[" && this.reader.p(1) == "." && !this.isend(this.reader.p(2)) && this.reader.p(3) == "." && this.reader.p(4) == "]") {
12219 return this.reader.getn(5);
12220 }
12221 return "";
12222}
12223
12224// [[=a=]]
12225RegexpParser.prototype.get_token_sq_equi_class = function() {
12226 if (this.reader.p(0) == "[" && this.reader.p(1) == "=" && !this.isend(this.reader.p(2)) && this.reader.p(3) == "=" && this.reader.p(4) == "]") {
12227 return this.reader.getn(5);
12228 }
12229 return "";
12230}
12231
12232// [[:alpha:]]
12233RegexpParser.prototype.get_token_sq_char_class = function() {
12234 var class_names = ["alnum", "alpha", "blank", "cntrl", "digit", "graph", "lower", "print", "punct", "space", "upper", "xdigit", "tab", "return", "backspace", "escape"];
12235 var pos = this.reader.tell();
12236 if (this.reader.p(0) == "[" && this.reader.p(1) == ":") {
12237 this.reader.seek_cur(2);
12238 var r = this.reader.read_alpha();
12239 if (this.reader.p(0) == ":" && this.reader.p(1) == "]") {
12240 this.reader.seek_cur(2);
12241 var __c15 = class_names;
12242 for (var __i15 = 0; __i15 < __c15.length; ++__i15) {
12243 var name = __c15[__i15];
12244 if (r == name) {
12245 return "[:" + name + ":]";
12246 }
12247 }
12248 }
12249 }
12250 this.reader.seek_set(pos);
12251 return "";
12252}
12253
12254// \@...
12255RegexpParser.prototype.get_token_at = function(pre) {
12256 var epos = this.reader.getpos();
12257 var c = this.reader.get();
12258 if (c == ">") {
12259 return [pre + ">", "\\@>"];
12260 }
12261 else if (c == "=") {
12262 return [pre + "=", "\\@="];
12263 }
12264 else if (c == "!") {
12265 return [pre + "!", "\\@!"];
12266 }
12267 else if (c == "<") {
12268 var c = this.reader.get();
12269 if (c == "=") {
12270 return [pre + "<=", "\\@<="];
12271 }
12272 else if (c == "!") {
12273 return [pre + "<!", "\\@<!"];
12274 }
12275 }
12276 throw Err("E64: @ follows nothing", epos);
12277}
12278
12279// \%...
12280RegexpParser.prototype.get_token_percent = function(pre) {
12281 var c = this.reader.get();
12282 if (c == "^") {
12283 return [pre + "^", "\\%^"];
12284 }
12285 else if (c == "$") {
12286 return [pre + "$", "\\%$"];
12287 }
12288 else if (c == "V") {
12289 return [pre + "V", "\\%V"];
12290 }
12291 else if (c == "#") {
12292 return [pre + "#", "\\%#"];
12293 }
12294 else if (c == "[") {
12295 return this.get_token_percent_sq(pre + "[");
12296 }
12297 else if (c == "(") {
12298 return [pre + "(", "\\%("];
12299 }
12300 else {
12301 return this.get_token_mlcv(pre);
12302 }
12303}
12304
12305// \%[]
12306RegexpParser.prototype.get_token_percent_sq = function(pre) {
12307 var r = "";
12308 while (TRUE) {
12309 var c = this.reader.peek();
12310 if (this.isend(c)) {
12311 throw Err("E69: Missing ] after \\%[", this.reader.getpos());
12312 }
12313 else if (c == "]") {
12314 if (r == "") {
12315 throw Err("E70: Empty \\%[", this.reader.getpos());
12316 }
12317 this.reader.seek_cur(1);
12318 break;
12319 }
12320 this.reader.seek_cur(1);
12321 r += c;
12322 }
12323 return [pre + r + "]", "\\%[" + r + "]"];
12324}
12325
12326// \%'m \%l \%c \%v
12327RegexpParser.prototype.get_token_mlvc = function(pre) {
12328 var r = "";
12329 var cmp = "";
12330 if (this.reader.p(0) == "<" || this.reader.p(0) == ">") {
12331 var cmp = this.reader.get();
12332 r += cmp;
12333 }
12334 if (this.reader.p(0) == "'") {
12335 r += this.reader.get();
12336 var c = this.reader.p(0);
12337 if (this.isend(c)) {
12338 // FIXME: Should be error? Vim allow this.
12339 var c = "";
12340 }
12341 else {
12342 var c = this.reader.get();
12343 }
12344 return [pre + r + c, "\\%" + cmp + "'" + c];
12345 }
12346 else if (isdigit(this.reader.p(0))) {
12347 var d = this.reader.read_digit();
12348 r += d;
12349 var c = this.reader.p(0);
12350 if (c == "l") {
12351 this.reader.get();
12352 return [pre + r + "l", "\\%" + cmp + d + "l"];
12353 }
12354 else if (c == "c") {
12355 this.reader.get();
12356 return [pre + r + "c", "\\%" + cmp + d + "c"];
12357 }
12358 else if (c == "v") {
12359 this.reader.get();
12360 return [pre + r + "v", "\\%" + cmp + d + "v"];
12361 }
12362 }
12363 throw Err("E71: Invalid character after %", this.reader.getpos());
12364}
12365
12366RegexpParser.prototype.getdecchrs = function() {
12367 return this.reader.read_digit();
12368}
12369
12370RegexpParser.prototype.getoctchrs = function() {
12371 return this.reader.read_odigit();
12372}
12373
12374RegexpParser.prototype.gethexchrs = function(n) {
12375 var r = "";
12376 var __c16 = viml_range(n);
12377 for (var __i16 = 0; __i16 < __c16.length; ++__i16) {
12378 var i = __c16[__i16];
12379 var c = this.reader.peek();
12380 if (!isxdigit(c)) {
12381 break;
12382 }
12383 r += this.reader.get();
12384 }
12385 return r;
12386}
12387
12388if (__webpack_require__.c[__webpack_require__.s] === module) {
12389 main();
12390}
12391else {
12392 module.exports = {
12393 VimLParser: VimLParser,
12394 StringReader: StringReader,
12395 Compiler: Compiler
12396 };
12397}
12398
12399/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(47)(module)))
12400
12401/***/ }),
12402
12403/***/ 47:
12404/***/ (function(module, exports) {
12405
12406module.exports = function(module) {
12407 if (!module.webpackPolyfill) {
12408 module.deprecate = function() {};
12409 module.paths = [];
12410 // module.parent = undefined by default
12411 if (!module.children) module.children = [];
12412 Object.defineProperty(module, "loaded", {
12413 enumerable: true,
12414 get: function() {
12415 return module.l;
12416 }
12417 });
12418 Object.defineProperty(module, "id", {
12419 enumerable: true,
12420 get: function() {
12421 return module.i;
12422 }
12423 });
12424 module.webpackPolyfill = 1;
12425 }
12426 return module;
12427};
12428
12429
12430/***/ }),
12431
12432/***/ 48:
12433/***/ (function(module, exports, __webpack_require__) {
12434
12435"use strict";
12436
12437Object.defineProperty(exports, "__esModule", { value: true });
12438exports.errorLinePattern = /[^:]+:\s*(.+?):\s*line\s*([0-9]+)\s*col\s*([0-9]+)/;
12439exports.commentPattern = /^[ \t]*("|')/;
12440exports.keywordPattern = /[\w#&$<>.:]/;
12441exports.builtinFunctionPattern = /^((<SID>|\b(v|g|b|s|l|a):)?[\w#&]+)[ \t]*\([^)]*\)/;
12442exports.wordPrePattern = /^.*?(((<SID>|\b(v|g|b|s|l|a):)?[\w#&$.]+)|(<SID>|<SID|<SI|<S|<|\b(v|g|b|s|l|a):))$/;
12443exports.wordNextPattern = /^((SID>|ID>|D>|>|<SID>|\b(v|g|b|s|l|a):)?[\w#&$.]+|(:[\w#&$.]+)).*?(\r\n|\r|\n)?$/;
12444exports.colorschemePattern = /\bcolorscheme[ \t]+\w*$/;
12445exports.mapCommandPattern = /^([ \t]*(\[ \t]*)?)\w*map[ \t]+/;
12446exports.highlightLinkPattern = /^[ \t]*(hi|highlight)[ \t]+link([ \t]+[^ \t]+)*[ \t]*$/;
12447exports.highlightPattern = /^[ \t]*(hi|highlight)([ \t]+[^ \t]+)*[ \t]*$/;
12448exports.highlightValuePattern = /^[ \t]*(hi|highlight)([ \t]+[^ \t]+)*[ \t]+([^ \t=]+)=[^ \t=]*$/;
12449exports.autocmdPattern = /^[ \t]*(au|autocmd)!?[ \t]+([^ \t,]+,)*[^ \t,]*$/;
12450exports.builtinVariablePattern = [
12451 /\bv:\w*$/,
12452];
12453exports.optionPattern = [
12454 /(^|[ \t]+)&\w*$/,
12455 /(^|[ \t]+)set(l|local|g|global)?[ \t]+\w+$/,
12456];
12457exports.notFunctionPattern = [
12458 /^[ \t]*\\$/,
12459 /^[ \t]*\w+$/,
12460 /^[ \t]*"/,
12461 /(let|set|colorscheme)[ \t][^ \t]*$/,
12462 /[^([,\\ \t\w#>]\w*$/,
12463 /^[ \t]*(hi|highlight)([ \t]+link)?([ \t]+[^ \t]+)*[ \t]*$/,
12464 exports.autocmdPattern,
12465];
12466exports.commandPattern = [
12467 /(^|[ \t]):\w+$/,
12468 /^[ \t]*\w+$/,
12469 /:?silent!?[ \t]\w+/,
12470];
12471exports.featurePattern = [
12472 /\bhas\([ \t]*["']\w*/,
12473];
12474exports.expandPattern = [
12475 /\bexpand\(['"]<\w*$/,
12476 /\bexpand\([ \t]*['"]\w*$/,
12477];
12478exports.notIdentifierPattern = [
12479 exports.commentPattern,
12480 /("|'):\w*$/,
12481 /^[ \t]*\\$/,
12482 /^[ \t]*call[ \t]+[^ \t()]*$/,
12483 /('|"|#|&|\$|<)\w*$/,
12484];
12485
12486
12487/***/ }),
12488
12489/***/ 5:
12490/***/ (function(module, exports, __webpack_require__) {
12491
12492"use strict";
12493/* --------------------------------------------------------------------------------------------
12494 * Copyright (c) Microsoft Corporation. All rights reserved.
12495 * Licensed under the MIT License. See License.txt in the project root for license information.
12496 * ------------------------------------------------------------------------------------------ */
12497
12498function __export(m) {
12499 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
12500}
12501Object.defineProperty(exports, "__esModule", { value: true });
12502const vscode_jsonrpc_1 = __webpack_require__(6);
12503exports.ErrorCodes = vscode_jsonrpc_1.ErrorCodes;
12504exports.ResponseError = vscode_jsonrpc_1.ResponseError;
12505exports.CancellationToken = vscode_jsonrpc_1.CancellationToken;
12506exports.CancellationTokenSource = vscode_jsonrpc_1.CancellationTokenSource;
12507exports.Disposable = vscode_jsonrpc_1.Disposable;
12508exports.Event = vscode_jsonrpc_1.Event;
12509exports.Emitter = vscode_jsonrpc_1.Emitter;
12510exports.Trace = vscode_jsonrpc_1.Trace;
12511exports.TraceFormat = vscode_jsonrpc_1.TraceFormat;
12512exports.SetTraceNotification = vscode_jsonrpc_1.SetTraceNotification;
12513exports.LogTraceNotification = vscode_jsonrpc_1.LogTraceNotification;
12514exports.RequestType = vscode_jsonrpc_1.RequestType;
12515exports.RequestType0 = vscode_jsonrpc_1.RequestType0;
12516exports.NotificationType = vscode_jsonrpc_1.NotificationType;
12517exports.NotificationType0 = vscode_jsonrpc_1.NotificationType0;
12518exports.MessageReader = vscode_jsonrpc_1.MessageReader;
12519exports.MessageWriter = vscode_jsonrpc_1.MessageWriter;
12520exports.ConnectionStrategy = vscode_jsonrpc_1.ConnectionStrategy;
12521exports.StreamMessageReader = vscode_jsonrpc_1.StreamMessageReader;
12522exports.StreamMessageWriter = vscode_jsonrpc_1.StreamMessageWriter;
12523exports.IPCMessageReader = vscode_jsonrpc_1.IPCMessageReader;
12524exports.IPCMessageWriter = vscode_jsonrpc_1.IPCMessageWriter;
12525exports.createClientPipeTransport = vscode_jsonrpc_1.createClientPipeTransport;
12526exports.createServerPipeTransport = vscode_jsonrpc_1.createServerPipeTransport;
12527exports.generateRandomPipeName = vscode_jsonrpc_1.generateRandomPipeName;
12528exports.createClientSocketTransport = vscode_jsonrpc_1.createClientSocketTransport;
12529exports.createServerSocketTransport = vscode_jsonrpc_1.createServerSocketTransport;
12530__export(__webpack_require__(20));
12531__export(__webpack_require__(21));
12532function createProtocolConnection(reader, writer, logger, strategy) {
12533 return vscode_jsonrpc_1.createMessageConnection(reader, writer, logger, strategy);
12534}
12535exports.createProtocolConnection = createProtocolConnection;
12536
12537
12538/***/ }),
12539
12540/***/ 6:
12541/***/ (function(module, exports, __webpack_require__) {
12542
12543"use strict";
12544/* --------------------------------------------------------------------------------------------
12545 * Copyright (c) Microsoft Corporation. All rights reserved.
12546 * Licensed under the MIT License. See License.txt in the project root for license information.
12547 * ------------------------------------------------------------------------------------------ */
12548/// <reference path="./thenable.ts" />
12549
12550function __export(m) {
12551 for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
12552}
12553Object.defineProperty(exports, "__esModule", { value: true });
12554const Is = __webpack_require__(7);
12555const messages_1 = __webpack_require__(8);
12556exports.RequestType = messages_1.RequestType;
12557exports.RequestType0 = messages_1.RequestType0;
12558exports.RequestType1 = messages_1.RequestType1;
12559exports.RequestType2 = messages_1.RequestType2;
12560exports.RequestType3 = messages_1.RequestType3;
12561exports.RequestType4 = messages_1.RequestType4;
12562exports.RequestType5 = messages_1.RequestType5;
12563exports.RequestType6 = messages_1.RequestType6;
12564exports.RequestType7 = messages_1.RequestType7;
12565exports.RequestType8 = messages_1.RequestType8;
12566exports.RequestType9 = messages_1.RequestType9;
12567exports.ResponseError = messages_1.ResponseError;
12568exports.ErrorCodes = messages_1.ErrorCodes;
12569exports.NotificationType = messages_1.NotificationType;
12570exports.NotificationType0 = messages_1.NotificationType0;
12571exports.NotificationType1 = messages_1.NotificationType1;
12572exports.NotificationType2 = messages_1.NotificationType2;
12573exports.NotificationType3 = messages_1.NotificationType3;
12574exports.NotificationType4 = messages_1.NotificationType4;
12575exports.NotificationType5 = messages_1.NotificationType5;
12576exports.NotificationType6 = messages_1.NotificationType6;
12577exports.NotificationType7 = messages_1.NotificationType7;
12578exports.NotificationType8 = messages_1.NotificationType8;
12579exports.NotificationType9 = messages_1.NotificationType9;
12580const messageReader_1 = __webpack_require__(9);
12581exports.MessageReader = messageReader_1.MessageReader;
12582exports.StreamMessageReader = messageReader_1.StreamMessageReader;
12583exports.IPCMessageReader = messageReader_1.IPCMessageReader;
12584exports.SocketMessageReader = messageReader_1.SocketMessageReader;
12585const messageWriter_1 = __webpack_require__(11);
12586exports.MessageWriter = messageWriter_1.MessageWriter;
12587exports.StreamMessageWriter = messageWriter_1.StreamMessageWriter;
12588exports.IPCMessageWriter = messageWriter_1.IPCMessageWriter;
12589exports.SocketMessageWriter = messageWriter_1.SocketMessageWriter;
12590const events_1 = __webpack_require__(10);
12591exports.Disposable = events_1.Disposable;
12592exports.Event = events_1.Event;
12593exports.Emitter = events_1.Emitter;
12594const cancellation_1 = __webpack_require__(12);
12595exports.CancellationTokenSource = cancellation_1.CancellationTokenSource;
12596exports.CancellationToken = cancellation_1.CancellationToken;
12597const linkedMap_1 = __webpack_require__(13);
12598__export(__webpack_require__(14));
12599__export(__webpack_require__(19));
12600var CancelNotification;
12601(function (CancelNotification) {
12602 CancelNotification.type = new messages_1.NotificationType('$/cancelRequest');
12603})(CancelNotification || (CancelNotification = {}));
12604exports.NullLogger = Object.freeze({
12605 error: () => { },
12606 warn: () => { },
12607 info: () => { },
12608 log: () => { }
12609});
12610var Trace;
12611(function (Trace) {
12612 Trace[Trace["Off"] = 0] = "Off";
12613 Trace[Trace["Messages"] = 1] = "Messages";
12614 Trace[Trace["Verbose"] = 2] = "Verbose";
12615})(Trace = exports.Trace || (exports.Trace = {}));
12616(function (Trace) {
12617 function fromString(value) {
12618 value = value.toLowerCase();
12619 switch (value) {
12620 case 'off':
12621 return Trace.Off;
12622 case 'messages':
12623 return Trace.Messages;
12624 case 'verbose':
12625 return Trace.Verbose;
12626 default:
12627 return Trace.Off;
12628 }
12629 }
12630 Trace.fromString = fromString;
12631 function toString(value) {
12632 switch (value) {
12633 case Trace.Off:
12634 return 'off';
12635 case Trace.Messages:
12636 return 'messages';
12637 case Trace.Verbose:
12638 return 'verbose';
12639 default:
12640 return 'off';
12641 }
12642 }
12643 Trace.toString = toString;
12644})(Trace = exports.Trace || (exports.Trace = {}));
12645var TraceFormat;
12646(function (TraceFormat) {
12647 TraceFormat["Text"] = "text";
12648 TraceFormat["JSON"] = "json";
12649})(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
12650(function (TraceFormat) {
12651 function fromString(value) {
12652 value = value.toLowerCase();
12653 if (value === 'json') {
12654 return TraceFormat.JSON;
12655 }
12656 else {
12657 return TraceFormat.Text;
12658 }
12659 }
12660 TraceFormat.fromString = fromString;
12661})(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));
12662var SetTraceNotification;
12663(function (SetTraceNotification) {
12664 SetTraceNotification.type = new messages_1.NotificationType('$/setTraceNotification');
12665})(SetTraceNotification = exports.SetTraceNotification || (exports.SetTraceNotification = {}));
12666var LogTraceNotification;
12667(function (LogTraceNotification) {
12668 LogTraceNotification.type = new messages_1.NotificationType('$/logTraceNotification');
12669})(LogTraceNotification = exports.LogTraceNotification || (exports.LogTraceNotification = {}));
12670var ConnectionErrors;
12671(function (ConnectionErrors) {
12672 /**
12673 * The connection is closed.
12674 */
12675 ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";
12676 /**
12677 * The connection got disposed.
12678 */
12679 ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";
12680 /**
12681 * The connection is already in listening mode.
12682 */
12683 ConnectionErrors[ConnectionErrors["AlreadyListening"] = 3] = "AlreadyListening";
12684})(ConnectionErrors = exports.ConnectionErrors || (exports.ConnectionErrors = {}));
12685class ConnectionError extends Error {
12686 constructor(code, message) {
12687 super(message);
12688 this.code = code;
12689 Object.setPrototypeOf(this, ConnectionError.prototype);
12690 }
12691}
12692exports.ConnectionError = ConnectionError;
12693var ConnectionStrategy;
12694(function (ConnectionStrategy) {
12695 function is(value) {
12696 let candidate = value;
12697 return candidate && Is.func(candidate.cancelUndispatched);
12698 }
12699 ConnectionStrategy.is = is;
12700})(ConnectionStrategy = exports.ConnectionStrategy || (exports.ConnectionStrategy = {}));
12701var ConnectionState;
12702(function (ConnectionState) {
12703 ConnectionState[ConnectionState["New"] = 1] = "New";
12704 ConnectionState[ConnectionState["Listening"] = 2] = "Listening";
12705 ConnectionState[ConnectionState["Closed"] = 3] = "Closed";
12706 ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";
12707})(ConnectionState || (ConnectionState = {}));
12708function _createMessageConnection(messageReader, messageWriter, logger, strategy) {
12709 let sequenceNumber = 0;
12710 let notificationSquenceNumber = 0;
12711 let unknownResponseSquenceNumber = 0;
12712 const version = '2.0';
12713 let starRequestHandler = undefined;
12714 let requestHandlers = Object.create(null);
12715 let starNotificationHandler = undefined;
12716 let notificationHandlers = Object.create(null);
12717 let timer;
12718 let messageQueue = new linkedMap_1.LinkedMap();
12719 let responsePromises = Object.create(null);
12720 let requestTokens = Object.create(null);
12721 let trace = Trace.Off;
12722 let traceFormat = TraceFormat.Text;
12723 let tracer;
12724 let state = ConnectionState.New;
12725 let errorEmitter = new events_1.Emitter();
12726 let closeEmitter = new events_1.Emitter();
12727 let unhandledNotificationEmitter = new events_1.Emitter();
12728 let disposeEmitter = new events_1.Emitter();
12729 function createRequestQueueKey(id) {
12730 return 'req-' + id.toString();
12731 }
12732 function createResponseQueueKey(id) {
12733 if (id === null) {
12734 return 'res-unknown-' + (++unknownResponseSquenceNumber).toString();
12735 }
12736 else {
12737 return 'res-' + id.toString();
12738 }
12739 }
12740 function createNotificationQueueKey() {
12741 return 'not-' + (++notificationSquenceNumber).toString();
12742 }
12743 function addMessageToQueue(queue, message) {
12744 if (messages_1.isRequestMessage(message)) {
12745 queue.set(createRequestQueueKey(message.id), message);
12746 }
12747 else if (messages_1.isResponseMessage(message)) {
12748 queue.set(createResponseQueueKey(message.id), message);
12749 }
12750 else {
12751 queue.set(createNotificationQueueKey(), message);
12752 }
12753 }
12754 function cancelUndispatched(_message) {
12755 return undefined;
12756 }
12757 function isListening() {
12758 return state === ConnectionState.Listening;
12759 }
12760 function isClosed() {
12761 return state === ConnectionState.Closed;
12762 }
12763 function isDisposed() {
12764 return state === ConnectionState.Disposed;
12765 }
12766 function closeHandler() {
12767 if (state === ConnectionState.New || state === ConnectionState.Listening) {
12768 state = ConnectionState.Closed;
12769 closeEmitter.fire(undefined);
12770 }
12771 // If the connection is disposed don't sent close events.
12772 }
12773 ;
12774 function readErrorHandler(error) {
12775 errorEmitter.fire([error, undefined, undefined]);
12776 }
12777 function writeErrorHandler(data) {
12778 errorEmitter.fire(data);
12779 }
12780 messageReader.onClose(closeHandler);
12781 messageReader.onError(readErrorHandler);
12782 messageWriter.onClose(closeHandler);
12783 messageWriter.onError(writeErrorHandler);
12784 function triggerMessageQueue() {
12785 if (timer || messageQueue.size === 0) {
12786 return;
12787 }
12788 timer = setImmediate(() => {
12789 timer = undefined;
12790 processMessageQueue();
12791 });
12792 }
12793 function processMessageQueue() {
12794 if (messageQueue.size === 0) {
12795 return;
12796 }
12797 let message = messageQueue.shift();
12798 try {
12799 if (messages_1.isRequestMessage(message)) {
12800 handleRequest(message);
12801 }
12802 else if (messages_1.isNotificationMessage(message)) {
12803 handleNotification(message);
12804 }
12805 else if (messages_1.isResponseMessage(message)) {
12806 handleResponse(message);
12807 }
12808 else {
12809 handleInvalidMessage(message);
12810 }
12811 }
12812 finally {
12813 triggerMessageQueue();
12814 }
12815 }
12816 let callback = (message) => {
12817 try {
12818 // We have received a cancellation message. Check if the message is still in the queue
12819 // and cancel it if allowed to do so.
12820 if (messages_1.isNotificationMessage(message) && message.method === CancelNotification.type.method) {
12821 let key = createRequestQueueKey(message.params.id);
12822 let toCancel = messageQueue.get(key);
12823 if (messages_1.isRequestMessage(toCancel)) {
12824 let response = strategy && strategy.cancelUndispatched ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);
12825 if (response && (response.error !== void 0 || response.result !== void 0)) {
12826 messageQueue.delete(key);
12827 response.id = toCancel.id;
12828 traceSendingResponse(response, message.method, Date.now());
12829 messageWriter.write(response);
12830 return;
12831 }
12832 }
12833 }
12834 addMessageToQueue(messageQueue, message);
12835 }
12836 finally {
12837 triggerMessageQueue();
12838 }
12839 };
12840 function handleRequest(requestMessage) {
12841 if (isDisposed()) {
12842 // we return here silently since we fired an event when the
12843 // connection got disposed.
12844 return;
12845 }
12846 function reply(resultOrError, method, startTime) {
12847 let message = {
12848 jsonrpc: version,
12849 id: requestMessage.id
12850 };
12851 if (resultOrError instanceof messages_1.ResponseError) {
12852 message.error = resultOrError.toJson();
12853 }
12854 else {
12855 message.result = resultOrError === void 0 ? null : resultOrError;
12856 }
12857 traceSendingResponse(message, method, startTime);
12858 messageWriter.write(message);
12859 }
12860 function replyError(error, method, startTime) {
12861 let message = {
12862 jsonrpc: version,
12863 id: requestMessage.id,
12864 error: error.toJson()
12865 };
12866 traceSendingResponse(message, method, startTime);
12867 messageWriter.write(message);
12868 }
12869 function replySuccess(result, method, startTime) {
12870 // The JSON RPC defines that a response must either have a result or an error
12871 // So we can't treat undefined as a valid response result.
12872 if (result === void 0) {
12873 result = null;
12874 }
12875 let message = {
12876 jsonrpc: version,
12877 id: requestMessage.id,
12878 result: result
12879 };
12880 traceSendingResponse(message, method, startTime);
12881 messageWriter.write(message);
12882 }
12883 traceReceivedRequest(requestMessage);
12884 let element = requestHandlers[requestMessage.method];
12885 let type;
12886 let requestHandler;
12887 if (element) {
12888 type = element.type;
12889 requestHandler = element.handler;
12890 }
12891 let startTime = Date.now();
12892 if (requestHandler || starRequestHandler) {
12893 let cancellationSource = new cancellation_1.CancellationTokenSource();
12894 let tokenKey = String(requestMessage.id);
12895 requestTokens[tokenKey] = cancellationSource;
12896 try {
12897 let handlerResult;
12898 if (requestMessage.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
12899 handlerResult = requestHandler
12900 ? requestHandler(cancellationSource.token)
12901 : starRequestHandler(requestMessage.method, cancellationSource.token);
12902 }
12903 else if (Is.array(requestMessage.params) && (type === void 0 || type.numberOfParams > 1)) {
12904 handlerResult = requestHandler
12905 ? requestHandler(...requestMessage.params, cancellationSource.token)
12906 : starRequestHandler(requestMessage.method, ...requestMessage.params, cancellationSource.token);
12907 }
12908 else {
12909 handlerResult = requestHandler
12910 ? requestHandler(requestMessage.params, cancellationSource.token)
12911 : starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);
12912 }
12913 let promise = handlerResult;
12914 if (!handlerResult) {
12915 delete requestTokens[tokenKey];
12916 replySuccess(handlerResult, requestMessage.method, startTime);
12917 }
12918 else if (promise.then) {
12919 promise.then((resultOrError) => {
12920 delete requestTokens[tokenKey];
12921 reply(resultOrError, requestMessage.method, startTime);
12922 }, error => {
12923 delete requestTokens[tokenKey];
12924 if (error instanceof messages_1.ResponseError) {
12925 replyError(error, requestMessage.method, startTime);
12926 }
12927 else if (error && Is.string(error.message)) {
12928 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
12929 }
12930 else {
12931 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
12932 }
12933 });
12934 }
12935 else {
12936 delete requestTokens[tokenKey];
12937 reply(handlerResult, requestMessage.method, startTime);
12938 }
12939 }
12940 catch (error) {
12941 delete requestTokens[tokenKey];
12942 if (error instanceof messages_1.ResponseError) {
12943 reply(error, requestMessage.method, startTime);
12944 }
12945 else if (error && Is.string(error.message)) {
12946 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);
12947 }
12948 else {
12949 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);
12950 }
12951 }
12952 }
12953 else {
12954 replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);
12955 }
12956 }
12957 function handleResponse(responseMessage) {
12958 if (isDisposed()) {
12959 // See handle request.
12960 return;
12961 }
12962 if (responseMessage.id === null) {
12963 if (responseMessage.error) {
12964 logger.error(`Received response message without id: Error is: \n${JSON.stringify(responseMessage.error, undefined, 4)}`);
12965 }
12966 else {
12967 logger.error(`Received response message without id. No further error information provided.`);
12968 }
12969 }
12970 else {
12971 let key = String(responseMessage.id);
12972 let responsePromise = responsePromises[key];
12973 traceReceivedResponse(responseMessage, responsePromise);
12974 if (responsePromise) {
12975 delete responsePromises[key];
12976 try {
12977 if (responseMessage.error) {
12978 let error = responseMessage.error;
12979 responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));
12980 }
12981 else if (responseMessage.result !== void 0) {
12982 responsePromise.resolve(responseMessage.result);
12983 }
12984 else {
12985 throw new Error('Should never happen.');
12986 }
12987 }
12988 catch (error) {
12989 if (error.message) {
12990 logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);
12991 }
12992 else {
12993 logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);
12994 }
12995 }
12996 }
12997 }
12998 }
12999 function handleNotification(message) {
13000 if (isDisposed()) {
13001 // See handle request.
13002 return;
13003 }
13004 let type = undefined;
13005 let notificationHandler;
13006 if (message.method === CancelNotification.type.method) {
13007 notificationHandler = (params) => {
13008 let id = params.id;
13009 let source = requestTokens[String(id)];
13010 if (source) {
13011 source.cancel();
13012 }
13013 };
13014 }
13015 else {
13016 let element = notificationHandlers[message.method];
13017 if (element) {
13018 notificationHandler = element.handler;
13019 type = element.type;
13020 }
13021 }
13022 if (notificationHandler || starNotificationHandler) {
13023 try {
13024 traceReceivedNotification(message);
13025 if (message.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {
13026 notificationHandler ? notificationHandler() : starNotificationHandler(message.method);
13027 }
13028 else if (Is.array(message.params) && (type === void 0 || type.numberOfParams > 1)) {
13029 notificationHandler ? notificationHandler(...message.params) : starNotificationHandler(message.method, ...message.params);
13030 }
13031 else {
13032 notificationHandler ? notificationHandler(message.params) : starNotificationHandler(message.method, message.params);
13033 }
13034 }
13035 catch (error) {
13036 if (error.message) {
13037 logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);
13038 }
13039 else {
13040 logger.error(`Notification handler '${message.method}' failed unexpectedly.`);
13041 }
13042 }
13043 }
13044 else {
13045 unhandledNotificationEmitter.fire(message);
13046 }
13047 }
13048 function handleInvalidMessage(message) {
13049 if (!message) {
13050 logger.error('Received empty message.');
13051 return;
13052 }
13053 logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);
13054 // Test whether we find an id to reject the promise
13055 let responseMessage = message;
13056 if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {
13057 let key = String(responseMessage.id);
13058 let responseHandler = responsePromises[key];
13059 if (responseHandler) {
13060 responseHandler.reject(new Error('The received response has neither a result nor an error property.'));
13061 }
13062 }
13063 }
13064 function traceSendingRequest(message) {
13065 if (trace === Trace.Off || !tracer) {
13066 return;
13067 }
13068 if (traceFormat === TraceFormat.Text) {
13069 let data = undefined;
13070 if (trace === Trace.Verbose && message.params) {
13071 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
13072 }
13073 tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);
13074 }
13075 else {
13076 logLSPMessage('send-request', message);
13077 }
13078 }
13079 function traceSendingNotification(message) {
13080 if (trace === Trace.Off || !tracer) {
13081 return;
13082 }
13083 if (traceFormat === TraceFormat.Text) {
13084 let data = undefined;
13085 if (trace === Trace.Verbose) {
13086 if (message.params) {
13087 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
13088 }
13089 else {
13090 data = 'No parameters provided.\n\n';
13091 }
13092 }
13093 tracer.log(`Sending notification '${message.method}'.`, data);
13094 }
13095 else {
13096 logLSPMessage('send-notification', message);
13097 }
13098 }
13099 function traceSendingResponse(message, method, startTime) {
13100 if (trace === Trace.Off || !tracer) {
13101 return;
13102 }
13103 if (traceFormat === TraceFormat.Text) {
13104 let data = undefined;
13105 if (trace === Trace.Verbose) {
13106 if (message.error && message.error.data) {
13107 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
13108 }
13109 else {
13110 if (message.result) {
13111 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
13112 }
13113 else if (message.error === void 0) {
13114 data = 'No result returned.\n\n';
13115 }
13116 }
13117 }
13118 tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);
13119 }
13120 else {
13121 logLSPMessage('send-response', message);
13122 }
13123 }
13124 function traceReceivedRequest(message) {
13125 if (trace === Trace.Off || !tracer) {
13126 return;
13127 }
13128 if (traceFormat === TraceFormat.Text) {
13129 let data = undefined;
13130 if (trace === Trace.Verbose && message.params) {
13131 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
13132 }
13133 tracer.log(`Received request '${message.method} - (${message.id})'.`, data);
13134 }
13135 else {
13136 logLSPMessage('receive-request', message);
13137 }
13138 }
13139 function traceReceivedNotification(message) {
13140 if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {
13141 return;
13142 }
13143 if (traceFormat === TraceFormat.Text) {
13144 let data = undefined;
13145 if (trace === Trace.Verbose) {
13146 if (message.params) {
13147 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;
13148 }
13149 else {
13150 data = 'No parameters provided.\n\n';
13151 }
13152 }
13153 tracer.log(`Received notification '${message.method}'.`, data);
13154 }
13155 else {
13156 logLSPMessage('receive-notification', message);
13157 }
13158 }
13159 function traceReceivedResponse(message, responsePromise) {
13160 if (trace === Trace.Off || !tracer) {
13161 return;
13162 }
13163 if (traceFormat === TraceFormat.Text) {
13164 let data = undefined;
13165 if (trace === Trace.Verbose) {
13166 if (message.error && message.error.data) {
13167 data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;
13168 }
13169 else {
13170 if (message.result) {
13171 data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;
13172 }
13173 else if (message.error === void 0) {
13174 data = 'No result returned.\n\n';
13175 }
13176 }
13177 }
13178 if (responsePromise) {
13179 let error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';
13180 tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);
13181 }
13182 else {
13183 tracer.log(`Received response ${message.id} without active response promise.`, data);
13184 }
13185 }
13186 else {
13187 logLSPMessage('receive-response', message);
13188 }
13189 }
13190 function logLSPMessage(type, message) {
13191 if (!tracer || trace === Trace.Off) {
13192 return;
13193 }
13194 const lspMessage = {
13195 isLSPMessage: true,
13196 type,
13197 message,
13198 timestamp: Date.now()
13199 };
13200 tracer.log(lspMessage);
13201 }
13202 function throwIfClosedOrDisposed() {
13203 if (isClosed()) {
13204 throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');
13205 }
13206 if (isDisposed()) {
13207 throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');
13208 }
13209 }
13210 function throwIfListening() {
13211 if (isListening()) {
13212 throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');
13213 }
13214 }
13215 function throwIfNotListening() {
13216 if (!isListening()) {
13217 throw new Error('Call listen() first.');
13218 }
13219 }
13220 function undefinedToNull(param) {
13221 if (param === void 0) {
13222 return null;
13223 }
13224 else {
13225 return param;
13226 }
13227 }
13228 function computeMessageParams(type, params) {
13229 let result;
13230 let numberOfParams = type.numberOfParams;
13231 switch (numberOfParams) {
13232 case 0:
13233 result = null;
13234 break;
13235 case 1:
13236 result = undefinedToNull(params[0]);
13237 break;
13238 default:
13239 result = [];
13240 for (let i = 0; i < params.length && i < numberOfParams; i++) {
13241 result.push(undefinedToNull(params[i]));
13242 }
13243 if (params.length < numberOfParams) {
13244 for (let i = params.length; i < numberOfParams; i++) {
13245 result.push(null);
13246 }
13247 }
13248 break;
13249 }
13250 return result;
13251 }
13252 let connection = {
13253 sendNotification: (type, ...params) => {
13254 throwIfClosedOrDisposed();
13255 let method;
13256 let messageParams;
13257 if (Is.string(type)) {
13258 method = type;
13259 switch (params.length) {
13260 case 0:
13261 messageParams = null;
13262 break;
13263 case 1:
13264 messageParams = params[0];
13265 break;
13266 default:
13267 messageParams = params;
13268 break;
13269 }
13270 }
13271 else {
13272 method = type.method;
13273 messageParams = computeMessageParams(type, params);
13274 }
13275 let notificationMessage = {
13276 jsonrpc: version,
13277 method: method,
13278 params: messageParams
13279 };
13280 traceSendingNotification(notificationMessage);
13281 messageWriter.write(notificationMessage);
13282 },
13283 onNotification: (type, handler) => {
13284 throwIfClosedOrDisposed();
13285 if (Is.func(type)) {
13286 starNotificationHandler = type;
13287 }
13288 else if (handler) {
13289 if (Is.string(type)) {
13290 notificationHandlers[type] = { type: undefined, handler };
13291 }
13292 else {
13293 notificationHandlers[type.method] = { type, handler };
13294 }
13295 }
13296 },
13297 sendRequest: (type, ...params) => {
13298 throwIfClosedOrDisposed();
13299 throwIfNotListening();
13300 let method;
13301 let messageParams;
13302 let token = undefined;
13303 if (Is.string(type)) {
13304 method = type;
13305 switch (params.length) {
13306 case 0:
13307 messageParams = null;
13308 break;
13309 case 1:
13310 // The cancellation token is optional so it can also be undefined.
13311 if (cancellation_1.CancellationToken.is(params[0])) {
13312 messageParams = null;
13313 token = params[0];
13314 }
13315 else {
13316 messageParams = undefinedToNull(params[0]);
13317 }
13318 break;
13319 default:
13320 const last = params.length - 1;
13321 if (cancellation_1.CancellationToken.is(params[last])) {
13322 token = params[last];
13323 if (params.length === 2) {
13324 messageParams = undefinedToNull(params[0]);
13325 }
13326 else {
13327 messageParams = params.slice(0, last).map(value => undefinedToNull(value));
13328 }
13329 }
13330 else {
13331 messageParams = params.map(value => undefinedToNull(value));
13332 }
13333 break;
13334 }
13335 }
13336 else {
13337 method = type.method;
13338 messageParams = computeMessageParams(type, params);
13339 let numberOfParams = type.numberOfParams;
13340 token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : undefined;
13341 }
13342 let id = sequenceNumber++;
13343 let result = new Promise((resolve, reject) => {
13344 let requestMessage = {
13345 jsonrpc: version,
13346 id: id,
13347 method: method,
13348 params: messageParams
13349 };
13350 let responsePromise = { method: method, timerStart: Date.now(), resolve, reject };
13351 traceSendingRequest(requestMessage);
13352 try {
13353 messageWriter.write(requestMessage);
13354 }
13355 catch (e) {
13356 // Writing the message failed. So we need to reject the promise.
13357 responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));
13358 responsePromise = null;
13359 }
13360 if (responsePromise) {
13361 responsePromises[String(id)] = responsePromise;
13362 }
13363 });
13364 if (token) {
13365 token.onCancellationRequested(() => {
13366 connection.sendNotification(CancelNotification.type, { id });
13367 });
13368 }
13369 return result;
13370 },
13371 onRequest: (type, handler) => {
13372 throwIfClosedOrDisposed();
13373 if (Is.func(type)) {
13374 starRequestHandler = type;
13375 }
13376 else if (handler) {
13377 if (Is.string(type)) {
13378 requestHandlers[type] = { type: undefined, handler };
13379 }
13380 else {
13381 requestHandlers[type.method] = { type, handler };
13382 }
13383 }
13384 },
13385 trace: (_value, _tracer, sendNotificationOrTraceOptions) => {
13386 let _sendNotification = false;
13387 let _traceFormat = TraceFormat.Text;
13388 if (sendNotificationOrTraceOptions !== void 0) {
13389 if (Is.boolean(sendNotificationOrTraceOptions)) {
13390 _sendNotification = sendNotificationOrTraceOptions;
13391 }
13392 else {
13393 _sendNotification = sendNotificationOrTraceOptions.sendNotification || false;
13394 _traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;
13395 }
13396 }
13397 trace = _value;
13398 traceFormat = _traceFormat;
13399 if (trace === Trace.Off) {
13400 tracer = undefined;
13401 }
13402 else {
13403 tracer = _tracer;
13404 }
13405 if (_sendNotification && !isClosed() && !isDisposed()) {
13406 connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });
13407 }
13408 },
13409 onError: errorEmitter.event,
13410 onClose: closeEmitter.event,
13411 onUnhandledNotification: unhandledNotificationEmitter.event,
13412 onDispose: disposeEmitter.event,
13413 dispose: () => {
13414 if (isDisposed()) {
13415 return;
13416 }
13417 state = ConnectionState.Disposed;
13418 disposeEmitter.fire(undefined);
13419 let error = new Error('Connection got disposed.');
13420 Object.keys(responsePromises).forEach((key) => {
13421 responsePromises[key].reject(error);
13422 });
13423 responsePromises = Object.create(null);
13424 requestTokens = Object.create(null);
13425 messageQueue = new linkedMap_1.LinkedMap();
13426 // Test for backwards compatibility
13427 if (Is.func(messageWriter.dispose)) {
13428 messageWriter.dispose();
13429 }
13430 if (Is.func(messageReader.dispose)) {
13431 messageReader.dispose();
13432 }
13433 },
13434 listen: () => {
13435 throwIfClosedOrDisposed();
13436 throwIfListening();
13437 state = ConnectionState.Listening;
13438 messageReader.listen(callback);
13439 },
13440 inspect: () => {
13441 console.log("inspect");
13442 }
13443 };
13444 connection.onNotification(LogTraceNotification.type, (params) => {
13445 if (trace === Trace.Off || !tracer) {
13446 return;
13447 }
13448 tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);
13449 });
13450 return connection;
13451}
13452function isMessageReader(value) {
13453 return value.listen !== void 0 && value.read === void 0;
13454}
13455function isMessageWriter(value) {
13456 return value.write !== void 0 && value.end === void 0;
13457}
13458function createMessageConnection(input, output, logger, strategy) {
13459 if (!logger) {
13460 logger = exports.NullLogger;
13461 }
13462 let reader = isMessageReader(input) ? input : new messageReader_1.StreamMessageReader(input);
13463 let writer = isMessageWriter(output) ? output : new messageWriter_1.StreamMessageWriter(output);
13464 return _createMessageConnection(reader, writer, logger, strategy);
13465}
13466exports.createMessageConnection = createMessageConnection;
13467
13468
13469/***/ }),
13470
13471/***/ 7:
13472/***/ (function(module, exports, __webpack_require__) {
13473
13474"use strict";
13475/* --------------------------------------------------------------------------------------------
13476 * Copyright (c) Microsoft Corporation. All rights reserved.
13477 * Licensed under the MIT License. See License.txt in the project root for license information.
13478 * ------------------------------------------------------------------------------------------ */
13479
13480Object.defineProperty(exports, "__esModule", { value: true });
13481function boolean(value) {
13482 return value === true || value === false;
13483}
13484exports.boolean = boolean;
13485function string(value) {
13486 return typeof value === 'string' || value instanceof String;
13487}
13488exports.string = string;
13489function number(value) {
13490 return typeof value === 'number' || value instanceof Number;
13491}
13492exports.number = number;
13493function error(value) {
13494 return value instanceof Error;
13495}
13496exports.error = error;
13497function func(value) {
13498 return typeof value === 'function';
13499}
13500exports.func = func;
13501function array(value) {
13502 return Array.isArray(value);
13503}
13504exports.array = array;
13505function stringArray(value) {
13506 return array(value) && value.every(elem => string(elem));
13507}
13508exports.stringArray = stringArray;
13509
13510
13511/***/ }),
13512
13513/***/ 8:
13514/***/ (function(module, exports, __webpack_require__) {
13515
13516"use strict";
13517/* --------------------------------------------------------------------------------------------
13518 * Copyright (c) Microsoft Corporation. All rights reserved.
13519 * Licensed under the MIT License. See License.txt in the project root for license information.
13520 * ------------------------------------------------------------------------------------------ */
13521
13522Object.defineProperty(exports, "__esModule", { value: true });
13523const is = __webpack_require__(7);
13524/**
13525 * Predefined error codes.
13526 */
13527var ErrorCodes;
13528(function (ErrorCodes) {
13529 // Defined by JSON RPC
13530 ErrorCodes.ParseError = -32700;
13531 ErrorCodes.InvalidRequest = -32600;
13532 ErrorCodes.MethodNotFound = -32601;
13533 ErrorCodes.InvalidParams = -32602;
13534 ErrorCodes.InternalError = -32603;
13535 ErrorCodes.serverErrorStart = -32099;
13536 ErrorCodes.serverErrorEnd = -32000;
13537 ErrorCodes.ServerNotInitialized = -32002;
13538 ErrorCodes.UnknownErrorCode = -32001;
13539 // Defined by the protocol.
13540 ErrorCodes.RequestCancelled = -32800;
13541 // Defined by VSCode library.
13542 ErrorCodes.MessageWriteError = 1;
13543 ErrorCodes.MessageReadError = 2;
13544})(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));
13545/**
13546 * An error object return in a response in case a request
13547 * has failed.
13548 */
13549class ResponseError extends Error {
13550 constructor(code, message, data) {
13551 super(message);
13552 this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;
13553 this.data = data;
13554 Object.setPrototypeOf(this, ResponseError.prototype);
13555 }
13556 toJson() {
13557 return {
13558 code: this.code,
13559 message: this.message,
13560 data: this.data,
13561 };
13562 }
13563}
13564exports.ResponseError = ResponseError;
13565/**
13566 * An abstract implementation of a MessageType.
13567 */
13568class AbstractMessageType {
13569 constructor(_method, _numberOfParams) {
13570 this._method = _method;
13571 this._numberOfParams = _numberOfParams;
13572 }
13573 get method() {
13574 return this._method;
13575 }
13576 get numberOfParams() {
13577 return this._numberOfParams;
13578 }
13579}
13580exports.AbstractMessageType = AbstractMessageType;
13581/**
13582 * Classes to type request response pairs
13583 */
13584class RequestType0 extends AbstractMessageType {
13585 constructor(method) {
13586 super(method, 0);
13587 this._ = undefined;
13588 }
13589}
13590exports.RequestType0 = RequestType0;
13591class RequestType extends AbstractMessageType {
13592 constructor(method) {
13593 super(method, 1);
13594 this._ = undefined;
13595 }
13596}
13597exports.RequestType = RequestType;
13598class RequestType1 extends AbstractMessageType {
13599 constructor(method) {
13600 super(method, 1);
13601 this._ = undefined;
13602 }
13603}
13604exports.RequestType1 = RequestType1;
13605class RequestType2 extends AbstractMessageType {
13606 constructor(method) {
13607 super(method, 2);
13608 this._ = undefined;
13609 }
13610}
13611exports.RequestType2 = RequestType2;
13612class RequestType3 extends AbstractMessageType {
13613 constructor(method) {
13614 super(method, 3);
13615 this._ = undefined;
13616 }
13617}
13618exports.RequestType3 = RequestType3;
13619class RequestType4 extends AbstractMessageType {
13620 constructor(method) {
13621 super(method, 4);
13622 this._ = undefined;
13623 }
13624}
13625exports.RequestType4 = RequestType4;
13626class RequestType5 extends AbstractMessageType {
13627 constructor(method) {
13628 super(method, 5);
13629 this._ = undefined;
13630 }
13631}
13632exports.RequestType5 = RequestType5;
13633class RequestType6 extends AbstractMessageType {
13634 constructor(method) {
13635 super(method, 6);
13636 this._ = undefined;
13637 }
13638}
13639exports.RequestType6 = RequestType6;
13640class RequestType7 extends AbstractMessageType {
13641 constructor(method) {
13642 super(method, 7);
13643 this._ = undefined;
13644 }
13645}
13646exports.RequestType7 = RequestType7;
13647class RequestType8 extends AbstractMessageType {
13648 constructor(method) {
13649 super(method, 8);
13650 this._ = undefined;
13651 }
13652}
13653exports.RequestType8 = RequestType8;
13654class RequestType9 extends AbstractMessageType {
13655 constructor(method) {
13656 super(method, 9);
13657 this._ = undefined;
13658 }
13659}
13660exports.RequestType9 = RequestType9;
13661class NotificationType extends AbstractMessageType {
13662 constructor(method) {
13663 super(method, 1);
13664 this._ = undefined;
13665 }
13666}
13667exports.NotificationType = NotificationType;
13668class NotificationType0 extends AbstractMessageType {
13669 constructor(method) {
13670 super(method, 0);
13671 this._ = undefined;
13672 }
13673}
13674exports.NotificationType0 = NotificationType0;
13675class NotificationType1 extends AbstractMessageType {
13676 constructor(method) {
13677 super(method, 1);
13678 this._ = undefined;
13679 }
13680}
13681exports.NotificationType1 = NotificationType1;
13682class NotificationType2 extends AbstractMessageType {
13683 constructor(method) {
13684 super(method, 2);
13685 this._ = undefined;
13686 }
13687}
13688exports.NotificationType2 = NotificationType2;
13689class NotificationType3 extends AbstractMessageType {
13690 constructor(method) {
13691 super(method, 3);
13692 this._ = undefined;
13693 }
13694}
13695exports.NotificationType3 = NotificationType3;
13696class NotificationType4 extends AbstractMessageType {
13697 constructor(method) {
13698 super(method, 4);
13699 this._ = undefined;
13700 }
13701}
13702exports.NotificationType4 = NotificationType4;
13703class NotificationType5 extends AbstractMessageType {
13704 constructor(method) {
13705 super(method, 5);
13706 this._ = undefined;
13707 }
13708}
13709exports.NotificationType5 = NotificationType5;
13710class NotificationType6 extends AbstractMessageType {
13711 constructor(method) {
13712 super(method, 6);
13713 this._ = undefined;
13714 }
13715}
13716exports.NotificationType6 = NotificationType6;
13717class NotificationType7 extends AbstractMessageType {
13718 constructor(method) {
13719 super(method, 7);
13720 this._ = undefined;
13721 }
13722}
13723exports.NotificationType7 = NotificationType7;
13724class NotificationType8 extends AbstractMessageType {
13725 constructor(method) {
13726 super(method, 8);
13727 this._ = undefined;
13728 }
13729}
13730exports.NotificationType8 = NotificationType8;
13731class NotificationType9 extends AbstractMessageType {
13732 constructor(method) {
13733 super(method, 9);
13734 this._ = undefined;
13735 }
13736}
13737exports.NotificationType9 = NotificationType9;
13738/**
13739 * Tests if the given message is a request message
13740 */
13741function isRequestMessage(message) {
13742 let candidate = message;
13743 return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));
13744}
13745exports.isRequestMessage = isRequestMessage;
13746/**
13747 * Tests if the given message is a notification message
13748 */
13749function isNotificationMessage(message) {
13750 let candidate = message;
13751 return candidate && is.string(candidate.method) && message.id === void 0;
13752}
13753exports.isNotificationMessage = isNotificationMessage;
13754/**
13755 * Tests if the given message is a response message
13756 */
13757function isResponseMessage(message) {
13758 let candidate = message;
13759 return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);
13760}
13761exports.isResponseMessage = isResponseMessage;
13762
13763
13764/***/ }),
13765
13766/***/ 9:
13767/***/ (function(module, exports, __webpack_require__) {
13768
13769"use strict";
13770/* --------------------------------------------------------------------------------------------
13771 * Copyright (c) Microsoft Corporation. All rights reserved.
13772 * Licensed under the MIT License. See License.txt in the project root for license information.
13773 * ------------------------------------------------------------------------------------------ */
13774
13775Object.defineProperty(exports, "__esModule", { value: true });
13776const events_1 = __webpack_require__(10);
13777const Is = __webpack_require__(7);
13778let DefaultSize = 8192;
13779let CR = Buffer.from('\r', 'ascii')[0];
13780let LF = Buffer.from('\n', 'ascii')[0];
13781let CRLF = '\r\n';
13782class MessageBuffer {
13783 constructor(encoding = 'utf8') {
13784 this.encoding = encoding;
13785 this.index = 0;
13786 this.buffer = Buffer.allocUnsafe(DefaultSize);
13787 }
13788 append(chunk) {
13789 var toAppend = chunk;
13790 if (typeof (chunk) === 'string') {
13791 var str = chunk;
13792 var bufferLen = Buffer.byteLength(str, this.encoding);
13793 toAppend = Buffer.allocUnsafe(bufferLen);
13794 toAppend.write(str, 0, bufferLen, this.encoding);
13795 }
13796 if (this.buffer.length - this.index >= toAppend.length) {
13797 toAppend.copy(this.buffer, this.index, 0, toAppend.length);
13798 }
13799 else {
13800 var newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize;
13801 if (this.index === 0) {
13802 this.buffer = Buffer.allocUnsafe(newSize);
13803 toAppend.copy(this.buffer, 0, 0, toAppend.length);
13804 }
13805 else {
13806 this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);
13807 }
13808 }
13809 this.index += toAppend.length;
13810 }
13811 tryReadHeaders() {
13812 let result = undefined;
13813 let current = 0;
13814 while (current + 3 < this.index && (this.buffer[current] !== CR || this.buffer[current + 1] !== LF || this.buffer[current + 2] !== CR || this.buffer[current + 3] !== LF)) {
13815 current++;
13816 }
13817 // No header / body separator found (e.g CRLFCRLF)
13818 if (current + 3 >= this.index) {
13819 return result;
13820 }
13821 result = Object.create(null);
13822 let headers = this.buffer.toString('ascii', 0, current).split(CRLF);
13823 headers.forEach((header) => {
13824 let index = header.indexOf(':');
13825 if (index === -1) {
13826 throw new Error('Message header must separate key and value using :');
13827 }
13828 let key = header.substr(0, index);
13829 let value = header.substr(index + 1).trim();
13830 result[key] = value;
13831 });
13832 let nextStart = current + 4;
13833 this.buffer = this.buffer.slice(nextStart);
13834 this.index = this.index - nextStart;
13835 return result;
13836 }
13837 tryReadContent(length) {
13838 if (this.index < length) {
13839 return null;
13840 }
13841 let result = this.buffer.toString(this.encoding, 0, length);
13842 let nextStart = length;
13843 this.buffer.copy(this.buffer, 0, nextStart);
13844 this.index = this.index - nextStart;
13845 return result;
13846 }
13847 get numberOfBytes() {
13848 return this.index;
13849 }
13850}
13851var MessageReader;
13852(function (MessageReader) {
13853 function is(value) {
13854 let candidate = value;
13855 return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) &&
13856 Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);
13857 }
13858 MessageReader.is = is;
13859})(MessageReader = exports.MessageReader || (exports.MessageReader = {}));
13860class AbstractMessageReader {
13861 constructor() {
13862 this.errorEmitter = new events_1.Emitter();
13863 this.closeEmitter = new events_1.Emitter();
13864 this.partialMessageEmitter = new events_1.Emitter();
13865 }
13866 dispose() {
13867 this.errorEmitter.dispose();
13868 this.closeEmitter.dispose();
13869 }
13870 get onError() {
13871 return this.errorEmitter.event;
13872 }
13873 fireError(error) {
13874 this.errorEmitter.fire(this.asError(error));
13875 }
13876 get onClose() {
13877 return this.closeEmitter.event;
13878 }
13879 fireClose() {
13880 this.closeEmitter.fire(undefined);
13881 }
13882 get onPartialMessage() {
13883 return this.partialMessageEmitter.event;
13884 }
13885 firePartialMessage(info) {
13886 this.partialMessageEmitter.fire(info);
13887 }
13888 asError(error) {
13889 if (error instanceof Error) {
13890 return error;
13891 }
13892 else {
13893 return new Error(`Reader recevied error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);
13894 }
13895 }
13896}
13897exports.AbstractMessageReader = AbstractMessageReader;
13898class StreamMessageReader extends AbstractMessageReader {
13899 constructor(readable, encoding = 'utf8') {
13900 super();
13901 this.readable = readable;
13902 this.buffer = new MessageBuffer(encoding);
13903 this._partialMessageTimeout = 10000;
13904 }
13905 set partialMessageTimeout(timeout) {
13906 this._partialMessageTimeout = timeout;
13907 }
13908 get partialMessageTimeout() {
13909 return this._partialMessageTimeout;
13910 }
13911 listen(callback) {
13912 this.nextMessageLength = -1;
13913 this.messageToken = 0;
13914 this.partialMessageTimer = undefined;
13915 this.callback = callback;
13916 this.readable.on('data', (data) => {
13917 this.onData(data);
13918 });
13919 this.readable.on('error', (error) => this.fireError(error));
13920 this.readable.on('close', () => this.fireClose());
13921 }
13922 onData(data) {
13923 this.buffer.append(data);
13924 while (true) {
13925 if (this.nextMessageLength === -1) {
13926 let headers = this.buffer.tryReadHeaders();
13927 if (!headers) {
13928 return;
13929 }
13930 let contentLength = headers['Content-Length'];
13931 if (!contentLength) {
13932 throw new Error('Header must provide a Content-Length property.');
13933 }
13934 let length = parseInt(contentLength);
13935 if (isNaN(length)) {
13936 throw new Error('Content-Length value must be a number.');
13937 }
13938 this.nextMessageLength = length;
13939 // Take the encoding form the header. For compatibility
13940 // treat both utf-8 and utf8 as node utf8
13941 }
13942 var msg = this.buffer.tryReadContent(this.nextMessageLength);
13943 if (msg === null) {
13944 /** We haven't recevied the full message yet. */
13945 this.setPartialMessageTimer();
13946 return;
13947 }
13948 this.clearPartialMessageTimer();
13949 this.nextMessageLength = -1;
13950 this.messageToken++;
13951 var json = JSON.parse(msg);
13952 this.callback(json);
13953 }
13954 }
13955 clearPartialMessageTimer() {
13956 if (this.partialMessageTimer) {
13957 clearTimeout(this.partialMessageTimer);
13958 this.partialMessageTimer = undefined;
13959 }
13960 }
13961 setPartialMessageTimer() {
13962 this.clearPartialMessageTimer();
13963 if (this._partialMessageTimeout <= 0) {
13964 return;
13965 }
13966 this.partialMessageTimer = setTimeout((token, timeout) => {
13967 this.partialMessageTimer = undefined;
13968 if (token === this.messageToken) {
13969 this.firePartialMessage({ messageToken: token, waitingTime: timeout });
13970 this.setPartialMessageTimer();
13971 }
13972 }, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);
13973 }
13974}
13975exports.StreamMessageReader = StreamMessageReader;
13976class IPCMessageReader extends AbstractMessageReader {
13977 constructor(process) {
13978 super();
13979 this.process = process;
13980 let eventEmitter = this.process;
13981 eventEmitter.on('error', (error) => this.fireError(error));
13982 eventEmitter.on('close', () => this.fireClose());
13983 }
13984 listen(callback) {
13985 this.process.on('message', callback);
13986 }
13987}
13988exports.IPCMessageReader = IPCMessageReader;
13989class SocketMessageReader extends StreamMessageReader {
13990 constructor(socket, encoding = 'utf-8') {
13991 super(socket, encoding);
13992 }
13993}
13994exports.SocketMessageReader = SocketMessageReader;
13995
13996
13997/***/ })
13998
13999/******/ })));
\No newline at end of file