monaco-languageserver-types
Advanced tools
Comparing version 0.1.1 to 0.2.0
export * from './lib/codeAction.js'; | ||
export * from './lib/color.js'; | ||
export * from './lib/colorInformation.js'; | ||
export * from './lib/command.js'; | ||
export * from './lib/completionContext.js'; | ||
export * from './lib/completionItem.js'; | ||
export * from './lib/completionItemKind.js'; | ||
export * from './lib/completionItemTag.js'; | ||
export * from './lib/completionList.js'; | ||
export * from './lib/completionTriggerKind.js'; | ||
export * from './lib/documentSymbol.js'; | ||
@@ -12,2 +20,3 @@ export * from './lib/formattingOptions.js'; | ||
export * from './lib/markerTag.js'; | ||
export { setMonaco } from './lib/monaco.js'; | ||
export * from './lib/position.js'; | ||
@@ -14,0 +23,0 @@ export * from './lib/range.js'; |
export * from './lib/codeAction.js'; | ||
export * from './lib/color.js'; | ||
export * from './lib/colorInformation.js'; | ||
export * from './lib/command.js'; | ||
export * from './lib/completionContext.js'; | ||
export * from './lib/completionItem.js'; | ||
export * from './lib/completionItemKind.js'; | ||
export * from './lib/completionItemTag.js'; | ||
export * from './lib/completionList.js'; | ||
export * from './lib/completionTriggerKind.js'; | ||
export * from './lib/documentSymbol.js'; | ||
@@ -12,2 +20,3 @@ export * from './lib/formattingOptions.js'; | ||
export * from './lib/markerTag.js'; | ||
export { setMonaco } from './lib/monaco.js'; | ||
export * from './lib/position.js'; | ||
@@ -14,0 +23,0 @@ export * from './lib/range.js'; |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -10,2 +10,10 @@ * Convert a Monaco editor code action to an LSP code action. | ||
export declare function fromCodeAction(codeAction: monaco.languages.CodeAction): ls.CodeAction; | ||
export interface ToCodeActionOptions { | ||
/** | ||
* The default severity in case it’s not provided by a diagnostic. | ||
* | ||
* @default MarkerSeverity.Error | ||
*/ | ||
defaultSeverity?: monaco.MarkerSeverity; | ||
} | ||
/** | ||
@@ -15,5 +23,5 @@ * Convert an LSP code action to a Monaco editor code action. | ||
* @param codeAction The LSP code action to convert. | ||
* @param Uri The Monaco Uri constructor. | ||
* @param options Additional options needed to construct the Monaco code action. | ||
* @returns The code action as Monaco editor code action. | ||
*/ | ||
export declare function toCodeAction(codeAction: ls.CodeAction, Uri: typeof monaco.Uri): monaco.languages.CodeAction; | ||
export declare function toCodeAction(codeAction: ls.CodeAction, options?: ToCodeActionOptions): monaco.languages.CodeAction; |
@@ -10,15 +10,21 @@ import { fromMarkerData, toMarkerData } from './markerData.js'; | ||
export function fromCodeAction(codeAction) { | ||
var _a; | ||
return { | ||
title: codeAction.title, | ||
diagnostics: (_a = codeAction.diagnostics) === null || _a === void 0 ? void 0 : _a.map(fromMarkerData), | ||
disabled: codeAction.disabled | ||
? { | ||
reason: codeAction.disabled | ||
} | ||
: undefined, | ||
edit: codeAction.edit ? fromWorkspaceEdit(codeAction.edit) : undefined, | ||
kind: codeAction.kind, | ||
isPreferred: codeAction.isPreferred | ||
const result = { | ||
title: codeAction.title | ||
}; | ||
if (codeAction.diagnostics) { | ||
result.diagnostics = codeAction.diagnostics.map(fromMarkerData); | ||
} | ||
if (codeAction.disabled != null) { | ||
result.disabled = { reason: codeAction.disabled }; | ||
} | ||
if (codeAction.edit) { | ||
result.edit = fromWorkspaceEdit(codeAction.edit); | ||
} | ||
if (codeAction.isPreferred != null) { | ||
result.isPreferred = codeAction.isPreferred; | ||
} | ||
if (codeAction.kind) { | ||
result.kind = codeAction.kind; | ||
} | ||
return result; | ||
} | ||
@@ -29,15 +35,26 @@ /** | ||
* @param codeAction The LSP code action to convert. | ||
* @param Uri The Monaco Uri constructor. | ||
* @param options Additional options needed to construct the Monaco code action. | ||
* @returns The code action as Monaco editor code action. | ||
*/ | ||
export function toCodeAction(codeAction, Uri) { | ||
var _a, _b; | ||
return { | ||
export function toCodeAction(codeAction, options) { | ||
const result = { | ||
title: codeAction.title, | ||
diagnostics: (_a = codeAction.diagnostics) === null || _a === void 0 ? void 0 : _a.map((diagnostic) => toMarkerData(diagnostic, Uri)), | ||
disabled: (_b = codeAction.disabled) === null || _b === void 0 ? void 0 : _b.reason, | ||
edit: codeAction.edit ? toWorkspaceEdit(codeAction.edit, Uri) : undefined, | ||
kind: codeAction.kind, | ||
isPreferred: codeAction.isPreferred | ||
}; | ||
if (codeAction.diagnostics) { | ||
result.diagnostics = codeAction.diagnostics.map((diagnostic) => toMarkerData(diagnostic, options)); | ||
} | ||
if (codeAction.disabled) { | ||
result.disabled = codeAction.disabled.reason; | ||
} | ||
if (codeAction.edit) { | ||
result.edit = toWorkspaceEdit(codeAction.edit); | ||
} | ||
if (codeAction.isPreferred != null) { | ||
result.isPreferred = codeAction.isPreferred; | ||
} | ||
if (codeAction.kind) { | ||
result.kind = codeAction.kind; | ||
} | ||
return result; | ||
} |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -9,3 +9,3 @@ * Convert a Monaco editor completion item kind to an LSP completion item kind. | ||
*/ | ||
export declare function fromCompletionItemKind(kind: monaco.languages.CompletionItemKind): ls.CompletionItemKind; | ||
export declare function fromCompletionItemKind(kind: monaco.languages.CompletionItemKind): ls.CompletionItemKind | undefined; | ||
/** | ||
@@ -12,0 +12,0 @@ * Convert an LSP completion item kind to a Monaco editor completion item kind. |
@@ -0,1 +1,2 @@ | ||
import { getMonaco } from './monaco.js'; | ||
/** | ||
@@ -8,54 +9,78 @@ * Convert a Monaco editor completion item kind to an LSP completion item kind. | ||
export function fromCompletionItemKind(kind) { | ||
if (kind === 22 || kind === 25 || kind === 26) { | ||
throw new TypeError(`Completion kind ${kind} is not supported in LSP.`); | ||
const { CompletionItemKind } = getMonaco().languages; | ||
if (kind === CompletionItemKind.Text) { | ||
return 1; | ||
} | ||
return kind === 0 | ||
? 2 | ||
: kind === 1 | ||
? 3 | ||
: kind === 2 | ||
? 4 | ||
: kind === 3 | ||
? 5 | ||
: kind === 4 | ||
? 6 | ||
: kind === 5 | ||
? 7 | ||
: kind === 6 | ||
? 22 | ||
: kind === 7 | ||
? 8 | ||
: kind === 8 | ||
? 9 | ||
: kind === 9 | ||
? 10 | ||
: kind === 10 | ||
? 23 | ||
: kind === 11 | ||
? 24 | ||
: kind === 12 | ||
? 11 | ||
: kind === 13 | ||
? 12 | ||
: kind === 14 | ||
? 21 | ||
: kind === 15 | ||
? 13 | ||
: kind === 16 | ||
? 20 | ||
: kind === 17 | ||
? 14 | ||
: kind === 18 | ||
? 1 | ||
: kind === 19 | ||
? 16 | ||
: kind === 20 | ||
? 17 | ||
: kind === 21 | ||
? 18 | ||
: kind === 23 | ||
? 19 | ||
: kind === 24 | ||
? 25 | ||
: 15; | ||
if (kind === CompletionItemKind.Method) { | ||
return 2; | ||
} | ||
if (kind === CompletionItemKind.Function) { | ||
return 3; | ||
} | ||
if (kind === CompletionItemKind.Constructor) { | ||
return 4; | ||
} | ||
if (kind === CompletionItemKind.Field) { | ||
return 5; | ||
} | ||
if (kind === CompletionItemKind.Variable) { | ||
return 6; | ||
} | ||
if (kind === CompletionItemKind.Class) { | ||
return 7; | ||
} | ||
if (kind === CompletionItemKind.Interface) { | ||
return 8; | ||
} | ||
if (kind === CompletionItemKind.Module) { | ||
return 9; | ||
} | ||
if (kind === CompletionItemKind.Property) { | ||
return 10; | ||
} | ||
if (kind === CompletionItemKind.Unit) { | ||
return 11; | ||
} | ||
if (kind === CompletionItemKind.Value) { | ||
return 12; | ||
} | ||
if (kind === CompletionItemKind.Enum) { | ||
return 13; | ||
} | ||
if (kind === CompletionItemKind.Keyword) { | ||
return 14; | ||
} | ||
if (kind === CompletionItemKind.Snippet) { | ||
return 15; | ||
} | ||
if (kind === CompletionItemKind.Color) { | ||
return 16; | ||
} | ||
if (kind === CompletionItemKind.File) { | ||
return 17; | ||
} | ||
if (kind === CompletionItemKind.Reference) { | ||
return 18; | ||
} | ||
if (kind === CompletionItemKind.Folder) { | ||
return 19; | ||
} | ||
if (kind === CompletionItemKind.EnumMember) { | ||
return 20; | ||
} | ||
if (kind === CompletionItemKind.Constant) { | ||
return 21; | ||
} | ||
if (kind === CompletionItemKind.Struct) { | ||
return 22; | ||
} | ||
if (kind === CompletionItemKind.Event) { | ||
return 23; | ||
} | ||
if (kind === CompletionItemKind.Operator) { | ||
return 24; | ||
} | ||
if (kind === CompletionItemKind.TypeParameter) { | ||
return 25; | ||
} | ||
} | ||
@@ -69,51 +94,77 @@ /** | ||
export function toCompletionItemKind(kind) { | ||
return kind === 1 | ||
? 18 | ||
: kind === 2 | ||
? 0 | ||
: kind === 3 | ||
? 1 | ||
: kind === 4 | ||
? 2 | ||
: kind === 5 | ||
? 3 | ||
: kind === 6 | ||
? 4 | ||
: kind === 7 | ||
? 5 | ||
: kind === 8 | ||
? 7 | ||
: kind === 9 | ||
? 8 | ||
: kind === 10 | ||
? 9 | ||
: kind === 11 | ||
? 12 | ||
: kind === 12 | ||
? 13 | ||
: kind === 13 | ||
? 15 | ||
: kind === 14 | ||
? 17 | ||
: kind === 15 | ||
? 27 | ||
: kind === 16 | ||
? 19 | ||
: kind === 17 | ||
? 20 | ||
: kind === 18 | ||
? 21 | ||
: kind === 19 | ||
? 23 | ||
: kind === 20 | ||
? 16 | ||
: kind === 21 | ||
? 14 | ||
: kind === 22 | ||
? 6 | ||
: kind === 23 | ||
? 10 | ||
: kind === 24 | ||
? 11 | ||
: 24; | ||
const { CompletionItemKind } = getMonaco().languages; | ||
if (kind === 1) { | ||
return CompletionItemKind.Text; | ||
} | ||
if (kind === 2) { | ||
return CompletionItemKind.Method; | ||
} | ||
if (kind === 3) { | ||
return CompletionItemKind.Function; | ||
} | ||
if (kind === 4) { | ||
return CompletionItemKind.Constructor; | ||
} | ||
if (kind === 5) { | ||
return CompletionItemKind.Field; | ||
} | ||
if (kind === 6) { | ||
return CompletionItemKind.Variable; | ||
} | ||
if (kind === 7) { | ||
return CompletionItemKind.Class; | ||
} | ||
if (kind === 8) { | ||
return CompletionItemKind.Interface; | ||
} | ||
if (kind === 9) { | ||
return CompletionItemKind.Module; | ||
} | ||
if (kind === 10) { | ||
return CompletionItemKind.Property; | ||
} | ||
if (kind === 11) { | ||
return CompletionItemKind.Unit; | ||
} | ||
if (kind === 12) { | ||
return CompletionItemKind.Value; | ||
} | ||
if (kind === 13) { | ||
return CompletionItemKind.Enum; | ||
} | ||
if (kind === 14) { | ||
return CompletionItemKind.Keyword; | ||
} | ||
if (kind === 15) { | ||
return CompletionItemKind.Snippet; | ||
} | ||
if (kind === 16) { | ||
return CompletionItemKind.Color; | ||
} | ||
if (kind === 17) { | ||
return CompletionItemKind.File; | ||
} | ||
if (kind === 18) { | ||
return CompletionItemKind.Reference; | ||
} | ||
if (kind === 19) { | ||
return CompletionItemKind.Folder; | ||
} | ||
if (kind === 20) { | ||
return CompletionItemKind.EnumMember; | ||
} | ||
if (kind === 21) { | ||
return CompletionItemKind.Constant; | ||
} | ||
if (kind === 22) { | ||
return CompletionItemKind.Struct; | ||
} | ||
if (kind === 23) { | ||
return CompletionItemKind.Event; | ||
} | ||
if (kind === 24) { | ||
return CompletionItemKind.Operator; | ||
} | ||
// Kind === 25 | ||
return CompletionItemKind.TypeParameter; | ||
} |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Convert a Monaco editor document symbol to an LSP document symbol. |
@@ -11,6 +11,4 @@ import { fromRange, toRange } from './range.js'; | ||
export function fromDocumentSymbol(documentSymbol) { | ||
var _a; | ||
return { | ||
children: (_a = documentSymbol.children) === null || _a === void 0 ? void 0 : _a.map(fromDocumentSymbol), | ||
detail: documentSymbol.detail || undefined, | ||
const result = { | ||
detail: documentSymbol.detail, | ||
kind: fromSymbolKind(documentSymbol.kind), | ||
@@ -22,2 +20,6 @@ name: documentSymbol.name, | ||
}; | ||
if (documentSymbol.children) { | ||
result.children = documentSymbol.children.map(fromDocumentSymbol); | ||
} | ||
return result; | ||
} | ||
@@ -31,6 +33,5 @@ /** | ||
export function toDocumentSymbol(documentSymbol) { | ||
var _a, _b, _c, _d; | ||
return { | ||
children: (_a = documentSymbol.children) === null || _a === void 0 ? void 0 : _a.map(toDocumentSymbol), | ||
detail: (_b = documentSymbol.detail) !== null && _b !== void 0 ? _b : '', | ||
var _a, _b, _c; | ||
const result = { | ||
detail: (_a = documentSymbol.detail) !== null && _a !== void 0 ? _a : '', | ||
kind: toSymbolKind(documentSymbol.kind), | ||
@@ -40,4 +41,8 @@ name: documentSymbol.name, | ||
selectionRange: toRange(documentSymbol.selectionRange), | ||
tags: (_d = (_c = documentSymbol.tags) === null || _c === void 0 ? void 0 : _c.map(toSymbolTag)) !== null && _d !== void 0 ? _d : [] | ||
tags: (_c = (_b = documentSymbol.tags) === null || _b === void 0 ? void 0 : _b.map(toSymbolTag)) !== null && _c !== void 0 ? _c : [] | ||
}; | ||
if (documentSymbol.children) { | ||
result.children = documentSymbol.children.map(toDocumentSymbol); | ||
} | ||
return result; | ||
} |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Convert a Monaco editor formatting options to an LSP formatting options. |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Convert a Monaco editor hover to an LSP hover. |
@@ -10,6 +10,9 @@ import { fromMarkdownString, toMarkdownString } from './markdownString.js'; | ||
export function fromHover(hover) { | ||
return { | ||
range: hover.range && fromRange(hover.range), | ||
const result = { | ||
contents: fromMarkdownString(hover.contents[0]) | ||
}; | ||
if (hover.range) { | ||
result.range = fromRange(hover.range); | ||
} | ||
return result; | ||
} | ||
@@ -26,3 +29,3 @@ /** | ||
} | ||
return { value: `\`\`\`\n${value.language}\n${value.value}\`\`\`` }; | ||
return { value: `\`\`\`${value.language}\n${value.value}\n\`\`\`` }; | ||
} | ||
@@ -51,6 +54,9 @@ /** | ||
export function toHover(hover) { | ||
return { | ||
range: hover.range && toRange(hover.range), | ||
const result = { | ||
contents: toHoverContents(hover.contents) | ||
}; | ||
if (hover.range) { | ||
result.range = toRange(hover.range); | ||
} | ||
return result; | ||
} |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -14,5 +14,4 @@ * Convert a Monaco editor link to an LSP document link. | ||
* @param documentLink The LSP document link to convert. | ||
* @param Uri The Monaco Uri constructor. | ||
* @returns The document link as Monaco editor link. | ||
*/ | ||
export declare function toLink(documentLink: ls.DocumentLink, Uri: typeof monaco.Uri): monaco.languages.ILink; | ||
export declare function toLink(documentLink: ls.DocumentLink): monaco.languages.ILink; |
@@ -0,1 +1,2 @@ | ||
import { getMonaco } from './monaco.js'; | ||
import { fromRange, toRange } from './range.js'; | ||
@@ -9,7 +10,12 @@ /** | ||
export function fromLink(link) { | ||
return { | ||
range: fromRange(link.range), | ||
target: link.url ? String(link.url) : undefined, | ||
tooltip: link.tooltip | ||
const result = { | ||
range: fromRange(link.range) | ||
}; | ||
if (link.tooltip != null) { | ||
result.tooltip = link.tooltip; | ||
} | ||
if (link.url != null) { | ||
result.target = String(link.url); | ||
} | ||
return result; | ||
} | ||
@@ -20,11 +26,16 @@ /** | ||
* @param documentLink The LSP document link to convert. | ||
* @param Uri The Monaco Uri constructor. | ||
* @returns The document link as Monaco editor link. | ||
*/ | ||
export function toLink(documentLink, Uri) { | ||
return { | ||
range: toRange(documentLink.range), | ||
url: documentLink.target ? Uri.parse(documentLink.target) : undefined, | ||
tooltip: documentLink.tooltip | ||
export function toLink(documentLink) { | ||
const { Uri } = getMonaco(); | ||
const result = { | ||
range: toRange(documentLink.range) | ||
}; | ||
if (documentLink.tooltip != null) { | ||
result.tooltip = documentLink.tooltip; | ||
} | ||
if (documentLink.target != null) { | ||
result.url = Uri.parse(documentLink.target); | ||
} | ||
return result; | ||
} |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -14,5 +14,4 @@ * Convert a Monaco editor location link to an LSP location link. | ||
* @param locationLink The LSP location link to convert. | ||
* @param Uri The Monaco Uri constructor. | ||
* @returns The location link as Monaco editor location link. | ||
*/ | ||
export declare function toLocationLink(locationLink: ls.LocationLink, Uri: typeof monaco.Uri): monaco.languages.LocationLink; | ||
export declare function toLocationLink(locationLink: ls.LocationLink): monaco.languages.LocationLink; |
@@ -0,1 +1,2 @@ | ||
import { getMonaco } from './monaco.js'; | ||
import { fromRange, toRange } from './range.js'; | ||
@@ -9,4 +10,3 @@ /** | ||
export function fromLocationLink(locationLink) { | ||
return { | ||
originSelectionRange: locationLink.originSelectionRange && fromRange(locationLink.originSelectionRange), | ||
const result = { | ||
targetRange: fromRange(locationLink.range), | ||
@@ -18,2 +18,6 @@ targetSelectionRange: locationLink.targetSelectionRange | ||
}; | ||
if (locationLink.originSelectionRange) { | ||
result.originSelectionRange = fromRange(locationLink.originSelectionRange); | ||
} | ||
return result; | ||
} | ||
@@ -24,8 +28,7 @@ /** | ||
* @param locationLink The LSP location link to convert. | ||
* @param Uri The Monaco Uri constructor. | ||
* @returns The location link as Monaco editor location link. | ||
*/ | ||
export function toLocationLink(locationLink, Uri) { | ||
return { | ||
originSelectionRange: locationLink.originSelectionRange && toRange(locationLink.originSelectionRange), | ||
export function toLocationLink(locationLink) { | ||
const { Uri } = getMonaco(); | ||
const result = { | ||
range: toRange(locationLink.targetRange), | ||
@@ -35,2 +38,6 @@ targetSelectionRange: toRange(locationLink.targetSelectionRange), | ||
}; | ||
if (locationLink.originSelectionRange) { | ||
result.originSelectionRange = toRange(locationLink.originSelectionRange); | ||
} | ||
return result; | ||
} |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Convert a Monaco editor markdown string to an LSP markup content. |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -10,11 +10,17 @@ * Convert a Monaco editor marker data to an LSP diagnostic. | ||
export declare function fromMarkerData(markerData: monaco.editor.IMarkerData): ls.Diagnostic; | ||
export interface ToMarkerDataOptions { | ||
/** | ||
* The default severity in case it’s not provided by the diagnostic. | ||
* | ||
* @default MarkerSeverity.Error | ||
*/ | ||
defaultSeverity?: monaco.MarkerSeverity; | ||
} | ||
/** | ||
* Convert an LSP diagnostic to a Monaco editor marker data. | ||
* | ||
* **Note**: A default severity of {@link monaco.MarkerSeverity.Error} is used. | ||
* | ||
* @param diagnostic The LSP diagnostic to convert. | ||
* @param Uri The Monaco Uri constructor. | ||
* @param options Additional options needed to construct the Monaco marker data. | ||
* @returns The diagnostic as Monaco editor marker data. | ||
*/ | ||
export declare function toMarkerData(diagnostic: ls.Diagnostic, Uri: typeof monaco.Uri): monaco.editor.IMarkerData; | ||
export declare function toMarkerData(diagnostic: ls.Diagnostic, options?: ToMarkerDataOptions): monaco.editor.IMarkerData; |
import { fromMarkerSeverity, toMarkerSeverity } from './markerSeverity.js'; | ||
import { fromMarkerTag, toMarkerTag } from './markerTag.js'; | ||
import { getMonaco } from './monaco.js'; | ||
import { fromRange, toRange } from './range.js'; | ||
@@ -12,24 +13,23 @@ import { fromRelatedInformation, toRelatedInformation } from './relatedInformation.js'; | ||
export function fromMarkerData(markerData) { | ||
var _a, _b; | ||
const diagnostic = { | ||
code: String(markerData.code), | ||
message: markerData.message, | ||
range: fromRange(markerData), | ||
severity: fromMarkerSeverity(markerData.severity), | ||
source: markerData.source, | ||
tags: (_a = markerData.tags) === null || _a === void 0 ? void 0 : _a.map(fromMarkerTag), | ||
relatedInformation: (_b = markerData.relatedInformation) === null || _b === void 0 ? void 0 : _b.map(fromRelatedInformation) | ||
severity: fromMarkerSeverity(markerData.severity) | ||
}; | ||
if (markerData.code == null) { | ||
diagnostic.code = undefined; | ||
diagnostic.codeDescription = undefined; | ||
} | ||
else if (typeof markerData.code === 'string') { | ||
if (typeof markerData.code === 'string') { | ||
diagnostic.code = markerData.code; | ||
diagnostic.codeDescription = undefined; | ||
} | ||
else { | ||
else if (markerData.code != null) { | ||
diagnostic.code = markerData.code.value; | ||
diagnostic.codeDescription = { href: String(markerData.code.target) }; | ||
} | ||
if (markerData.relatedInformation) { | ||
diagnostic.relatedInformation = markerData.relatedInformation.map(fromRelatedInformation); | ||
} | ||
if (markerData.tags) { | ||
diagnostic.tags = markerData.tags.map(fromMarkerTag); | ||
} | ||
if (markerData.source != null) { | ||
diagnostic.source = markerData.source; | ||
} | ||
return diagnostic; | ||
@@ -40,23 +40,32 @@ } | ||
* | ||
* **Note**: A default severity of {@link monaco.MarkerSeverity.Error} is used. | ||
* | ||
* @param diagnostic The LSP diagnostic to convert. | ||
* @param Uri The Monaco Uri constructor. | ||
* @param options Additional options needed to construct the Monaco marker data. | ||
* @returns The diagnostic as Monaco editor marker data. | ||
*/ | ||
export function toMarkerData(diagnostic, Uri) { | ||
var _a, _b; | ||
return { | ||
export function toMarkerData(diagnostic, options) { | ||
var _a; | ||
const { MarkerSeverity, Uri } = getMonaco(); | ||
const markerData = { | ||
...toRange(diagnostic.range), | ||
code: diagnostic.code == null | ||
? undefined | ||
: diagnostic.codeDescription | ||
? { value: String(diagnostic.code), target: Uri.parse(diagnostic.codeDescription.href) } | ||
: String(diagnostic.code), | ||
message: diagnostic.message, | ||
relatedInformation: (_a = diagnostic.relatedInformation) === null || _a === void 0 ? void 0 : _a.map((relatedInformation) => toRelatedInformation(relatedInformation, Uri)), | ||
severity: diagnostic.severity ? toMarkerSeverity(diagnostic.severity) : 8, | ||
source: diagnostic.source, | ||
tags: (_b = diagnostic.tags) === null || _b === void 0 ? void 0 : _b.map(toMarkerTag) | ||
severity: diagnostic.severity | ||
? toMarkerSeverity(diagnostic.severity) | ||
: (_a = options === null || options === void 0 ? void 0 : options.defaultSeverity) !== null && _a !== void 0 ? _a : MarkerSeverity.Error | ||
}; | ||
if (diagnostic.code != null) { | ||
markerData.code = | ||
diagnostic.codeDescription == null | ||
? String(diagnostic.code) | ||
: { value: String(diagnostic.code), target: Uri.parse(diagnostic.codeDescription.href) }; | ||
} | ||
if (diagnostic.relatedInformation) { | ||
markerData.relatedInformation = diagnostic.relatedInformation.map(toRelatedInformation); | ||
} | ||
if (diagnostic.tags) { | ||
markerData.tags = diagnostic.tags.map(toMarkerTag); | ||
} | ||
if (diagnostic.source != null) { | ||
markerData.source = diagnostic.source; | ||
} | ||
return markerData; | ||
} |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Convert a Monaco editor marker severity to an LSP diagnostic severity. |
@@ -0,1 +1,2 @@ | ||
import { getMonaco } from './monaco.js'; | ||
/** | ||
@@ -8,3 +9,14 @@ * Convert a Monaco editor marker severity to an LSP diagnostic severity. | ||
export function fromMarkerSeverity(severity) { | ||
return severity === 1 ? 4 : severity === 2 ? 3 : severity === 4 ? 2 : 1; | ||
const { MarkerSeverity } = getMonaco(); | ||
if (severity === MarkerSeverity.Error) { | ||
return 1; | ||
} | ||
if (severity === MarkerSeverity.Warning) { | ||
return 2; | ||
} | ||
if (severity === MarkerSeverity.Info) { | ||
return 3; | ||
} | ||
// Severity === MarkerSeverity.Hint | ||
return 4; | ||
} | ||
@@ -18,3 +30,14 @@ /** | ||
export function toMarkerSeverity(severity) { | ||
return severity === 4 ? 1 : severity === 3 ? 2 : severity === 2 ? 4 : 8; | ||
const { MarkerSeverity } = getMonaco(); | ||
if (severity === 1) { | ||
return MarkerSeverity.Error; | ||
} | ||
if (severity === 2) { | ||
return MarkerSeverity.Warning; | ||
} | ||
if (severity === 3) { | ||
return MarkerSeverity.Info; | ||
} | ||
// Severity === 4 | ||
return MarkerSeverity.Hint; | ||
} |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Convert a Monaco editor marker tag to an LSP diagnostic tag. |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Convert a Monaco editor position to an LSP range. |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Convert a Monaco editor range to an LSP range. |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -14,5 +14,4 @@ * Convert a Monaco editor related information to an LSP diagnostic related information. | ||
* @param relatedInformation The LSP diagnostic related information to convert. | ||
* @param Uri The Monaco Uri constructor. | ||
* @returns The diagnostic related information as Monaco editor related information. | ||
*/ | ||
export declare function toRelatedInformation(relatedInformation: ls.DiagnosticRelatedInformation, Uri: typeof monaco.Uri): monaco.editor.IRelatedInformation; | ||
export declare function toRelatedInformation(relatedInformation: ls.DiagnosticRelatedInformation): monaco.editor.IRelatedInformation; |
@@ -0,1 +1,2 @@ | ||
import { getMonaco } from './monaco.js'; | ||
import { fromRange, toRange } from './range.js'; | ||
@@ -21,6 +22,6 @@ /** | ||
* @param relatedInformation The LSP diagnostic related information to convert. | ||
* @param Uri The Monaco Uri constructor. | ||
* @returns The diagnostic related information as Monaco editor related information. | ||
*/ | ||
export function toRelatedInformation(relatedInformation, Uri) { | ||
export function toRelatedInformation(relatedInformation) { | ||
const { Uri } = getMonaco(); | ||
return { | ||
@@ -27,0 +28,0 @@ ...toRange(relatedInformation.location.range), |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Convert a Monaco editor single edit operation to an LSP text edit. |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Convert a Monaco editor symbol kind to an LSP symbol kind. |
@@ -0,1 +1,2 @@ | ||
import { getMonaco } from './monaco.js'; | ||
/** | ||
@@ -8,3 +9,80 @@ * Convert a Monaco editor symbol kind to an LSP symbol kind. | ||
export function fromSymbolKind(symbolKind) { | ||
return (symbolKind + 1); | ||
const { SymbolKind } = getMonaco().languages; | ||
if (symbolKind === SymbolKind.File) { | ||
return 1; | ||
} | ||
if (symbolKind === SymbolKind.Module) { | ||
return 2; | ||
} | ||
if (symbolKind === SymbolKind.Namespace) { | ||
return 3; | ||
} | ||
if (symbolKind === SymbolKind.Package) { | ||
return 4; | ||
} | ||
if (symbolKind === SymbolKind.Class) { | ||
return 5; | ||
} | ||
if (symbolKind === SymbolKind.Method) { | ||
return 6; | ||
} | ||
if (symbolKind === SymbolKind.Property) { | ||
return 7; | ||
} | ||
if (symbolKind === SymbolKind.Field) { | ||
return 8; | ||
} | ||
if (symbolKind === SymbolKind.Constructor) { | ||
return 9; | ||
} | ||
if (symbolKind === SymbolKind.Enum) { | ||
return 10; | ||
} | ||
if (symbolKind === SymbolKind.Interface) { | ||
return 11; | ||
} | ||
if (symbolKind === SymbolKind.Function) { | ||
return 12; | ||
} | ||
if (symbolKind === SymbolKind.Variable) { | ||
return 13; | ||
} | ||
if (symbolKind === SymbolKind.Constant) { | ||
return 14; | ||
} | ||
if (symbolKind === SymbolKind.String) { | ||
return 15; | ||
} | ||
if (symbolKind === SymbolKind.Number) { | ||
return 16; | ||
} | ||
if (symbolKind === SymbolKind.Boolean) { | ||
return 17; | ||
} | ||
if (symbolKind === SymbolKind.Array) { | ||
return 18; | ||
} | ||
if (symbolKind === SymbolKind.Object) { | ||
return 19; | ||
} | ||
if (symbolKind === SymbolKind.Key) { | ||
return 20; | ||
} | ||
if (symbolKind === SymbolKind.Null) { | ||
return 21; | ||
} | ||
if (symbolKind === SymbolKind.EnumMember) { | ||
return 22; | ||
} | ||
if (symbolKind === SymbolKind.Struct) { | ||
return 23; | ||
} | ||
if (symbolKind === SymbolKind.Event) { | ||
return 24; | ||
} | ||
if (symbolKind === SymbolKind.Operator) { | ||
return 25; | ||
} | ||
// SymbolKind === SymbolKind.TypeParameter | ||
return 26; | ||
} | ||
@@ -18,3 +96,80 @@ /** | ||
export function toSymbolKind(symbolKind) { | ||
return symbolKind - 1; | ||
const { SymbolKind } = getMonaco().languages; | ||
if (symbolKind === 1) { | ||
return SymbolKind.File; | ||
} | ||
if (symbolKind === 2) { | ||
return SymbolKind.Module; | ||
} | ||
if (symbolKind === 3) { | ||
return SymbolKind.Namespace; | ||
} | ||
if (symbolKind === 4) { | ||
return SymbolKind.Package; | ||
} | ||
if (symbolKind === 5) { | ||
return SymbolKind.Class; | ||
} | ||
if (symbolKind === 6) { | ||
return SymbolKind.Method; | ||
} | ||
if (symbolKind === 7) { | ||
return SymbolKind.Property; | ||
} | ||
if (symbolKind === 8) { | ||
return SymbolKind.Field; | ||
} | ||
if (symbolKind === 9) { | ||
return SymbolKind.Constructor; | ||
} | ||
if (symbolKind === 10) { | ||
return SymbolKind.Enum; | ||
} | ||
if (symbolKind === 11) { | ||
return SymbolKind.Interface; | ||
} | ||
if (symbolKind === 12) { | ||
return SymbolKind.Function; | ||
} | ||
if (symbolKind === 13) { | ||
return SymbolKind.Variable; | ||
} | ||
if (symbolKind === 14) { | ||
return SymbolKind.Constant; | ||
} | ||
if (symbolKind === 15) { | ||
return SymbolKind.String; | ||
} | ||
if (symbolKind === 16) { | ||
return SymbolKind.Number; | ||
} | ||
if (symbolKind === 17) { | ||
return SymbolKind.Boolean; | ||
} | ||
if (symbolKind === 18) { | ||
return SymbolKind.Array; | ||
} | ||
if (symbolKind === 19) { | ||
return SymbolKind.Object; | ||
} | ||
if (symbolKind === 20) { | ||
return SymbolKind.Key; | ||
} | ||
if (symbolKind === 21) { | ||
return SymbolKind.Null; | ||
} | ||
if (symbolKind === 22) { | ||
return SymbolKind.EnumMember; | ||
} | ||
if (symbolKind === 23) { | ||
return SymbolKind.Struct; | ||
} | ||
if (symbolKind === 24) { | ||
return SymbolKind.Event; | ||
} | ||
if (symbolKind === 25) { | ||
return SymbolKind.Operator; | ||
} | ||
// SymbolKind === 26 | ||
return SymbolKind.TypeParameter; | ||
} |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Convert a Monaco editor symbol tag to an LSP symbol tag. |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -4,0 +4,0 @@ * Convert a Monaco editor text edit to an LSP text edit. |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
/** | ||
@@ -14,5 +14,4 @@ * Convert a Monaco editor workspace edit to an LSP workspace edit. | ||
* @param workspaceEdit The LSP workspace edit to convert. | ||
* @param Uri The Monaco Uri constructor. | ||
* @returns The workspace edit as Monaco editor workspace edit. | ||
*/ | ||
export declare function toWorkspaceEdit(workspaceEdit: ls.WorkspaceEdit, Uri: typeof monaco.Uri): monaco.languages.WorkspaceEdit; | ||
export declare function toWorkspaceEdit(workspaceEdit: ls.WorkspaceEdit): monaco.languages.WorkspaceEdit; |
@@ -0,1 +1,2 @@ | ||
import { getMonaco } from './monaco.js'; | ||
import { fromTextEdit, toTextEdit } from './textEdit.js'; | ||
@@ -53,6 +54,6 @@ import { fromWorkspaceFileEdit, toWorkspaceFileEdit } from './workspaceFileEdit.js'; | ||
* @param versionId The version ID of the workspace text edit. | ||
* @param Uri The Monaco Uri constructor. | ||
* @returns The text edit and uri as Monaco editor workspace text edit. | ||
*/ | ||
function toWorkspaceTextEdit(textEdit, uri, versionId, Uri) { | ||
function toWorkspaceTextEdit(textEdit, uri, versionId) { | ||
const { Uri } = getMonaco(); | ||
return { | ||
@@ -68,6 +69,5 @@ resource: Uri.parse(uri), | ||
* @param workspaceEdit The LSP workspace edit to convert. | ||
* @param Uri The Monaco Uri constructor. | ||
* @returns The workspace edit as Monaco editor workspace edit. | ||
*/ | ||
export function toWorkspaceEdit(workspaceEdit, Uri) { | ||
export function toWorkspaceEdit(workspaceEdit) { | ||
var _a; | ||
@@ -78,3 +78,3 @@ const edits = []; | ||
for (const textEdit of textEdits) { | ||
edits.push(toWorkspaceTextEdit(textEdit, uri, undefined, Uri)); | ||
edits.push(toWorkspaceTextEdit(textEdit, uri)); | ||
} | ||
@@ -87,7 +87,7 @@ } | ||
for (const textEdit of documentChange.edits) { | ||
edits.push(toWorkspaceTextEdit(textEdit, documentChange.textDocument.uri, (_a = documentChange.textDocument.version) !== null && _a !== void 0 ? _a : undefined, Uri)); | ||
edits.push(toWorkspaceTextEdit(textEdit, documentChange.textDocument.uri, (_a = documentChange.textDocument.version) !== null && _a !== void 0 ? _a : undefined)); | ||
} | ||
} | ||
else { | ||
edits.push(toWorkspaceFileEdit(documentChange, Uri)); | ||
edits.push(toWorkspaceFileEdit(documentChange)); | ||
} | ||
@@ -94,0 +94,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
type WorkspaceFileEdit = ls.CreateFile | ls.DeleteFile | ls.RenameFile; | ||
@@ -15,6 +15,5 @@ /** | ||
* @param workspaceFileEdit The LSP workspace file edit to convert. | ||
* @param Uri The Monaco Uri constructor. | ||
* @returns The workspace file edit options Monaco editor workspace file edit options. | ||
*/ | ||
export declare function toWorkspaceFileEdit(workspaceFileEdit: WorkspaceFileEdit, Uri: typeof monaco.Uri): monaco.languages.IWorkspaceFileEdit; | ||
export declare function toWorkspaceFileEdit(workspaceFileEdit: WorkspaceFileEdit): monaco.languages.IWorkspaceFileEdit; | ||
export {}; |
@@ -0,1 +1,2 @@ | ||
import { getMonaco } from './monaco.js'; | ||
import { fromWorkspaceFileEditOptions, toWorkspaceFileEditOptions } from './workspaceFileEditOptions.js'; | ||
@@ -9,27 +10,30 @@ /** | ||
export function fromWorkspaceFileEdit(workspaceFileEdit) { | ||
let result; | ||
if (workspaceFileEdit.oldResource) { | ||
if (workspaceFileEdit.newResource) { | ||
return { | ||
result = workspaceFileEdit.newResource | ||
? { | ||
kind: 'rename', | ||
oldUri: String(workspaceFileEdit.oldResource), | ||
newUri: String(workspaceFileEdit.newResource), | ||
options: workspaceFileEdit.options && fromWorkspaceFileEditOptions(workspaceFileEdit.options) | ||
newUri: String(workspaceFileEdit.newResource) | ||
} | ||
: { | ||
kind: 'delete', | ||
uri: String(workspaceFileEdit.oldResource) | ||
}; | ||
} | ||
return { | ||
kind: 'delete', | ||
uri: String(workspaceFileEdit.oldResource), | ||
options: workspaceFileEdit.options && fromWorkspaceFileEditOptions(workspaceFileEdit.options) | ||
}; | ||
} | ||
if (workspaceFileEdit.newResource) { | ||
return { | ||
else if (workspaceFileEdit.newResource) { | ||
result = { | ||
kind: 'create', | ||
uri: String(workspaceFileEdit.newResource), | ||
options: workspaceFileEdit.options && fromWorkspaceFileEditOptions(workspaceFileEdit.options) | ||
uri: String(workspaceFileEdit.newResource) | ||
}; | ||
} | ||
throw new Error('Could not convert workspace file edit to language server type', { | ||
cause: workspaceFileEdit | ||
}); | ||
else { | ||
throw new Error('Could not convert workspace file edit to language server type', { | ||
cause: workspaceFileEdit | ||
}); | ||
} | ||
if (workspaceFileEdit.options) { | ||
result.options = fromWorkspaceFileEditOptions(workspaceFileEdit.options); | ||
} | ||
return result; | ||
} | ||
@@ -40,29 +44,18 @@ /** | ||
* @param workspaceFileEdit The LSP workspace file edit to convert. | ||
* @param Uri The Monaco Uri constructor. | ||
* @returns The workspace file edit options Monaco editor workspace file edit options. | ||
*/ | ||
export function toWorkspaceFileEdit(workspaceFileEdit, Uri) { | ||
if (workspaceFileEdit.kind === 'create') { | ||
return { | ||
newResource: Uri.parse(workspaceFileEdit.uri), | ||
options: workspaceFileEdit.options | ||
? toWorkspaceFileEditOptions(workspaceFileEdit.options) | ||
: undefined | ||
}; | ||
export function toWorkspaceFileEdit(workspaceFileEdit) { | ||
const { Uri } = getMonaco(); | ||
const result = workspaceFileEdit.kind === 'create' | ||
? { newResource: Uri.parse(workspaceFileEdit.uri) } | ||
: workspaceFileEdit.kind === 'delete' | ||
? { oldResource: Uri.parse(workspaceFileEdit.uri) } | ||
: { | ||
oldResource: Uri.parse(workspaceFileEdit.oldUri), | ||
newResource: Uri.parse(workspaceFileEdit.newUri) | ||
}; | ||
if (workspaceFileEdit.options) { | ||
result.options = toWorkspaceFileEditOptions(workspaceFileEdit.options); | ||
} | ||
if (workspaceFileEdit.kind === 'delete') { | ||
return { | ||
oldResource: Uri.parse(workspaceFileEdit.uri), | ||
options: workspaceFileEdit.options | ||
? toWorkspaceFileEditOptions(workspaceFileEdit.options) | ||
: undefined | ||
}; | ||
} | ||
return { | ||
oldResource: Uri.parse(workspaceFileEdit.oldUri), | ||
newResource: Uri.parse(workspaceFileEdit.newUri), | ||
options: workspaceFileEdit.options | ||
? toWorkspaceFileEditOptions(workspaceFileEdit.options) | ||
: undefined | ||
}; | ||
return result; | ||
} |
@@ -1,3 +0,3 @@ | ||
import type * as monaco from 'monaco-editor'; | ||
import type * as ls from 'vscode-languageserver-types'; | ||
import type * as monaco from 'monaco-types'; | ||
import type * as ls from 'vscode-languageserver-protocol'; | ||
type LSFileEditOptions = ls.CreateFileOptions & ls.DeleteFileOptions & ls.RenameFileOptions; | ||
@@ -4,0 +4,0 @@ /** |
@@ -8,8 +8,16 @@ /** | ||
export function fromWorkspaceFileEditOptions(options) { | ||
return { | ||
ignoreIfExists: options.ignoreIfExists, | ||
ignoreIfNotExists: options.ignoreIfNotExists, | ||
overwrite: options.overwrite, | ||
recursive: options.recursive | ||
}; | ||
const result = {}; | ||
if (options.ignoreIfExists != null) { | ||
result.ignoreIfExists = options.ignoreIfExists; | ||
} | ||
if (options.ignoreIfNotExists != null) { | ||
result.ignoreIfNotExists = options.ignoreIfNotExists; | ||
} | ||
if (options.overwrite != null) { | ||
result.overwrite = options.overwrite; | ||
} | ||
if (options.recursive != null) { | ||
result.recursive = options.recursive; | ||
} | ||
return result; | ||
} | ||
@@ -23,8 +31,16 @@ /** | ||
export function toWorkspaceFileEditOptions(options) { | ||
return { | ||
overwrite: options.overwrite, | ||
ignoreIfExists: options.ignoreIfExists, | ||
ignoreIfNotExists: options.ignoreIfNotExists, | ||
recursive: options.recursive | ||
}; | ||
const result = {}; | ||
if (options.ignoreIfExists != null) { | ||
result.ignoreIfExists = options.ignoreIfExists; | ||
} | ||
if (options.ignoreIfNotExists != null) { | ||
result.ignoreIfNotExists = options.ignoreIfNotExists; | ||
} | ||
if (options.overwrite != null) { | ||
result.overwrite = options.overwrite; | ||
} | ||
if (options.recursive != null) { | ||
result.recursive = options.recursive; | ||
} | ||
return result; | ||
} |
{ | ||
"name": "monaco-languageserver-types", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Convert between language server types and Monaco editor types", | ||
@@ -32,3 +32,4 @@ "type": "module", | ||
"dependencies": { | ||
"vscode-languageserver-types": "^3.0.0" | ||
"monaco-types": "^0.1.0", | ||
"vscode-languageserver-protocol": "^3.0.0" | ||
}, | ||
@@ -35,0 +36,0 @@ "devDependencies": { |
@@ -20,4 +20,4 @@ # monaco-languageserver-types | ||
This package exports function to convert language server types to Monaco editor types and vise | ||
versa. It does so without importing `monaco-editor` or `vscode-languageserver-types`, meaning it has | ||
no runtime dependencies. | ||
versa. It does so without importing `monaco-editor` or `vscode-languageserver-protocol`, meaning it | ||
has no runtime dependencies. | ||
@@ -29,8 +29,13 @@ For each Monaco editor / language server type, there are two functions: | ||
Some types require the Monaco editor module. However, users may load Monaco from different sources. | ||
To support this, you should call `setMonaco(monaco)` once in your application. | ||
For example: | ||
```typescript | ||
import type * as monaco from 'monaco-editor' | ||
import { fromRange, toRange } from 'monaco-languageserver-types' | ||
import * as monaco from 'monaco-editor' | ||
import { fromRange, setMonaco, toRange } from 'monaco-languageserver-types' | ||
setMonaco(monaco) | ||
const monacoRange: monaco.IRange = { | ||
@@ -50,7 +55,4 @@ startLineNumber: 1, | ||
Some Monaco editor types contain a `monaco.Uri` instance. For these cases the `to*` accept | ||
`monaco.Uri` as a second argument. | ||
## License | ||
[MIT](LICENSE.md) @ [Remco Haszing](https://github.com/remcohaszing) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
75627
65
2060
56
0
2
+ Addedmonaco-types@^0.1.0
+ Addedmonaco-types@0.1.0(transitive)
+ Addedvscode-jsonrpc@8.2.0(transitive)
+ Addedvscode-languageserver-protocol@3.17.5(transitive)
- Removedvscode-languageserver-types@^3.0.0