monaco-languageclient 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1195 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProtocolToMonacoConverter = exports.MonacoToProtocolConverter = exports.ProtocolInlayHint = exports.ProtocolCodeAction = exports.ProtocolCompletionItem = exports.ProtocolCodeLens = exports.ProtocolDocumentLink = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const ls = tslib_1.__importStar(require("vscode-languageserver-protocol"));
6
+ const Is = tslib_1.__importStar(require("vscode-languageserver-protocol/lib/common/utils/is"));
7
+ const api_1 = require("vscode-languageserver-protocol/lib/common/api");
8
+ var ProtocolDocumentLink;
9
+ (function (ProtocolDocumentLink) {
10
+ function is(item) {
11
+ return !!item && 'data' in item;
12
+ }
13
+ ProtocolDocumentLink.is = is;
14
+ })(ProtocolDocumentLink = exports.ProtocolDocumentLink || (exports.ProtocolDocumentLink = {}));
15
+ var ProtocolCodeLens;
16
+ (function (ProtocolCodeLens) {
17
+ function is(item) {
18
+ return !!item && 'data' in item;
19
+ }
20
+ ProtocolCodeLens.is = is;
21
+ })(ProtocolCodeLens = exports.ProtocolCodeLens || (exports.ProtocolCodeLens = {}));
22
+ var ProtocolCompletionItem;
23
+ (function (ProtocolCompletionItem) {
24
+ function is(item) {
25
+ return !!item && 'data' in item;
26
+ }
27
+ ProtocolCompletionItem.is = is;
28
+ })(ProtocolCompletionItem = exports.ProtocolCompletionItem || (exports.ProtocolCompletionItem = {}));
29
+ var ProtocolCodeAction;
30
+ (function (ProtocolCodeAction) {
31
+ function is(item) {
32
+ return !!item && 'data' in item;
33
+ }
34
+ ProtocolCodeAction.is = is;
35
+ })(ProtocolCodeAction = exports.ProtocolCodeAction || (exports.ProtocolCodeAction = {}));
36
+ var ProtocolInlayHint;
37
+ (function (ProtocolInlayHint) {
38
+ function is(item) {
39
+ return !!item && 'data' in item;
40
+ }
41
+ ProtocolInlayHint.is = is;
42
+ })(ProtocolInlayHint = exports.ProtocolInlayHint || (exports.ProtocolInlayHint = {}));
43
+ function isRangeReplace(v) {
44
+ return v.insert !== undefined;
45
+ }
46
+ /**
47
+ * @deprecated use @CodinGame/monaco-vscode-api and vscode-languageclient/lib/common/codeConverter (see browser example)
48
+ */
49
+ class MonacoToProtocolConverter {
50
+ constructor(_monaco) {
51
+ this._monaco = _monaco;
52
+ }
53
+ asPosition(lineNumber, column) {
54
+ const line = lineNumber === undefined || lineNumber === null ? undefined : lineNumber - 1;
55
+ const character = column === undefined || column === null ? undefined : column - 1;
56
+ return {
57
+ line, character
58
+ };
59
+ }
60
+ asRange(range) {
61
+ if (range === undefined) {
62
+ return undefined;
63
+ }
64
+ if (range === null) {
65
+ return null;
66
+ }
67
+ if (isRangeReplace(range)) {
68
+ return this.asRange(range.insert);
69
+ }
70
+ else {
71
+ const start = this.asPosition(range.startLineNumber, range.startColumn);
72
+ const end = this.asPosition(range.endLineNumber, range.endColumn);
73
+ return {
74
+ start, end
75
+ };
76
+ }
77
+ }
78
+ asLocation(item) {
79
+ if (!item) {
80
+ return undefined;
81
+ }
82
+ const uri = item.uri.toString();
83
+ const range = this.asRange(item.range);
84
+ return {
85
+ uri,
86
+ range
87
+ };
88
+ }
89
+ asTextDocumentIdentifier(model) {
90
+ return {
91
+ uri: model.uri.toString()
92
+ };
93
+ }
94
+ asTextDocumentPositionParams(model, position) {
95
+ return {
96
+ textDocument: this.asTextDocumentIdentifier(model),
97
+ position: this.asPosition(position.lineNumber, position.column)
98
+ };
99
+ }
100
+ asCompletionParams(model, position, context) {
101
+ return Object.assign(this.asTextDocumentPositionParams(model, position), {
102
+ context: this.asCompletionContext(context)
103
+ });
104
+ }
105
+ asCompletionContext(context) {
106
+ return {
107
+ triggerKind: this.asCompletionTriggerKind(context.triggerKind),
108
+ triggerCharacter: context.triggerCharacter
109
+ };
110
+ }
111
+ asSignatureHelpContext(context) {
112
+ return {
113
+ triggerKind: this.asSignatureHelpTriggerKind(context.triggerKind),
114
+ triggerCharacter: context.triggerCharacter,
115
+ isRetrigger: context.isRetrigger,
116
+ activeSignatureHelp: this.asSignatureHelp(context.activeSignatureHelp)
117
+ };
118
+ }
119
+ asSignatureHelp(signatureHelp) {
120
+ if (signatureHelp === undefined) {
121
+ return undefined;
122
+ }
123
+ return {
124
+ signatures: signatureHelp.signatures.map(signatureInfo => this.asSignatureInformation(signatureInfo)),
125
+ activeParameter: signatureHelp.activeParameter,
126
+ activeSignature: signatureHelp.activeSignature
127
+ };
128
+ }
129
+ asSignatureInformation(signatureInformation) {
130
+ return {
131
+ documentation: this.asMarkupContent(signatureInformation.documentation),
132
+ label: signatureInformation.label,
133
+ parameters: signatureInformation.parameters.map(paramInfo => this.asParameterInformation(paramInfo)),
134
+ activeParameter: signatureInformation.activeParameter
135
+ };
136
+ }
137
+ asParameterInformation(parameterInformation) {
138
+ return {
139
+ documentation: this.asMarkupContent(parameterInformation.documentation),
140
+ label: parameterInformation.label
141
+ };
142
+ }
143
+ asMarkupContent(markupContent) {
144
+ if (markupContent === undefined) {
145
+ return undefined;
146
+ }
147
+ if (typeof markupContent === 'string') {
148
+ return markupContent;
149
+ }
150
+ return {
151
+ kind: api_1.MarkupKind.Markdown,
152
+ value: markupContent.value
153
+ };
154
+ }
155
+ asSignatureHelpTriggerKind(triggerKind) {
156
+ switch (triggerKind) {
157
+ case this._monaco.languages.SignatureHelpTriggerKind.ContentChange:
158
+ return api_1.SignatureHelpTriggerKind.ContentChange;
159
+ case this._monaco.languages.SignatureHelpTriggerKind.TriggerCharacter:
160
+ return api_1.SignatureHelpTriggerKind.TriggerCharacter;
161
+ default:
162
+ return api_1.SignatureHelpTriggerKind.Invoked;
163
+ }
164
+ }
165
+ asCompletionTriggerKind(triggerKind) {
166
+ switch (triggerKind) {
167
+ case this._monaco.languages.CompletionTriggerKind.TriggerCharacter:
168
+ return api_1.CompletionTriggerKind.TriggerCharacter;
169
+ case this._monaco.languages.CompletionTriggerKind.TriggerForIncompleteCompletions:
170
+ return api_1.CompletionTriggerKind.TriggerForIncompleteCompletions;
171
+ default:
172
+ return api_1.CompletionTriggerKind.Invoked;
173
+ }
174
+ }
175
+ asCompletionItem(item) {
176
+ const result = { label: item.label };
177
+ const protocolItem = ProtocolCompletionItem.is(item) ? item : undefined;
178
+ if (item.detail) {
179
+ result.detail = item.detail;
180
+ }
181
+ if (item.documentation) {
182
+ if (typeof item.documentation === 'string') {
183
+ result.documentation = item.documentation;
184
+ }
185
+ else {
186
+ result.documentation = this.asDocumentation(protocolItem?.documentationFormat ?? api_1.MarkupKind.Markdown, item.documentation);
187
+ }
188
+ }
189
+ if (item.filterText) {
190
+ result.filterText = item.filterText;
191
+ }
192
+ this.fillPrimaryInsertText(result, item);
193
+ if (Is.number(item.kind)) {
194
+ result.kind = this.asCompletionItemKind(item.kind, protocolItem && protocolItem.originalItemKind);
195
+ }
196
+ if (item.sortText) {
197
+ result.sortText = item.sortText;
198
+ }
199
+ if (item.additionalTextEdits) {
200
+ result.additionalTextEdits = this.asTextEdits(item.additionalTextEdits);
201
+ }
202
+ if (item.command) {
203
+ result.command = this.asCommand(item.command);
204
+ }
205
+ if (item.commitCharacters) {
206
+ result.commitCharacters = item.commitCharacters.slice();
207
+ }
208
+ if (item.command) {
209
+ result.command = this.asCommand(item.command);
210
+ }
211
+ if (item.preselect === true || item.preselect === false) {
212
+ result.preselect = item.preselect;
213
+ }
214
+ if (protocolItem) {
215
+ if (protocolItem.data !== undefined) {
216
+ result.data = protocolItem.data;
217
+ }
218
+ if (protocolItem.deprecated === true || protocolItem.deprecated === false) {
219
+ result.deprecated = protocolItem.deprecated;
220
+ }
221
+ }
222
+ if (item.tags) {
223
+ result.tags = item.tags?.slice();
224
+ }
225
+ return result;
226
+ }
227
+ asCompletionItemKind(value, original) {
228
+ if (original !== undefined) {
229
+ return original;
230
+ }
231
+ switch (value) {
232
+ case this._monaco.languages.CompletionItemKind.Method: return api_1.CompletionItemKind.Method;
233
+ case this._monaco.languages.CompletionItemKind.Function: return api_1.CompletionItemKind.Function;
234
+ case this._monaco.languages.CompletionItemKind.Constructor: return api_1.CompletionItemKind.Constructor;
235
+ case this._monaco.languages.CompletionItemKind.Field: return api_1.CompletionItemKind.Field;
236
+ case this._monaco.languages.CompletionItemKind.Variable: return api_1.CompletionItemKind.Variable;
237
+ case this._monaco.languages.CompletionItemKind.Class: return api_1.CompletionItemKind.Class;
238
+ case this._monaco.languages.CompletionItemKind.Struct: return api_1.CompletionItemKind.Struct;
239
+ case this._monaco.languages.CompletionItemKind.Interface: return api_1.CompletionItemKind.Interface;
240
+ case this._monaco.languages.CompletionItemKind.Module: return api_1.CompletionItemKind.Module;
241
+ case this._monaco.languages.CompletionItemKind.Property: return api_1.CompletionItemKind.Property;
242
+ case this._monaco.languages.CompletionItemKind.Event: return api_1.CompletionItemKind.Event;
243
+ case this._monaco.languages.CompletionItemKind.Operator: return api_1.CompletionItemKind.Operator;
244
+ case this._monaco.languages.CompletionItemKind.Unit: return api_1.CompletionItemKind.Unit;
245
+ case this._monaco.languages.CompletionItemKind.Value: return api_1.CompletionItemKind.Value;
246
+ case this._monaco.languages.CompletionItemKind.Constant: return api_1.CompletionItemKind.Constant;
247
+ case this._monaco.languages.CompletionItemKind.Enum: return api_1.CompletionItemKind.Enum;
248
+ case this._monaco.languages.CompletionItemKind.EnumMember: return api_1.CompletionItemKind.EnumMember;
249
+ case this._monaco.languages.CompletionItemKind.Keyword: return api_1.CompletionItemKind.Keyword;
250
+ case this._monaco.languages.CompletionItemKind.Text: return api_1.CompletionItemKind.Text;
251
+ case this._monaco.languages.CompletionItemKind.Color: return api_1.CompletionItemKind.Color;
252
+ case this._monaco.languages.CompletionItemKind.File: return api_1.CompletionItemKind.File;
253
+ case this._monaco.languages.CompletionItemKind.Reference: return api_1.CompletionItemKind.Reference;
254
+ case this._monaco.languages.CompletionItemKind.Customcolor: return api_1.CompletionItemKind.Color;
255
+ case this._monaco.languages.CompletionItemKind.Folder: return api_1.CompletionItemKind.Folder;
256
+ case this._monaco.languages.CompletionItemKind.TypeParameter: return api_1.CompletionItemKind.TypeParameter;
257
+ case this._monaco.languages.CompletionItemKind.Snippet: return api_1.CompletionItemKind.Snippet;
258
+ default: return value + 1;
259
+ }
260
+ }
261
+ asDocumentation(format, documentation) {
262
+ switch (format) {
263
+ case api_1.MarkupKind.PlainText:
264
+ return { kind: format, value: documentation };
265
+ case api_1.MarkupKind.Markdown:
266
+ return { kind: format, value: documentation.value };
267
+ default:
268
+ return `Unsupported Markup content received. Kind is: ${format}`;
269
+ }
270
+ }
271
+ fillPrimaryInsertText(target, source) {
272
+ let format = api_1.InsertTextFormat.PlainText;
273
+ let text;
274
+ let range;
275
+ if (source.insertTextRules !== undefined && (source.insertTextRules & this._monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet) === 0) {
276
+ format = api_1.InsertTextFormat.Snippet;
277
+ text = source.insertText;
278
+ }
279
+ target.insertTextFormat = format;
280
+ text = source.insertText;
281
+ if (source.range) {
282
+ range = this.asRange(source.range);
283
+ }
284
+ target.insertTextFormat = format;
285
+ if (source.fromEdit && text && range) {
286
+ target.textEdit = { newText: text, range };
287
+ }
288
+ else {
289
+ target.insertText = text;
290
+ }
291
+ target.insertTextMode = source.insertTextMode;
292
+ }
293
+ asTextEdit(edit) {
294
+ const range = this.asRange(edit.range);
295
+ return {
296
+ range,
297
+ newText: edit.text || ''
298
+ };
299
+ }
300
+ asTextEdits(items) {
301
+ if (!items) {
302
+ return undefined;
303
+ }
304
+ return items.map(item => this.asTextEdit(item));
305
+ }
306
+ asReferenceParams(model, position, options) {
307
+ return {
308
+ textDocument: this.asTextDocumentIdentifier(model),
309
+ position: this.asPosition(position.lineNumber, position.column),
310
+ context: { includeDeclaration: options.includeDeclaration }
311
+ };
312
+ }
313
+ asDocumentSymbolParams(model) {
314
+ return {
315
+ textDocument: this.asTextDocumentIdentifier(model)
316
+ };
317
+ }
318
+ asCodeLensParams(model) {
319
+ return {
320
+ textDocument: this.asTextDocumentIdentifier(model)
321
+ };
322
+ }
323
+ asDiagnosticSeverity(value) {
324
+ switch (value) {
325
+ case this._monaco.MarkerSeverity.Error:
326
+ return api_1.DiagnosticSeverity.Error;
327
+ case this._monaco.MarkerSeverity.Warning:
328
+ return api_1.DiagnosticSeverity.Warning;
329
+ case this._monaco.MarkerSeverity.Info:
330
+ return api_1.DiagnosticSeverity.Information;
331
+ case this._monaco.MarkerSeverity.Hint:
332
+ return api_1.DiagnosticSeverity.Hint;
333
+ }
334
+ return undefined;
335
+ }
336
+ asDiagnostic(marker) {
337
+ const range = this.asRange(new this._monaco.Range(marker.startLineNumber, marker.startColumn, marker.endLineNumber, marker.endColumn));
338
+ const severity = this.asDiagnosticSeverity(marker.severity);
339
+ const diag = api_1.Diagnostic.create(range, marker.message, severity, marker.code, marker.source);
340
+ return diag;
341
+ }
342
+ asDiagnostics(markers) {
343
+ if (markers === void 0 || markers === null) {
344
+ return markers;
345
+ }
346
+ return markers.map(marker => this.asDiagnostic(marker));
347
+ }
348
+ asCodeActionContext(context, diagnostics) {
349
+ if (context === void 0 || context === null) {
350
+ return context;
351
+ }
352
+ // FIXME: CodeActionTriggerKind is missing
353
+ return api_1.CodeActionContext.create(diagnostics, Is.string(context.only) ? [context.only] : undefined, undefined);
354
+ }
355
+ asCodeActionParams(model, range, context, diagnostics) {
356
+ return {
357
+ textDocument: this.asTextDocumentIdentifier(model),
358
+ range: this.asRange(range),
359
+ context: this.asCodeActionContext(context, diagnostics)
360
+ };
361
+ }
362
+ asCommand(item) {
363
+ if (item) {
364
+ const args = item.arguments || [];
365
+ return api_1.Command.create(item.title, item.id, ...args);
366
+ }
367
+ return undefined;
368
+ }
369
+ asCodeLens(item) {
370
+ const result = api_1.CodeLens.create(this.asRange(item.range));
371
+ if (item.command) {
372
+ result.command = this.asCommand(item.command);
373
+ }
374
+ if (ProtocolCodeLens.is(item)) {
375
+ if (item.data) {
376
+ result.data = item.data;
377
+ }
378
+ }
379
+ return result;
380
+ }
381
+ asFormattingOptions(options) {
382
+ return { tabSize: options.tabSize, insertSpaces: options.insertSpaces };
383
+ }
384
+ asDocumentFormattingParams(model, options) {
385
+ return {
386
+ textDocument: this.asTextDocumentIdentifier(model),
387
+ options: this.asFormattingOptions(options)
388
+ };
389
+ }
390
+ asDocumentRangeFormattingParams(model, range, options) {
391
+ return {
392
+ textDocument: this.asTextDocumentIdentifier(model),
393
+ range: this.asRange(range),
394
+ options: this.asFormattingOptions(options)
395
+ };
396
+ }
397
+ asDocumentOnTypeFormattingParams(model, position, ch, options) {
398
+ return {
399
+ textDocument: this.asTextDocumentIdentifier(model),
400
+ position: this.asPosition(position.lineNumber, position.column),
401
+ ch,
402
+ options: this.asFormattingOptions(options)
403
+ };
404
+ }
405
+ asRenameParams(model, position, newName) {
406
+ return {
407
+ textDocument: this.asTextDocumentIdentifier(model),
408
+ position: this.asPosition(position.lineNumber, position.column),
409
+ newName
410
+ };
411
+ }
412
+ asDocumentLinkParams(model) {
413
+ return {
414
+ textDocument: this.asTextDocumentIdentifier(model)
415
+ };
416
+ }
417
+ asDocumentLink(item) {
418
+ const result = api_1.DocumentLink.create(this.asRange(item.range));
419
+ if (item.url) {
420
+ result.target = typeof item.url === 'string' ? item.url : item.url.toString();
421
+ }
422
+ if (ProtocolDocumentLink.is(item) && item.data) {
423
+ result.data = item.data;
424
+ }
425
+ if (item.tooltip) {
426
+ result.tooltip = item.tooltip;
427
+ }
428
+ return result;
429
+ }
430
+ asCodeAction(item) {
431
+ const result = { title: item.title };
432
+ const protocolCodeAction = ProtocolCodeAction.is(item) ? item : undefined;
433
+ if (Is.number(item.kind)) {
434
+ result.kind = item.kind;
435
+ }
436
+ if (item.diagnostics) {
437
+ result.diagnostics = this.asDiagnostics(item.diagnostics);
438
+ }
439
+ if (item.edit) {
440
+ throw new Error('VS Code code actions can only be converted to a protocol code action without an edit.');
441
+ }
442
+ if (item.command) {
443
+ result.command = this.asCommand(item.command);
444
+ }
445
+ if (item.isPreferred !== undefined) {
446
+ result.isPreferred = item.isPreferred;
447
+ }
448
+ if (item.disabled) {
449
+ result.disabled = { reason: item.disabled };
450
+ }
451
+ if (protocolCodeAction) {
452
+ if (protocolCodeAction.data !== undefined) {
453
+ result.data = protocolCodeAction.data;
454
+ }
455
+ }
456
+ return result;
457
+ }
458
+ asInlayHintLabelPart(part) {
459
+ return {
460
+ value: part.label,
461
+ command: this.asCommand(part.command),
462
+ location: this.asLocation(part.location),
463
+ tooltip: this.asMarkupContent(part.tooltip)
464
+ };
465
+ }
466
+ asInlayHintLabel(label) {
467
+ if (Array.isArray(label)) {
468
+ return label.map(part => this.asInlayHintLabelPart(part));
469
+ }
470
+ return label;
471
+ }
472
+ asInlayHint(item) {
473
+ const result = api_1.InlayHint.create(this.asPosition(item.position.lineNumber, item.position.column), this.asInlayHintLabel(item.label), item.kind);
474
+ if (ProtocolInlayHint.is(item)) {
475
+ if (item.data) {
476
+ result.data = item.data;
477
+ }
478
+ }
479
+ return result;
480
+ }
481
+ }
482
+ exports.MonacoToProtocolConverter = MonacoToProtocolConverter;
483
+ /**
484
+ * @deprecated use @CodinGame/monaco-vscode-api and vscode-languageclient/lib/common/protocolConverter (see browser example)
485
+ */
486
+ class ProtocolToMonacoConverter {
487
+ constructor(_monaco) {
488
+ this._monaco = _monaco;
489
+ }
490
+ asResourceEdits(resource, edits, asMetadata, modelVersionId) {
491
+ return edits.map(edit => ({
492
+ resource,
493
+ edit: this.asTextEdit(edit),
494
+ modelVersionId,
495
+ metadata: api_1.AnnotatedTextEdit.is(edit) ? asMetadata(edit.annotationId) : undefined
496
+ }));
497
+ }
498
+ asWorkspaceEditMetadata(changeAnnotation) {
499
+ return {
500
+ needsConfirmation: changeAnnotation.needsConfirmation === true,
501
+ label: changeAnnotation.label,
502
+ description: changeAnnotation.description
503
+ };
504
+ }
505
+ asWorkspaceEdit(item) {
506
+ if (!item) {
507
+ return undefined;
508
+ }
509
+ const sharedMetadata = new Map();
510
+ if (item.changeAnnotations !== undefined) {
511
+ for (const key of Object.keys(item.changeAnnotations)) {
512
+ const metaData = this.asWorkspaceEditMetadata(item.changeAnnotations[key]);
513
+ sharedMetadata.set(key, metaData);
514
+ }
515
+ }
516
+ const asMetadata = (annotation) => {
517
+ if (annotation === undefined) {
518
+ return undefined;
519
+ }
520
+ else {
521
+ return sharedMetadata.get(annotation);
522
+ }
523
+ };
524
+ const edits = [];
525
+ if (item.documentChanges) {
526
+ item.documentChanges.forEach(change => {
527
+ if (ls.CreateFile.is(change)) {
528
+ edits.push({
529
+ newUri: this._monaco.Uri.parse(change.uri),
530
+ options: change.options,
531
+ metadata: asMetadata(change.annotationId)
532
+ });
533
+ }
534
+ else if (ls.RenameFile.is(change)) {
535
+ edits.push({
536
+ oldUri: this._monaco.Uri.parse(change.oldUri),
537
+ newUri: this._monaco.Uri.parse(change.newUri),
538
+ options: change.options,
539
+ metadata: asMetadata(change.annotationId)
540
+ });
541
+ }
542
+ else if (ls.DeleteFile.is(change)) {
543
+ edits.push({
544
+ oldUri: this._monaco.Uri.parse(change.uri),
545
+ options: change.options,
546
+ metadata: asMetadata(change.annotationId)
547
+ });
548
+ }
549
+ else if (ls.TextDocumentEdit.is(change)) {
550
+ const resource = this._monaco.Uri.parse(change.textDocument.uri);
551
+ const version = typeof change.textDocument.version === 'number' ? change.textDocument.version : undefined;
552
+ edits.push(...this.asResourceEdits(resource, change.edits, asMetadata, version));
553
+ }
554
+ else {
555
+ console.error(`Unknown workspace edit change received:\n${JSON.stringify(change, undefined, 4)}`);
556
+ }
557
+ });
558
+ }
559
+ else if (item.changes) {
560
+ for (const key of Object.keys(item.changes)) {
561
+ const resource = this._monaco.Uri.parse(key);
562
+ edits.push(...this.asResourceEdits(resource, item.changes[key], asMetadata));
563
+ }
564
+ }
565
+ return {
566
+ edits
567
+ };
568
+ }
569
+ asTextEdit(edit) {
570
+ if (!edit) {
571
+ return undefined;
572
+ }
573
+ const range = this.asRange(edit.range);
574
+ return {
575
+ range,
576
+ text: edit.newText
577
+ };
578
+ }
579
+ asTextEdits(items) {
580
+ if (!items) {
581
+ return undefined;
582
+ }
583
+ return items.map(item => this.asTextEdit(item));
584
+ }
585
+ asCodeLens(item) {
586
+ if (!item) {
587
+ return undefined;
588
+ }
589
+ const range = this.asRange(item.range);
590
+ const result = { range };
591
+ if (item.command) {
592
+ result.command = this.asCommand(item.command);
593
+ }
594
+ if (item.data !== void 0 && item.data !== null) {
595
+ result.data = item.data;
596
+ }
597
+ return result;
598
+ }
599
+ asCodeLensList(items) {
600
+ if (!items) {
601
+ return undefined;
602
+ }
603
+ return {
604
+ lenses: items.map((codeLens) => this.asCodeLens(codeLens)),
605
+ dispose: () => { }
606
+ };
607
+ }
608
+ asCodeActionList(actions) {
609
+ return {
610
+ actions: actions.map(action => this.asCodeAction(action)),
611
+ dispose: () => { }
612
+ };
613
+ }
614
+ asCodeAction(item) {
615
+ if (api_1.Command.is(item)) {
616
+ return {
617
+ command: {
618
+ id: item.command,
619
+ title: item.title,
620
+ arguments: item.arguments
621
+ },
622
+ title: item.title
623
+ };
624
+ }
625
+ return {
626
+ title: item.title,
627
+ command: this.asCommand(item.command),
628
+ edit: this.asWorkspaceEdit(item.edit),
629
+ diagnostics: this.asDiagnostics(item.diagnostics),
630
+ kind: item.kind,
631
+ disabled: item.disabled ? item.disabled.reason : undefined,
632
+ isPreferred: item.isPreferred,
633
+ data: item.data
634
+ };
635
+ }
636
+ asCommand(command) {
637
+ if (!command) {
638
+ return undefined;
639
+ }
640
+ return {
641
+ id: command.command,
642
+ title: command.title,
643
+ arguments: command.arguments
644
+ };
645
+ }
646
+ asDocumentSymbol(value) {
647
+ const children = value.children && value.children.map(c => this.asDocumentSymbol(c));
648
+ return {
649
+ name: value.name,
650
+ detail: value.detail || '',
651
+ kind: this.asSymbolKind(value.kind),
652
+ tags: value.tags || [],
653
+ range: this.asRange(value.range),
654
+ selectionRange: this.asRange(value.selectionRange),
655
+ children
656
+ };
657
+ }
658
+ asDocumentSymbols(values) {
659
+ if (api_1.DocumentSymbol.is(values[0])) {
660
+ return values.map(s => this.asDocumentSymbol(s));
661
+ }
662
+ return this.asSymbolInformations(values);
663
+ }
664
+ asSymbolInformations(values, uri) {
665
+ if (!values) {
666
+ return undefined;
667
+ }
668
+ return values.map(information => this.asSymbolInformation(information, uri));
669
+ }
670
+ asSymbolInformation(item, uri) {
671
+ const location = this.asLocation(uri ? { ...item.location, uri: uri.toString() } : item.location);
672
+ return {
673
+ name: item.name,
674
+ detail: '',
675
+ containerName: item.containerName,
676
+ kind: this.asSymbolKind(item.kind),
677
+ tags: item.tags || [],
678
+ range: location.range,
679
+ selectionRange: location.range
680
+ };
681
+ }
682
+ asSymbolKind(item) {
683
+ if (item <= api_1.SymbolKind.TypeParameter) {
684
+ // Symbol kind is one based in the protocol and zero based in code.
685
+ return item - 1;
686
+ }
687
+ return this._monaco.languages.SymbolKind.Property;
688
+ }
689
+ asDocumentHighlights(values) {
690
+ if (!values) {
691
+ return undefined;
692
+ }
693
+ return values.map(item => this.asDocumentHighlight(item));
694
+ }
695
+ asDocumentHighlight(item) {
696
+ const range = this.asRange(item.range);
697
+ const kind = Is.number(item.kind) ? this.asDocumentHighlightKind(item.kind) : undefined;
698
+ return { range, kind };
699
+ }
700
+ asDocumentHighlightKind(item) {
701
+ switch (item) {
702
+ case api_1.DocumentHighlightKind.Text:
703
+ return this._monaco.languages.DocumentHighlightKind.Text;
704
+ case api_1.DocumentHighlightKind.Read:
705
+ return this._monaco.languages.DocumentHighlightKind.Read;
706
+ case api_1.DocumentHighlightKind.Write:
707
+ return this._monaco.languages.DocumentHighlightKind.Write;
708
+ }
709
+ return this._monaco.languages.DocumentHighlightKind.Text;
710
+ }
711
+ asReferences(values) {
712
+ if (!values) {
713
+ return undefined;
714
+ }
715
+ return values.map(location => this.asLocation(location));
716
+ }
717
+ asDefinitionResult(item) {
718
+ if (!item) {
719
+ return undefined;
720
+ }
721
+ if (Is.array(item)) {
722
+ if (item.length === 0) {
723
+ return undefined;
724
+ }
725
+ else if (api_1.LocationLink.is(item[0])) {
726
+ const links = item;
727
+ return links.map((location) => this.asLocationLink(location));
728
+ }
729
+ else {
730
+ const locations = item;
731
+ return locations.map((location) => this.asLocation(location));
732
+ }
733
+ }
734
+ else {
735
+ return this.asLocation(item);
736
+ }
737
+ }
738
+ asLocation(item) {
739
+ if (!item) {
740
+ return undefined;
741
+ }
742
+ const uri = this._monaco.Uri.parse(item.uri);
743
+ const range = this.asRange(item.range);
744
+ return {
745
+ uri, range
746
+ };
747
+ }
748
+ asLocationLink(item) {
749
+ if (!item) {
750
+ return undefined;
751
+ }
752
+ const result = {
753
+ uri: this._monaco.Uri.parse(item.targetUri),
754
+ range: this.asRange(item.targetSelectionRange),
755
+ originSelectionRange: this.asRange(item.originSelectionRange),
756
+ targetSelectionRange: this.asRange(item.targetSelectionRange)
757
+ };
758
+ if (!result.targetSelectionRange) {
759
+ throw new Error('targetSelectionRange must not be undefined or null');
760
+ }
761
+ return result;
762
+ }
763
+ asSignatureHelpResult(item) {
764
+ if (!item) {
765
+ return undefined;
766
+ }
767
+ const result = {};
768
+ if (Is.number(item.activeSignature)) {
769
+ result.activeSignature = item.activeSignature;
770
+ }
771
+ else {
772
+ // activeSignature was optional in the past
773
+ result.activeSignature = 0;
774
+ }
775
+ if (Is.number(item.activeParameter)) {
776
+ result.activeParameter = item.activeParameter;
777
+ }
778
+ else {
779
+ // activeParameter was optional in the past
780
+ result.activeParameter = 0;
781
+ }
782
+ if (item.signatures) {
783
+ result.signatures = this.asSignatureInformations(item.signatures);
784
+ }
785
+ else {
786
+ result.signatures = [];
787
+ }
788
+ return {
789
+ value: result,
790
+ dispose: () => { }
791
+ };
792
+ }
793
+ asSignatureInformations(items) {
794
+ return items.map(item => this.asSignatureInformation(item));
795
+ }
796
+ asSignatureInformation(item) {
797
+ const result = { label: item.label };
798
+ if (item.documentation) {
799
+ result.documentation = this.asDocumentation(item.documentation);
800
+ }
801
+ if (item.parameters) {
802
+ result.parameters = this.asParameterInformations(item.parameters);
803
+ }
804
+ else {
805
+ result.parameters = [];
806
+ }
807
+ if (item.activeParameter) {
808
+ result.activeParameter = item.activeParameter;
809
+ }
810
+ return result;
811
+ }
812
+ asParameterInformations(item) {
813
+ return item.map(item => this.asParameterInformation(item));
814
+ }
815
+ asParameterInformation(item) {
816
+ const result = { label: item.label };
817
+ if (item.documentation) {
818
+ result.documentation = this.asDocumentation(item.documentation);
819
+ }
820
+ return result;
821
+ }
822
+ asHover(hover) {
823
+ if (!hover) {
824
+ return undefined;
825
+ }
826
+ return {
827
+ contents: this.asHoverContent(hover.contents),
828
+ range: this.asRange(hover.range)
829
+ };
830
+ }
831
+ asHoverContent(contents) {
832
+ if (Array.isArray(contents)) {
833
+ return contents.map(content => this.asMarkdownString(content));
834
+ }
835
+ return [this.asMarkdownString(contents)];
836
+ }
837
+ asDocumentation(value) {
838
+ if (Is.string(value)) {
839
+ return value;
840
+ }
841
+ if (value.kind === api_1.MarkupKind.PlainText) {
842
+ return value.value;
843
+ }
844
+ return this.asMarkdownString(value);
845
+ }
846
+ asMarkdownString(content) {
847
+ if (api_1.MarkupContent.is(content)) {
848
+ return {
849
+ value: content.value
850
+ };
851
+ }
852
+ if (Is.string(content)) {
853
+ return { value: content };
854
+ }
855
+ const { language, value } = content;
856
+ return {
857
+ value: '```' + language + '\n' + value + '\n```'
858
+ };
859
+ }
860
+ asSeverity(severity) {
861
+ if (severity === 1) {
862
+ return this._monaco.MarkerSeverity.Error;
863
+ }
864
+ if (severity === 2) {
865
+ return this._monaco.MarkerSeverity.Warning;
866
+ }
867
+ if (severity === 3) {
868
+ return this._monaco.MarkerSeverity.Info;
869
+ }
870
+ return this._monaco.MarkerSeverity.Hint;
871
+ }
872
+ asDiagnostics(diagnostics) {
873
+ if (!diagnostics) {
874
+ return undefined;
875
+ }
876
+ return diagnostics.map(diagnostic => this.asDiagnostic(diagnostic));
877
+ }
878
+ asDiagnostic(diagnostic) {
879
+ return {
880
+ code: typeof diagnostic.code === 'number' ? diagnostic.code.toString() : diagnostic.code,
881
+ severity: this.asSeverity(diagnostic.severity),
882
+ message: diagnostic.message,
883
+ source: diagnostic.source,
884
+ startLineNumber: diagnostic.range.start.line + 1,
885
+ startColumn: diagnostic.range.start.character + 1,
886
+ endLineNumber: diagnostic.range.end.line + 1,
887
+ endColumn: diagnostic.range.end.character + 1,
888
+ relatedInformation: this.asRelatedInformations(diagnostic.relatedInformation),
889
+ tags: diagnostic.tags
890
+ };
891
+ }
892
+ asRelatedInformations(relatedInformation) {
893
+ if (!relatedInformation) {
894
+ return undefined;
895
+ }
896
+ return relatedInformation.map(item => this.asRelatedInformation(item));
897
+ }
898
+ asRelatedInformation(relatedInformation) {
899
+ return {
900
+ resource: this._monaco.Uri.parse(relatedInformation.location.uri),
901
+ startLineNumber: relatedInformation.location.range.start.line + 1,
902
+ startColumn: relatedInformation.location.range.start.character + 1,
903
+ endLineNumber: relatedInformation.location.range.end.line + 1,
904
+ endColumn: relatedInformation.location.range.end.character + 1,
905
+ message: relatedInformation.message
906
+ };
907
+ }
908
+ asCompletionResult(result, defaultMonacoRange) {
909
+ if (!result) {
910
+ return {
911
+ incomplete: false,
912
+ suggestions: []
913
+ };
914
+ }
915
+ if (Array.isArray(result)) {
916
+ const suggestions = result.map(item => this.asCompletionItem(item, defaultMonacoRange, defaultRange));
917
+ return {
918
+ incomplete: false,
919
+ suggestions
920
+ };
921
+ }
922
+ const defaultRange = this.getCompletionItemDefaultRange(result);
923
+ return {
924
+ incomplete: result.isIncomplete,
925
+ suggestions: result.items.map(item => this.asCompletionItem(item, defaultMonacoRange, defaultRange, result.itemDefaults))
926
+ };
927
+ }
928
+ asCompletionItem(item, defaultMonacoRange, defaultRange, itemDefaults) {
929
+ const result = { label: this.asCompletionItemLabel(item) };
930
+ if (item.detail) {
931
+ result.detail = item.detail;
932
+ }
933
+ if (item.documentation) {
934
+ result.documentation = this.asDocumentation(item.documentation);
935
+ result.documentationFormat = Is.string(item.documentation) ? undefined : item.documentation.kind;
936
+ }
937
+ if (item.filterText) {
938
+ result.filterText = item.filterText;
939
+ }
940
+ const insertText = this.asCompletionInsertText(item, defaultRange, itemDefaults?.insertTextFormat);
941
+ result.insertText = insertText.insertText;
942
+ result.range = insertText.range ?? defaultMonacoRange;
943
+ result.fromEdit = insertText.fromEdit;
944
+ if (insertText.isSnippet) {
945
+ result.insertTextRules = this._monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet;
946
+ }
947
+ if (Is.number(item.kind)) {
948
+ const [itemKind, original] = this.asCompletionItemKind(item.kind);
949
+ result.kind = itemKind;
950
+ if (original) {
951
+ result.originalItemKind = original;
952
+ }
953
+ }
954
+ if (item.sortText) {
955
+ result.sortText = item.sortText;
956
+ }
957
+ if (item.additionalTextEdits) {
958
+ result.additionalTextEdits = this.asTextEdits(item.additionalTextEdits);
959
+ }
960
+ if (Is.stringArray(item.commitCharacters)) {
961
+ result.commitCharacters = item.commitCharacters.slice();
962
+ }
963
+ if (item.command) {
964
+ result.command = this.asCommand(item.command);
965
+ }
966
+ if (item.deprecated === true || item.deprecated === false) {
967
+ result.deprecated = item.deprecated;
968
+ }
969
+ if (item.preselect === true || item.preselect === false) {
970
+ result.preselect = item.preselect;
971
+ }
972
+ const data = item.data ?? itemDefaults?.data;
973
+ if (data !== undefined) {
974
+ result.data = data;
975
+ }
976
+ if (item.deprecated === true || item.deprecated === false) {
977
+ result.deprecated = item.deprecated;
978
+ }
979
+ const insertTextMode = item.insertTextMode ?? itemDefaults?.insertTextMode;
980
+ if (insertTextMode) {
981
+ result.insertTextMode = insertTextMode;
982
+ }
983
+ if (item.tags) {
984
+ result.tags = item.tags;
985
+ }
986
+ return result;
987
+ }
988
+ getCompletionItemDefaultRange(list) {
989
+ const rangeDefaults = list.itemDefaults?.editRange;
990
+ return ls.Range.is(rangeDefaults)
991
+ ? this.asRange(rangeDefaults)
992
+ : rangeDefaults !== undefined
993
+ ? { insert: this.asRange(rangeDefaults.insert), replace: this.asRange(rangeDefaults.replace) }
994
+ : undefined;
995
+ }
996
+ asCompletionItemLabel(item) {
997
+ if (ls.CompletionItemLabelDetails.is(item.labelDetails)) {
998
+ return {
999
+ label: item.label,
1000
+ detail: item.labelDetails.detail,
1001
+ description: item.labelDetails.description
1002
+ };
1003
+ }
1004
+ else {
1005
+ return item.label;
1006
+ }
1007
+ }
1008
+ asCompletionItemKind(value) {
1009
+ if (api_1.CompletionItemKind.Text <= value && value <= api_1.CompletionItemKind.TypeParameter) {
1010
+ switch (value) {
1011
+ case api_1.CompletionItemKind.Text: return [this._monaco.languages.CompletionItemKind.Text, undefined];
1012
+ case api_1.CompletionItemKind.Method: return [this._monaco.languages.CompletionItemKind.Method, undefined];
1013
+ case api_1.CompletionItemKind.Function: return [this._monaco.languages.CompletionItemKind.Function, undefined];
1014
+ case api_1.CompletionItemKind.Constructor: return [this._monaco.languages.CompletionItemKind.Constructor, undefined];
1015
+ case api_1.CompletionItemKind.Field: return [this._monaco.languages.CompletionItemKind.Field, undefined];
1016
+ case api_1.CompletionItemKind.Variable: return [this._monaco.languages.CompletionItemKind.Variable, undefined];
1017
+ case api_1.CompletionItemKind.Class: return [this._monaco.languages.CompletionItemKind.Class, undefined];
1018
+ case api_1.CompletionItemKind.Interface: return [this._monaco.languages.CompletionItemKind.Interface, undefined];
1019
+ case api_1.CompletionItemKind.Module: return [this._monaco.languages.CompletionItemKind.Module, undefined];
1020
+ case api_1.CompletionItemKind.Property: return [this._monaco.languages.CompletionItemKind.Property, undefined];
1021
+ case api_1.CompletionItemKind.Unit: return [this._monaco.languages.CompletionItemKind.Unit, undefined];
1022
+ case api_1.CompletionItemKind.Value: return [this._monaco.languages.CompletionItemKind.Value, undefined];
1023
+ case api_1.CompletionItemKind.Enum: return [this._monaco.languages.CompletionItemKind.Enum, undefined];
1024
+ case api_1.CompletionItemKind.Keyword: return [this._monaco.languages.CompletionItemKind.Keyword, undefined];
1025
+ case api_1.CompletionItemKind.Snippet: return [this._monaco.languages.CompletionItemKind.Snippet, undefined];
1026
+ case api_1.CompletionItemKind.Color: return [this._monaco.languages.CompletionItemKind.Color, undefined];
1027
+ case api_1.CompletionItemKind.File: return [this._monaco.languages.CompletionItemKind.File, undefined];
1028
+ case api_1.CompletionItemKind.Reference: return [this._monaco.languages.CompletionItemKind.Reference, undefined];
1029
+ case api_1.CompletionItemKind.Folder: return [this._monaco.languages.CompletionItemKind.Folder, undefined];
1030
+ case api_1.CompletionItemKind.EnumMember: return [this._monaco.languages.CompletionItemKind.EnumMember, undefined];
1031
+ case api_1.CompletionItemKind.Constant: return [this._monaco.languages.CompletionItemKind.Constant, undefined];
1032
+ case api_1.CompletionItemKind.Struct: return [this._monaco.languages.CompletionItemKind.Struct, undefined];
1033
+ case api_1.CompletionItemKind.Event: return [this._monaco.languages.CompletionItemKind.Event, undefined];
1034
+ case api_1.CompletionItemKind.Operator: return [this._monaco.languages.CompletionItemKind.Operator, undefined];
1035
+ case api_1.CompletionItemKind.TypeParameter: return [this._monaco.languages.CompletionItemKind.TypeParameter, undefined];
1036
+ default: return [value - 1, undefined];
1037
+ }
1038
+ }
1039
+ return [api_1.CompletionItemKind.Text, value];
1040
+ }
1041
+ asCompletionInsertText(item, defaultRange, defaultInsertTextFormat) {
1042
+ const insertTextFormat = item.insertTextFormat ?? defaultInsertTextFormat;
1043
+ const isSnippet = insertTextFormat === api_1.InsertTextFormat.Snippet;
1044
+ if (item.textEdit !== undefined || defaultRange !== undefined) {
1045
+ const [range, newText] = item.textEdit !== undefined
1046
+ ? this.getCompletionRangeAndText(item.textEdit)
1047
+ : [defaultRange, item.textEditText ?? item.label];
1048
+ return { insertText: newText, range, fromEdit: true, isSnippet };
1049
+ }
1050
+ else if (item.insertText) {
1051
+ return { isSnippet, insertText: item.insertText, fromEdit: false, range: defaultRange };
1052
+ }
1053
+ return { insertText: item.label, range: defaultRange, fromEdit: false, isSnippet: false };
1054
+ }
1055
+ getCompletionRangeAndText(value) {
1056
+ if (ls.InsertReplaceEdit.is(value)) {
1057
+ return [{ insert: this.asRange(value.insert), replace: this.asRange(value.replace) }, value.newText];
1058
+ }
1059
+ else {
1060
+ return [this.asRange(value.range), value.newText];
1061
+ }
1062
+ }
1063
+ asDocumentLinks(documentLinks) {
1064
+ const links = documentLinks.map(link => this.asDocumentLink(link));
1065
+ return { links };
1066
+ }
1067
+ asDocumentLink(documentLink) {
1068
+ return {
1069
+ range: this.asRange(documentLink.range),
1070
+ url: documentLink.target,
1071
+ data: documentLink.data,
1072
+ tooltip: documentLink.tooltip
1073
+ };
1074
+ }
1075
+ asRange(range) {
1076
+ if (range === undefined) {
1077
+ return undefined;
1078
+ }
1079
+ if (range === null) {
1080
+ return null;
1081
+ }
1082
+ const start = this.asPosition(range.start);
1083
+ const end = this.asPosition(range.end);
1084
+ if (start instanceof this._monaco.Position && end instanceof this._monaco.Position) {
1085
+ return new this._monaco.Range(start.lineNumber, start.column, end.lineNumber, end.column);
1086
+ }
1087
+ const startLineNumber = !start || start.lineNumber === undefined ? undefined : start.lineNumber;
1088
+ const startColumn = !start || start.column === undefined ? undefined : start.column;
1089
+ const endLineNumber = !end || end.lineNumber === undefined ? undefined : end.lineNumber;
1090
+ const endColumn = !end || end.column === undefined ? undefined : end.column;
1091
+ return { startLineNumber, startColumn, endLineNumber, endColumn };
1092
+ }
1093
+ asPosition(position) {
1094
+ if (position === undefined) {
1095
+ return undefined;
1096
+ }
1097
+ if (position === null) {
1098
+ return null;
1099
+ }
1100
+ const { line, character } = position;
1101
+ const lineNumber = line === undefined ? undefined : line + 1;
1102
+ const column = character === undefined ? undefined : character + 1;
1103
+ if (lineNumber !== undefined && column !== undefined) {
1104
+ return new this._monaco.Position(lineNumber, column);
1105
+ }
1106
+ return { lineNumber, column };
1107
+ }
1108
+ asColorInformations(items) {
1109
+ return items.map(item => this.asColorInformation(item));
1110
+ }
1111
+ asColorInformation(item) {
1112
+ return {
1113
+ range: this.asRange(item.range),
1114
+ color: item.color
1115
+ };
1116
+ }
1117
+ asColorPresentations(items) {
1118
+ return items.map(item => this.asColorPresentation(item));
1119
+ }
1120
+ asColorPresentation(item) {
1121
+ return {
1122
+ label: item.label,
1123
+ textEdit: this.asTextEdit(item.textEdit),
1124
+ additionalTextEdits: this.asTextEdits(item.additionalTextEdits)
1125
+ };
1126
+ }
1127
+ asFoldingRanges(items) {
1128
+ if (!items) {
1129
+ return items;
1130
+ }
1131
+ return items.map(item => this.asFoldingRange(item));
1132
+ }
1133
+ asFoldingRange(item) {
1134
+ return {
1135
+ start: item.startLine + 1,
1136
+ end: item.endLine + 1,
1137
+ kind: this.asFoldingRangeKind(item.kind)
1138
+ };
1139
+ }
1140
+ asFoldingRangeKind(kind) {
1141
+ if (kind) {
1142
+ switch (kind) {
1143
+ case api_1.FoldingRangeKind.Comment:
1144
+ return this._monaco.languages.FoldingRangeKind.Comment;
1145
+ case api_1.FoldingRangeKind.Imports:
1146
+ return this._monaco.languages.FoldingRangeKind.Imports;
1147
+ case api_1.FoldingRangeKind.Region:
1148
+ return this._monaco.languages.FoldingRangeKind.Region;
1149
+ }
1150
+ }
1151
+ return undefined;
1152
+ }
1153
+ asSemanticTokens(semanticTokens) {
1154
+ return {
1155
+ resultId: semanticTokens.resultId,
1156
+ data: Uint32Array.from(semanticTokens.data)
1157
+ };
1158
+ }
1159
+ asInlayHintLabelPart(part) {
1160
+ return {
1161
+ label: part.value,
1162
+ command: this.asCommand(part.command),
1163
+ location: this.asLocation(part.location),
1164
+ tooltip: part.tooltip && this.asMarkdownString(part.tooltip)
1165
+ };
1166
+ }
1167
+ asInlayHintLabel(label) {
1168
+ if (Array.isArray(label)) {
1169
+ return label.map(part => this.asInlayHintLabelPart(part));
1170
+ }
1171
+ return label;
1172
+ }
1173
+ asInlayHint(inlayHint) {
1174
+ return {
1175
+ data: inlayHint.data,
1176
+ label: this.asInlayHintLabel(inlayHint.label),
1177
+ position: this.asPosition(inlayHint.position),
1178
+ kind: inlayHint.kind,
1179
+ paddingLeft: inlayHint.paddingLeft,
1180
+ paddingRight: inlayHint.paddingRight,
1181
+ tooltip: inlayHint.tooltip && this.asMarkdownString(inlayHint.tooltip)
1182
+ };
1183
+ }
1184
+ asInlayHintList(items) {
1185
+ if (!items) {
1186
+ return undefined;
1187
+ }
1188
+ return {
1189
+ hints: items.map((hint) => this.asInlayHint(hint)),
1190
+ dispose: () => { }
1191
+ };
1192
+ }
1193
+ }
1194
+ exports.ProtocolToMonacoConverter = ProtocolToMonacoConverter;
1195
+ //# sourceMappingURL=monaco-converter.js.map