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