Skip to content

Commit cc5382d

Browse files
committed
Merge branch 'master' into new-monaco
2 parents 7102f0c + 5c83cae commit cc5382d

File tree

2 files changed

+23
-24
lines changed

2 files changed

+23
-24
lines changed

src/dot-monaco/monaco-to-protocol.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import {
44
type languages,
55
MarkerSeverity,
66
} from "monaco-editor";
7-
import type * as lst from "vscode-languageserver-types";
7+
import type * as ls from "vscode-languageserver-types";
88

9-
export function asPosition(lineNumber: number, column: number): lst.Position {
9+
export function asPosition(lineNumber: number, column: number): ls.Position {
1010
// Monaco uses 1-based line numbers, LSP uses 0-based
1111
// Monaco uses 1-based column numbers, LSP uses 0-based character offsets
1212
return {
@@ -15,7 +15,7 @@ export function asPosition(lineNumber: number, column: number): lst.Position {
1515
};
1616
}
1717

18-
export function asRange(range: IRange): lst.Range {
18+
export function asRange(range: IRange): ls.Range {
1919
return {
2020
start: asPosition(range.startLineNumber, range.startColumn),
2121
end: asPosition(range.endLineNumber, range.endColumn),
@@ -24,7 +24,7 @@ export function asRange(range: IRange): lst.Range {
2424

2525
export function asDiagnosticSeverity(
2626
severity: MarkerSeverity,
27-
): lst.DiagnosticSeverity {
27+
): ls.DiagnosticSeverity {
2828
// Monaco MarkerSeverity: Error=8, Warning=4, Info=2, Hint=1
2929
// LSP DiagnosticSeverity: Error=1, Warning=2, Information=3, Hint=4
3030
switch (severity) {
@@ -41,7 +41,7 @@ export function asDiagnosticSeverity(
4141
}
4242
}
4343

44-
export function asDiagnostics(markers: editor.IMarkerData[]): lst.Diagnostic[] {
44+
export function asDiagnostics(markers: editor.IMarkerData[]): ls.Diagnostic[] {
4545
return markers.map(marker => ({
4646
range: asRange({
4747
startLineNumber: marker.startLineNumber,
@@ -61,8 +61,8 @@ export function asDiagnostics(markers: editor.IMarkerData[]): lst.Diagnostic[] {
6161

6262
export function asCodeActionContext(
6363
context: languages.CodeActionContext,
64-
diagnostics?: lst.Diagnostic[],
65-
): lst.CodeActionContext {
64+
diagnostics?: ls.Diagnostic[],
65+
): ls.CodeActionContext {
6666
return {
6767
diagnostics:
6868
diagnostics && diagnostics.length > 0

src/dot-monaco/protocol-to-monaco.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as monaco from "monaco-editor";
22
import type * as ls from "vscode-languageserver-types";
3-
import type * as lst from "vscode-languageserver-types";
43

54
export function asPosition(value: undefined | null): undefined;
65
export function asPosition(value: ls.Position): monaco.Position;
@@ -32,7 +31,7 @@ export function asRange(
3231
}
3332

3433
export function asDiagnostics(
35-
diagnostics: lst.Diagnostic[],
34+
diagnostics: ls.Diagnostic[],
3635
): monaco.editor.IMarkerData[] {
3736
return diagnostics.map(diagnostic => {
3837
const range = asRange(diagnostic.range);
@@ -54,7 +53,7 @@ export function asDiagnostics(
5453
}
5554

5655
export function asCompletionList(
57-
completions: lst.CompletionItem[] | null | undefined,
56+
completions: ls.CompletionItem[] | null | undefined,
5857
position: monaco.Position,
5958
): monaco.languages.CompletionList {
6059
const defaultMonacoRange = monaco.Range.fromPositions(position);
@@ -67,7 +66,7 @@ export function asCompletionList(
6766
}
6867

6968
export function asCompletionResult(
70-
result: lst.CompletionItem[] | null | undefined,
69+
result: ls.CompletionItem[] | null | undefined,
7170
): monaco.languages.CompletionList {
7271
if (!result) {
7372
return {
@@ -85,7 +84,7 @@ export function asCompletionResult(
8584
}
8685

8786
export function asCompletionItem(
88-
item: lst.CompletionItem,
87+
item: ls.CompletionItem,
8988
defaultRange: monaco.IRange | undefined,
9089
insertTextReplaceRange?: monaco.IRange,
9190
): monaco.languages.CompletionItem {
@@ -132,12 +131,12 @@ export function asCompletionItem(
132131
}
133132

134133
export function asHover(hover: null | undefined): null;
135-
export function asHover(hover: lst.Hover): monaco.languages.Hover;
134+
export function asHover(hover: ls.Hover): monaco.languages.Hover;
136135
export function asHover(
137-
hover: lst.Hover | null | undefined,
136+
hover: ls.Hover | null | undefined,
138137
): monaco.languages.Hover | null;
139138
export function asHover(
140-
hover: lst.Hover | null | undefined,
139+
hover: ls.Hover | null | undefined,
141140
): monaco.languages.Hover | null {
142141
return hover
143142
? {
@@ -148,7 +147,7 @@ export function asHover(
148147
}
149148

150149
export function asDefinitionResult(
151-
definition: lst.Location | lst.Location[] | null | undefined,
150+
definition: ls.Location | ls.Location[] | null | undefined,
152151
): monaco.languages.Definition | null {
153152
if (!definition) {
154153
return null;
@@ -162,20 +161,20 @@ export function asDefinitionResult(
162161
}
163162

164163
export function asReferences(
165-
references: lst.Location[] | null | undefined,
164+
references: ls.Location[] | null | undefined,
166165
): monaco.languages.Location[] {
167166
return references?.map(ref => asLocation(ref)) ?? [];
168167
}
169168

170-
function asLocation(location: lst.Location): monaco.languages.Location {
169+
function asLocation(location: ls.Location): monaco.languages.Location {
171170
return {
172171
uri: monaco.Uri.parse(location.uri),
173172
range: asRange(location.range),
174173
};
175174
}
176175

177176
export function asWorkspaceEdit(
178-
edit: lst.WorkspaceEdit | null | undefined,
177+
edit: ls.WorkspaceEdit | null | undefined,
179178
): monaco.languages.WorkspaceEdit | undefined {
180179
if (!edit) {
181180
return undefined;
@@ -203,7 +202,7 @@ export function asWorkspaceEdit(
203202
}
204203

205204
export function asCodeActionList(
206-
commands: (lst.CodeAction | lst.Command)[] | null | undefined,
205+
commands: (ls.CodeAction | ls.Command)[] | null | undefined,
207206
): monaco.languages.CodeActionList | null {
208207
if (!commands) {
209208
return null;
@@ -215,7 +214,7 @@ export function asCodeActionList(
215214
typeof command.command === "string" &&
216215
"arguments" in command
217216
) {
218-
const cmd = command as lst.Command;
217+
const cmd = command as ls.Command;
219218
return {
220219
title: cmd.title,
221220
command: {
@@ -226,7 +225,7 @@ export function asCodeActionList(
226225
};
227226
}
228227

229-
const codeAction = command as lst.CodeAction;
228+
const codeAction = command as ls.CodeAction;
230229
const action: monaco.languages.CodeAction = {
231230
title: codeAction.title,
232231
kind: codeAction.kind,
@@ -261,7 +260,7 @@ export function asCodeActionList(
261260
}
262261

263262
export function asColorInformation(
264-
colorInfo: lst.ColorInformation[] | null | undefined,
263+
colorInfo: ls.ColorInformation[] | null | undefined,
265264
): monaco.languages.IColorInformation[] {
266265
if (!colorInfo) {
267266
return [];
@@ -274,7 +273,7 @@ export function asColorInformation(
274273
}
275274

276275
export function asColorPresentations(
277-
presentations: lst.ColorPresentation[] | null | undefined,
276+
presentations: ls.ColorPresentation[] | null | undefined,
278277
): monaco.languages.IColorPresentation[] {
279278
if (!presentations) {
280279
return [];

0 commit comments

Comments
 (0)