From df05905eb5a63646bbd12b94dfb98c455d184745 Mon Sep 17 00:00:00 2001 From: Kai Salmen Date: Mon, 20 Jun 2022 11:23:44 +0200 Subject: [PATCH] Use default space-before-function-paren from eslint-config-standard --- .eslintrc.js | 5 - .vscode/settings.json | 6 +- package-lock.json | 108 +++++++-- packages/client/src/console-window.ts | 12 +- packages/client/src/disposable.ts | 6 +- packages/client/src/monaco-converter.ts | 216 +++++++++--------- packages/client/src/monaco-language-client.ts | 14 +- packages/client/src/monaco-services.ts | 6 +- packages/client/src/monaco-workspace.ts | 2 +- 9 files changed, 215 insertions(+), 160 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 9037f521d..f8e11791f 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -21,11 +21,6 @@ module.exports = { indent: ['error', 4, { SwitchCase: 1 }], - 'space-before-function-paren': ['error', { - anonymous: 'always', - named: 'never', - asyncArrow: 'always' - }], semi: ['error', 'always'], 'no-extra-semi': 'off', '@typescript-eslint/no-extra-semi': ['error'], diff --git a/.vscode/settings.json b/.vscode/settings.json index c58016710..18270e0be 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,10 +4,12 @@ "editor.formatOnSave": false, "workbench.editor.revealIfOpen": true, "[javascript]": { - "editor.formatOnSave": true + "editor.formatOnSave": true, + "editor.defaultFormatter": "dbaeumer.vscode-eslint" }, "[typescript]": { - "editor.formatOnSave": true + "editor.formatOnSave": true, + "editor.defaultFormatter": "dbaeumer.vscode-eslint" }, "eslint.validate": [ "javascript", diff --git a/package-lock.json b/package-lock.json index 5442dc558..b8d8ce56e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,8 +6,10 @@ "": { "workspaces": [ "packages/client", + "packages/vscode-ws-jsonrpc", "packages/examples/node", "packages/examples/client", + "packages/examples/browser-lsp", "packages/examples/browser", "packages/examples/browser-old" ], @@ -30,14 +32,6 @@ "npm": ">=7.10.0" } }, - "node_modules/@codingame/monaco-jsonrpc": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@codingame/monaco-jsonrpc/-/monaco-jsonrpc-0.4.0.tgz", - "integrity": "sha512-5IQkYvFMyWQWutFhK77Tk5q1VIQoFySElqpAI1fUWXIIAepiYD7xJRawzMgJqhIzER7t44FbBN4uVvoXLRmJ6g==", - "dependencies": { - "vscode-jsonrpc": "^8.0.1" - } - }, "node_modules/@cspotcode/source-map-consumer": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", @@ -1165,6 +1159,10 @@ "resolved": "packages/examples/browser-old", "link": true }, + "node_modules/browser-lsp": { + "resolved": "packages/examples/browser-lsp", + "link": true + }, "node_modules/browserslist": { "version": "4.20.3", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.20.3.tgz", @@ -5266,6 +5264,10 @@ "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.3.tgz", "integrity": "sha512-EcswR2S8bpR7fD0YPeS7r2xXExrScVMxg4MedACaWHEtx9ftCF/qHG1xGkolzTPcEmjTavCQgbVzHUIdTMzFGA==" }, + "node_modules/vscode-ws-jsonrpc": { + "resolved": "packages/vscode-ws-jsonrpc", + "link": true + }, "node_modules/watchpack": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.3.1.tgz", @@ -5559,7 +5561,7 @@ "version": "2.0.0-dev.1", "license": "MIT", "dependencies": { - "glob-to-regexp": "^0.4.1", + "glob-to-regexp": "0.4.1", "vscode": "npm:@codingame/monaco-vscode-api@^1.68.4", "vscode-jsonrpc": "8.0.1", "vscode-languageclient": "8.0.1", @@ -5568,10 +5570,16 @@ }, "devDependencies": { "@types/glob-to-regexp": "^0.4.1", - "@types/node": "^16.11.7", + "@types/node": "16.11.7", "@types/vscode": "1.68.0" } }, + "packages/client/node_modules/@types/node": { + "version": "16.11.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.7.tgz", + "integrity": "sha512-QB5D2sqfSjCmTuWcBWyJ+/44bcjO7VbjSbOE0ucoVbAsSNQc4Lt6QkgkVXkTDwkL4z/beecZNDvVX15D4P8Jbw==", + "dev": true + }, "packages/examples/browser": { "name": "browser-example", "dependencies": { @@ -5581,6 +5589,15 @@ "vscode-json-languageservice": "^5.0.0" } }, + "packages/examples/browser-lsp": { + "dependencies": { + "monaco-editor": "0.33.0", + "monaco-editor-workers": "0.33.0", + "monaco-languageclient": "../../client", + "vscode-languageserver": "8.0.1", + "vscode-languageserver-protocol": "3.17.1" + } + }, "packages/examples/browser-old": { "name": "browser-example-old", "dependencies": { @@ -5593,11 +5610,11 @@ "packages/examples/client": { "name": "example-client", "dependencies": { - "@codingame/monaco-jsonrpc": "^0.4.0", "monaco-editor": "0.33.0", "monaco-editor-workers": "0.33.0", "monaco-languageclient": "../../client", - "normalize-url": "^7.0.3" + "normalize-url": "^7.0.3", + "vscode-ws-jsonrpc": "../../vscode-ws-jsonrpc" }, "devDependencies": { "css-loader": "^6.7.1", @@ -5613,7 +5630,6 @@ "packages/examples/node": { "name": "node-example", "dependencies": { - "@codingame/monaco-jsonrpc": "^0.4.0", "@types/ws": "^8.5.3", "express": "^4.17.3", "normalize-url": "^7.0.3", @@ -5621,6 +5637,7 @@ "vscode-json-languageservice": "^5.0.0", "vscode-languageserver": "8.0.1", "vscode-uri": "^3.0.3", + "vscode-ws-jsonrpc": "../../vscode-ws-jsonrpc", "ws": "^8.5.0" }, "devDependencies": { @@ -5628,17 +5645,25 @@ "@types/node": "^16.11.7", "ts-node": "^10.7.0" } - } - }, - "dependencies": { - "@codingame/monaco-jsonrpc": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/@codingame/monaco-jsonrpc/-/monaco-jsonrpc-0.4.0.tgz", - "integrity": "sha512-5IQkYvFMyWQWutFhK77Tk5q1VIQoFySElqpAI1fUWXIIAepiYD7xJRawzMgJqhIzER7t44FbBN4uVvoXLRmJ6g==", - "requires": { + }, + "packages/vscode-ws-jsonrpc": { + "version": "0.5.0-dev.0", + "license": "MIT", + "dependencies": { "vscode-jsonrpc": "^8.0.1" + }, + "devDependencies": { + "@types/node": "16.11.7" } }, + "packages/vscode-ws-jsonrpc/node_modules/@types/node": { + "version": "16.11.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.7.tgz", + "integrity": "sha512-QB5D2sqfSjCmTuWcBWyJ+/44bcjO7VbjSbOE0ucoVbAsSNQc4Lt6QkgkVXkTDwkL4z/beecZNDvVX15D4P8Jbw==", + "dev": true + } + }, + "dependencies": { "@cspotcode/source-map-consumer": { "version": "0.8.0", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz", @@ -6539,6 +6564,16 @@ "vscode-json-languageservice": "^5.0.0" } }, + "browser-lsp": { + "version": "file:packages/examples/browser-lsp", + "requires": { + "monaco-editor": "0.33.0", + "monaco-editor-workers": "0.33.0", + "monaco-languageclient": "../../client", + "vscode-languageserver": "8.0.1", + "vscode-languageserver-protocol": "3.17.1" + } + }, "browserslist": { "version": "4.20.3", "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.20.3.tgz", @@ -7427,7 +7462,6 @@ "example-client": { "version": "file:packages/examples/client", "requires": { - "@codingame/monaco-jsonrpc": "^0.4.0", "css-loader": "^6.7.1", "file-loader": "^6.2.0", "http-server": "^14.1.0", @@ -7439,6 +7473,7 @@ "source-map-loader": "^3.0.1", "style-loader": "^3.3.1", "ts-loader": "^9.3.0", + "vscode-ws-jsonrpc": "../../vscode-ws-jsonrpc", "webpack-cli": "^4.9.2" } }, @@ -8350,14 +8385,22 @@ "version": "file:packages/client", "requires": { "@types/glob-to-regexp": "^0.4.1", - "@types/node": "^16.11.7", + "@types/node": "16.11.7", "@types/vscode": "1.68.0", - "glob-to-regexp": "^0.4.1", + "glob-to-regexp": "0.4.1", "vscode": "npm:@codingame/monaco-vscode-api@^1.68.4", "vscode-jsonrpc": "8.0.1", "vscode-languageclient": "8.0.1", "vscode-languageserver-textdocument": "1.0.5", "vscode-uri": "3.0.3" + }, + "dependencies": { + "@types/node": { + "version": "16.11.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.7.tgz", + "integrity": "sha512-QB5D2sqfSjCmTuWcBWyJ+/44bcjO7VbjSbOE0ucoVbAsSNQc4Lt6QkgkVXkTDwkL4z/beecZNDvVX15D4P8Jbw==", + "dev": true + } } }, "ms": { @@ -8392,7 +8435,6 @@ "node-example": { "version": "file:packages/examples/node", "requires": { - "@codingame/monaco-jsonrpc": "^0.4.0", "@types/express": "^4.17.13", "@types/node": "^16.11.7", "@types/ws": "^8.5.3", @@ -8403,6 +8445,7 @@ "vscode-json-languageservice": "^5.0.0", "vscode-languageserver": "8.0.1", "vscode-uri": "^3.0.3", + "vscode-ws-jsonrpc": "../../vscode-ws-jsonrpc", "ws": "^8.5.0" } }, @@ -9529,6 +9572,21 @@ "resolved": "https://registry.npmjs.org/vscode-uri/-/vscode-uri-3.0.3.tgz", "integrity": "sha512-EcswR2S8bpR7fD0YPeS7r2xXExrScVMxg4MedACaWHEtx9ftCF/qHG1xGkolzTPcEmjTavCQgbVzHUIdTMzFGA==" }, + "vscode-ws-jsonrpc": { + "version": "file:packages/vscode-ws-jsonrpc", + "requires": { + "@types/node": "16.11.7", + "vscode-jsonrpc": "^8.0.1" + }, + "dependencies": { + "@types/node": { + "version": "16.11.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-16.11.7.tgz", + "integrity": "sha512-QB5D2sqfSjCmTuWcBWyJ+/44bcjO7VbjSbOE0ucoVbAsSNQc4Lt6QkgkVXkTDwkL4z/beecZNDvVX15D4P8Jbw==", + "dev": true + } + } + }, "watchpack": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.3.1.tgz", diff --git a/packages/client/src/console-window.ts b/packages/client/src/console-window.ts index a57fc7c8c..58a7920a0 100644 --- a/packages/client/src/console-window.ts +++ b/packages/client/src/console-window.ts @@ -7,7 +7,7 @@ import * as vscode from 'vscode'; export class ConsoleWindow implements Window { protected readonly channels = new Map(); - showMessage(severity: Severity, message: string, ...actions: T[]): Thenable { + showMessage (severity: Severity, message: string, ...actions: T[]): Thenable { if (severity === Severity.Error) { console.error(message); } @@ -23,23 +23,23 @@ export class ConsoleWindow implements Window { return Promise.resolve(undefined); } - createOutputChannel(name: string): vscode.OutputChannel { + createOutputChannel (name: string): vscode.OutputChannel { const existing = this.channels.get(name); if (existing) { return existing; } const channel: vscode.OutputChannel = { name: 'default', - append(value: string): void { + append (value: string): void { console.log(name + ': ' + value); }, - appendLine(line: string): void { + appendLine (line: string): void { console.log(name + ': ' + line); }, - show(): void { + show (): void { // no-op }, - dispose(): void { + dispose (): void { // no-op }, replace: function (value: string): void { diff --git a/packages/client/src/disposable.ts b/packages/client/src/disposable.ts index f4dde326a..e61fbb7d8 100644 --- a/packages/client/src/disposable.ts +++ b/packages/client/src/disposable.ts @@ -8,17 +8,17 @@ import { Disposable } from 'vscode-jsonrpc'; export class DisposableCollection implements Disposable { protected readonly disposables: Disposable[] = []; - dispose(): void { + dispose (): void { while (this.disposables.length !== 0) { this.disposables.pop()?.dispose(); } } - push(disposable: Disposable): Disposable { + push (disposable: Disposable): Disposable { const disposables = this.disposables; disposables.push(disposable); return { - dispose(): void { + dispose (): void { const index = disposables.indexOf(disposable); if (index !== -1) { disposables.splice(index, 1); diff --git a/packages/client/src/monaco-converter.ts b/packages/client/src/monaco-converter.ts index cfead6882..6b3b6b658 100644 --- a/packages/client/src/monaco-converter.ts +++ b/packages/client/src/monaco-converter.ts @@ -31,7 +31,7 @@ export interface ProtocolDocumentLink extends monaco.languages.ILink { } export namespace ProtocolDocumentLink { - export function is(item: any): item is ProtocolDocumentLink { + export function is (item: any): item is ProtocolDocumentLink { return !!item && 'data' in item; } } @@ -41,7 +41,7 @@ export interface ProtocolCodeLens extends monaco.languages.CodeLens { } export namespace ProtocolCodeLens { - export function is(item: any): item is ProtocolCodeLens { + export function is (item: any): item is ProtocolCodeLens { return !!item && 'data' in item; } } @@ -55,7 +55,7 @@ export interface ProtocolCompletionItem extends monaco.languages.CompletionItem insertTextMode?: InsertTextMode; } export namespace ProtocolCompletionItem { - export function is(item: any): item is ProtocolCompletionItem { + export function is (item: any): item is ProtocolCompletionItem { return !!item && 'data' in item; } } @@ -64,7 +64,7 @@ export interface ProtocolCodeAction extends monaco.languages.CodeAction { data?: unknown; } export namespace ProtocolCodeAction { - export function is(item: any): item is ProtocolCodeAction { + export function is (item: any): item is ProtocolCodeAction { return !!item && 'data' in item; } } @@ -73,14 +73,14 @@ export interface ProtocolInlayHint extends monaco.languages.InlayHint { data?: unknown; } export namespace ProtocolInlayHint { - export function is(item: any): item is ProtocolInlayHint { + export function is (item: any): item is ProtocolInlayHint { return !!item && 'data' in item; } } type RangeReplace = { insert: monaco.IRange; replace: monaco.IRange } -function isRangeReplace(v: Partial | RangeReplace): v is RangeReplace { +function isRangeReplace (v: Partial | RangeReplace): v is RangeReplace { return (v as RangeReplace).insert !== undefined; } @@ -88,14 +88,14 @@ function isRangeReplace(v: Partial | RangeReplace): v is RangeRep * @deprecated use @CodinGame/monaco-vscode-api and vscode-languageclient/lib/common/codeConverter (see browser example) */ export class MonacoToProtocolConverter { - public constructor(protected readonly _monaco: typeof monaco) { } + public constructor (protected readonly _monaco: typeof monaco) { } asPosition(lineNumber: undefined | null, column: undefined | null): {}; asPosition(lineNumber: number, column: undefined | null): Pick; asPosition(lineNumber: undefined | null, column: number): Pick; asPosition(lineNumber: number, column: number): Position; asPosition(lineNumber: number | undefined | null, column: number | undefined | null): Partial; - asPosition(lineNumber: number | undefined | null, column: number | undefined | null): Partial { + asPosition (lineNumber: number | undefined | null, column: number | undefined | null): Partial { const line = lineNumber === undefined || lineNumber === null ? undefined : lineNumber - 1; const character = column === undefined || column === null ? undefined : column - 1; return { @@ -112,7 +112,7 @@ export class MonacoToProtocolConverter { asRange(range: Partial): RecursivePartial; asRange(range: Partial | undefined): RecursivePartial | undefined; asRange(range: Partial | null): RecursivePartial | null; - asRange(range: Partial | undefined | null | RangeReplace): RecursivePartial | undefined | null { + asRange (range: Partial | undefined | null | RangeReplace): RecursivePartial | undefined | null { if (range === undefined) { return undefined; } @@ -134,7 +134,7 @@ export class MonacoToProtocolConverter { asLocation(item: monaco.languages.Location): Location; asLocation(item: undefined | null): undefined; asLocation(item: monaco.languages.Location | undefined | null): Location | undefined; - asLocation(item: monaco.languages.Location | undefined | null): Location | undefined { + asLocation (item: monaco.languages.Location | undefined | null): Location | undefined { if (!item) { return undefined; } @@ -146,33 +146,33 @@ export class MonacoToProtocolConverter { }; } - asTextDocumentIdentifier(model: monaco.editor.IReadOnlyModel): TextDocumentIdentifier { + asTextDocumentIdentifier (model: monaco.editor.IReadOnlyModel): TextDocumentIdentifier { return { uri: model.uri.toString() }; } - asTextDocumentPositionParams(model: monaco.editor.IReadOnlyModel, position: monaco.Position): TextDocumentPositionParams { + asTextDocumentPositionParams (model: monaco.editor.IReadOnlyModel, position: monaco.Position): TextDocumentPositionParams { return { textDocument: this.asTextDocumentIdentifier(model), position: this.asPosition(position.lineNumber, position.column) }; } - asCompletionParams(model: monaco.editor.IReadOnlyModel, position: monaco.Position, context: monaco.languages.CompletionContext): CompletionParams { + asCompletionParams (model: monaco.editor.IReadOnlyModel, position: monaco.Position, context: monaco.languages.CompletionContext): CompletionParams { return Object.assign(this.asTextDocumentPositionParams(model, position), { context: this.asCompletionContext(context) }); } - asCompletionContext(context: monaco.languages.CompletionContext): CompletionContext { + asCompletionContext (context: monaco.languages.CompletionContext): CompletionContext { return { triggerKind: this.asCompletionTriggerKind(context.triggerKind), triggerCharacter: context.triggerCharacter }; } - asSignatureHelpContext(context: monaco.languages.SignatureHelpContext): SignatureHelpContext { + asSignatureHelpContext (context: monaco.languages.SignatureHelpContext): SignatureHelpContext { return { triggerKind: this.asSignatureHelpTriggerKind(context.triggerKind), triggerCharacter: context.triggerCharacter, @@ -181,7 +181,7 @@ export class MonacoToProtocolConverter { }; } - asSignatureHelp(signatureHelp: monaco.languages.SignatureHelp | undefined): SignatureHelp | undefined { + asSignatureHelp (signatureHelp: monaco.languages.SignatureHelp | undefined): SignatureHelp | undefined { if (signatureHelp === undefined) { return undefined; } @@ -192,7 +192,7 @@ export class MonacoToProtocolConverter { }; } - asSignatureInformation(signatureInformation: monaco.languages.SignatureInformation): SignatureInformation { + asSignatureInformation (signatureInformation: monaco.languages.SignatureInformation): SignatureInformation { return { documentation: this.asMarkupContent(signatureInformation.documentation), label: signatureInformation.label, @@ -201,14 +201,14 @@ export class MonacoToProtocolConverter { }; } - asParameterInformation(parameterInformation: monaco.languages.ParameterInformation): ParameterInformation { + asParameterInformation (parameterInformation: monaco.languages.ParameterInformation): ParameterInformation { return { documentation: this.asMarkupContent(parameterInformation.documentation), label: parameterInformation.label }; } - asMarkupContent(markupContent: (string | monaco.IMarkdownString | undefined)): string | MarkupContent | undefined { + asMarkupContent (markupContent: (string | monaco.IMarkdownString | undefined)): string | MarkupContent | undefined { if (markupContent === undefined) { return undefined; } @@ -221,7 +221,7 @@ export class MonacoToProtocolConverter { }; } - asSignatureHelpTriggerKind(triggerKind: monaco.languages.SignatureHelpTriggerKind): SignatureHelpTriggerKind { + asSignatureHelpTriggerKind (triggerKind: monaco.languages.SignatureHelpTriggerKind): SignatureHelpTriggerKind { switch (triggerKind) { case this._monaco.languages.SignatureHelpTriggerKind.ContentChange: return SignatureHelpTriggerKind.ContentChange; @@ -232,7 +232,7 @@ export class MonacoToProtocolConverter { } } - asCompletionTriggerKind(triggerKind: monaco.languages.CompletionTriggerKind): CompletionTriggerKind { + asCompletionTriggerKind (triggerKind: monaco.languages.CompletionTriggerKind): CompletionTriggerKind { switch (triggerKind) { case this._monaco.languages.CompletionTriggerKind.TriggerCharacter: return CompletionTriggerKind.TriggerCharacter; @@ -243,7 +243,7 @@ export class MonacoToProtocolConverter { } } - asCompletionItem(item: monaco.languages.CompletionItem): CompletionItem { + asCompletionItem (item: monaco.languages.CompletionItem): CompletionItem { const result: CompletionItem = { label: item.label as string }; const protocolItem = ProtocolCompletionItem.is(item) ? item : undefined; if (item.detail) { result.detail = item.detail; } @@ -277,7 +277,7 @@ export class MonacoToProtocolConverter { return result; } - protected asCompletionItemKind(value: monaco.languages.CompletionItemKind, original: CompletionItemKind | undefined): CompletionItemKind { + protected asCompletionItemKind (value: monaco.languages.CompletionItemKind, original: CompletionItemKind | undefined): CompletionItemKind { if (original !== undefined) { return original; } @@ -312,7 +312,7 @@ export class MonacoToProtocolConverter { } } - protected asDocumentation(format: string, documentation: string | monaco.IMarkdownString): string | MarkupContent { + protected asDocumentation (format: string, documentation: string | monaco.IMarkdownString): string | MarkupContent { switch (format) { case MarkupKind.PlainText: return { kind: format, value: documentation as string }; @@ -323,7 +323,7 @@ export class MonacoToProtocolConverter { } } - protected fillPrimaryInsertText(target: CompletionItem, source: ProtocolCompletionItem): void { + protected fillPrimaryInsertText (target: CompletionItem, source: ProtocolCompletionItem): void { let format: InsertTextFormat = InsertTextFormat.PlainText; let text: string | undefined; let range: Range | undefined; @@ -347,7 +347,7 @@ export class MonacoToProtocolConverter { target.insertTextMode = source.insertTextMode; } - asTextEdit(edit: monaco.editor.ISingleEditOperation): TextEdit { + asTextEdit (edit: monaco.editor.ISingleEditOperation): TextEdit { const range = this.asRange(edit.range)!; return { range, @@ -358,14 +358,14 @@ export class MonacoToProtocolConverter { asTextEdits(items: monaco.editor.ISingleEditOperation[]): TextEdit[]; asTextEdits(items: undefined | null): undefined; asTextEdits(items: monaco.editor.ISingleEditOperation[] | undefined | null): TextEdit[] | undefined; - asTextEdits(items: monaco.editor.ISingleEditOperation[] | undefined | null): TextEdit[] | undefined { + asTextEdits (items: monaco.editor.ISingleEditOperation[] | undefined | null): TextEdit[] | undefined { if (!items) { return undefined; } return items.map(item => this.asTextEdit(item)); } - asReferenceParams(model: monaco.editor.IReadOnlyModel, position: monaco.Position, options: { includeDeclaration: boolean; }): ReferenceParams { + asReferenceParams (model: monaco.editor.IReadOnlyModel, position: monaco.Position, options: { includeDeclaration: boolean; }): ReferenceParams { return { textDocument: this.asTextDocumentIdentifier(model), position: this.asPosition(position.lineNumber, position.column), @@ -373,19 +373,19 @@ export class MonacoToProtocolConverter { }; } - asDocumentSymbolParams(model: monaco.editor.IReadOnlyModel): DocumentSymbolParams { + asDocumentSymbolParams (model: monaco.editor.IReadOnlyModel): DocumentSymbolParams { return { textDocument: this.asTextDocumentIdentifier(model) }; } - asCodeLensParams(model: monaco.editor.IReadOnlyModel): CodeLensParams { + asCodeLensParams (model: monaco.editor.IReadOnlyModel): CodeLensParams { return { textDocument: this.asTextDocumentIdentifier(model) }; } - asDiagnosticSeverity(value: monaco.MarkerSeverity): DiagnosticSeverity | undefined { + asDiagnosticSeverity (value: monaco.MarkerSeverity): DiagnosticSeverity | undefined { switch (value) { case this._monaco.MarkerSeverity.Error: return DiagnosticSeverity.Error; @@ -399,21 +399,21 @@ export class MonacoToProtocolConverter { return undefined; } - asDiagnostic(marker: monaco.editor.IMarkerData): Diagnostic { + asDiagnostic (marker: monaco.editor.IMarkerData): Diagnostic { const range = this.asRange(new this._monaco.Range(marker.startLineNumber, marker.startColumn, marker.endLineNumber, marker.endColumn)); const severity = this.asDiagnosticSeverity(marker.severity); const diag = Diagnostic.create(range, marker.message, severity, marker.code as string, marker.source); return diag; } - asDiagnostics(markers: monaco.editor.IMarkerData[]): Diagnostic[] { + asDiagnostics (markers: monaco.editor.IMarkerData[]): Diagnostic[] { if (markers === void 0 || markers === null) { return markers; } return markers.map(marker => this.asDiagnostic(marker)); } - asCodeActionContext(context: monaco.languages.CodeActionContext, diagnostics: Diagnostic[]): CodeActionContext { + asCodeActionContext (context: monaco.languages.CodeActionContext, diagnostics: Diagnostic[]): CodeActionContext { if (context === void 0 || context === null) { return context; } @@ -421,7 +421,7 @@ export class MonacoToProtocolConverter { return CodeActionContext.create(diagnostics, Is.string(context.only) ? [context.only] : undefined, undefined); } - asCodeActionParams(model: monaco.editor.IReadOnlyModel, range: monaco.Range, context: monaco.languages.CodeActionContext, diagnostics: Diagnostic[]): CodeActionParams { + asCodeActionParams (model: monaco.editor.IReadOnlyModel, range: monaco.Range, context: monaco.languages.CodeActionContext, diagnostics: Diagnostic[]): CodeActionParams { return { textDocument: this.asTextDocumentIdentifier(model), range: this.asRange(range), @@ -429,7 +429,7 @@ export class MonacoToProtocolConverter { }; } - asCommand(item: monaco.languages.Command | undefined | null): Command | undefined { + asCommand (item: monaco.languages.Command | undefined | null): Command | undefined { if (item) { const args = item.arguments || []; return Command.create(item.title, item.id, ...args); @@ -437,7 +437,7 @@ export class MonacoToProtocolConverter { return undefined; } - asCodeLens(item: monaco.languages.CodeLens): CodeLens { + asCodeLens (item: monaco.languages.CodeLens): CodeLens { const result = CodeLens.create(this.asRange(item.range)); if (item.command) { result.command = this.asCommand(item.command); } if (ProtocolCodeLens.is(item)) { @@ -446,18 +446,18 @@ export class MonacoToProtocolConverter { return result; } - asFormattingOptions(options: monaco.languages.FormattingOptions): FormattingOptions { + asFormattingOptions (options: monaco.languages.FormattingOptions): FormattingOptions { return { tabSize: options.tabSize, insertSpaces: options.insertSpaces }; } - asDocumentFormattingParams(model: monaco.editor.IReadOnlyModel, options: monaco.languages.FormattingOptions): DocumentFormattingParams { + asDocumentFormattingParams (model: monaco.editor.IReadOnlyModel, options: monaco.languages.FormattingOptions): DocumentFormattingParams { return { textDocument: this.asTextDocumentIdentifier(model), options: this.asFormattingOptions(options) }; } - asDocumentRangeFormattingParams(model: monaco.editor.IReadOnlyModel, range: monaco.Range, options: monaco.languages.FormattingOptions): DocumentRangeFormattingParams { + asDocumentRangeFormattingParams (model: monaco.editor.IReadOnlyModel, range: monaco.Range, options: monaco.languages.FormattingOptions): DocumentRangeFormattingParams { return { textDocument: this.asTextDocumentIdentifier(model), range: this.asRange(range), @@ -465,7 +465,7 @@ export class MonacoToProtocolConverter { }; } - asDocumentOnTypeFormattingParams(model: monaco.editor.IReadOnlyModel, position: monaco.IPosition, ch: string, options: monaco.languages.FormattingOptions): DocumentOnTypeFormattingParams { + asDocumentOnTypeFormattingParams (model: monaco.editor.IReadOnlyModel, position: monaco.IPosition, ch: string, options: monaco.languages.FormattingOptions): DocumentOnTypeFormattingParams { return { textDocument: this.asTextDocumentIdentifier(model), position: this.asPosition(position.lineNumber, position.column), @@ -474,7 +474,7 @@ export class MonacoToProtocolConverter { }; } - asRenameParams(model: monaco.editor.IReadOnlyModel, position: monaco.IPosition, newName: string): RenameParams { + asRenameParams (model: monaco.editor.IReadOnlyModel, position: monaco.IPosition, newName: string): RenameParams { return { textDocument: this.asTextDocumentIdentifier(model), position: this.asPosition(position.lineNumber, position.column), @@ -482,13 +482,13 @@ export class MonacoToProtocolConverter { }; } - asDocumentLinkParams(model: monaco.editor.IReadOnlyModel): DocumentLinkParams { + asDocumentLinkParams (model: monaco.editor.IReadOnlyModel): DocumentLinkParams { return { textDocument: this.asTextDocumentIdentifier(model) }; } - asDocumentLink(item: monaco.languages.ILink): DocumentLink { + asDocumentLink (item: monaco.languages.ILink): DocumentLink { const result = DocumentLink.create(this.asRange(item.range)); if (item.url) { result.target = typeof item.url === 'string' ? item.url : item.url.toString(); } if (ProtocolDocumentLink.is(item) && item.data) { @@ -498,7 +498,7 @@ export class MonacoToProtocolConverter { return result; } - asCodeAction(item: monaco.languages.CodeAction): CodeAction { + asCodeAction (item: monaco.languages.CodeAction): CodeAction { const result: CodeAction = { title: item.title }; const protocolCodeAction = ProtocolCodeAction.is(item) ? item : undefined; if (Is.number(item.kind)) { @@ -527,7 +527,7 @@ export class MonacoToProtocolConverter { return result; } - asInlayHintLabelPart(part: monaco.languages.InlayHintLabelPart): InlayHintLabelPart { + asInlayHintLabelPart (part: monaco.languages.InlayHintLabelPart): InlayHintLabelPart { return { value: part.label, command: this.asCommand(part.command), @@ -536,14 +536,14 @@ export class MonacoToProtocolConverter { }; } - asInlayHintLabel(label: string | monaco.languages.InlayHintLabelPart[]): string | InlayHintLabelPart[] { + asInlayHintLabel (label: string | monaco.languages.InlayHintLabelPart[]): string | InlayHintLabelPart[] { if (Array.isArray(label)) { return label.map(part => this.asInlayHintLabelPart(part)); } return label; } - asInlayHint(item: monaco.languages.InlayHint): InlayHint { + asInlayHint (item: monaco.languages.InlayHint): InlayHint { const result = InlayHint.create( this.asPosition(item.position.lineNumber, item.position.column), this.asInlayHintLabel(item.label), @@ -560,9 +560,9 @@ export class MonacoToProtocolConverter { * @deprecated use @CodinGame/monaco-vscode-api and vscode-languageclient/lib/common/protocolConverter (see browser example) */ export class ProtocolToMonacoConverter { - public constructor(protected readonly _monaco: typeof monaco) { } + public constructor (protected readonly _monaco: typeof monaco) { } - asResourceEdits(resource: monaco.Uri, edits: (TextEdit | AnnotatedTextEdit)[], asMetadata: (annotation: ls.ChangeAnnotationIdentifier | undefined) => monaco.languages.WorkspaceEditMetadata | undefined, modelVersionId?: number): monaco.languages.WorkspaceTextEdit[] { + asResourceEdits (resource: monaco.Uri, edits: (TextEdit | AnnotatedTextEdit)[], asMetadata: (annotation: ls.ChangeAnnotationIdentifier | undefined) => monaco.languages.WorkspaceEditMetadata | undefined, modelVersionId?: number): monaco.languages.WorkspaceTextEdit[] { return edits.map(edit => ({ resource, edit: this.asTextEdit(edit), @@ -571,7 +571,7 @@ export class ProtocolToMonacoConverter { })); } - asWorkspaceEditMetadata(changeAnnotation: ChangeAnnotation): monaco.languages.WorkspaceEditMetadata { + asWorkspaceEditMetadata (changeAnnotation: ChangeAnnotation): monaco.languages.WorkspaceEditMetadata { return { needsConfirmation: changeAnnotation.needsConfirmation === true, label: changeAnnotation.label, @@ -582,7 +582,7 @@ export class ProtocolToMonacoConverter { asWorkspaceEdit(item: WorkspaceEdit): monaco.languages.WorkspaceEdit; asWorkspaceEdit(item: undefined | null): undefined; asWorkspaceEdit(item: WorkspaceEdit | undefined | null): monaco.languages.WorkspaceEdit | undefined; - asWorkspaceEdit(item: WorkspaceEdit | undefined | null): monaco.languages.WorkspaceEdit | undefined { + asWorkspaceEdit (item: WorkspaceEdit | undefined | null): monaco.languages.WorkspaceEdit | undefined { if (!item) { return undefined; } @@ -644,7 +644,7 @@ export class ProtocolToMonacoConverter { asTextEdit(edit: TextEdit): monaco.languages.TextEdit; asTextEdit(edit: undefined | null): undefined; asTextEdit(edit: TextEdit | undefined | null): undefined; - asTextEdit(edit: TextEdit | undefined | null): monaco.languages.TextEdit | undefined { + asTextEdit (edit: TextEdit | undefined | null): monaco.languages.TextEdit | undefined { if (!edit) { return undefined; } @@ -658,7 +658,7 @@ export class ProtocolToMonacoConverter { asTextEdits(items: TextEdit[]): monaco.languages.TextEdit[]; asTextEdits(items: undefined | null): undefined; asTextEdits(items: TextEdit[] | undefined | null): monaco.languages.TextEdit[] | undefined; - asTextEdits(items: TextEdit[] | undefined | null): monaco.languages.TextEdit[] | undefined { + asTextEdits (items: TextEdit[] | undefined | null): monaco.languages.TextEdit[] | undefined { if (!items) { return undefined; } @@ -668,7 +668,7 @@ export class ProtocolToMonacoConverter { asCodeLens(item: CodeLens): monaco.languages.CodeLens; asCodeLens(item: undefined | null): undefined; asCodeLens(item: CodeLens | undefined | null): monaco.languages.CodeLens | undefined; - asCodeLens(item: CodeLens | undefined | null): monaco.languages.CodeLens | undefined { + asCodeLens (item: CodeLens | undefined | null): monaco.languages.CodeLens | undefined { if (!item) { return undefined; } @@ -682,7 +682,7 @@ export class ProtocolToMonacoConverter { asCodeLensList(items: CodeLens[]): monaco.languages.CodeLensList; asCodeLensList(items: undefined | null): undefined; asCodeLensList(items: CodeLens[] | undefined | null): monaco.languages.CodeLensList | undefined; - asCodeLensList(items: CodeLens[] | undefined | null): monaco.languages.CodeLensList | undefined { + asCodeLensList (items: CodeLens[] | undefined | null): monaco.languages.CodeLensList | undefined { if (!items) { return undefined; } @@ -692,14 +692,14 @@ export class ProtocolToMonacoConverter { }; } - asCodeActionList(actions: (Command | CodeAction)[]): monaco.languages.CodeActionList { + asCodeActionList (actions: (Command | CodeAction)[]): monaco.languages.CodeActionList { return { actions: actions.map(action => this.asCodeAction(action)), dispose: () => { } }; } - asCodeAction(item: Command | CodeAction): ProtocolCodeAction { + asCodeAction (item: Command | CodeAction): ProtocolCodeAction { if (Command.is(item)) { return { command: { @@ -725,7 +725,7 @@ export class ProtocolToMonacoConverter { asCommand(command: Command): monaco.languages.Command; asCommand(command: undefined): undefined; asCommand(command: Command | undefined): monaco.languages.Command | undefined; - asCommand(command: Command | undefined): monaco.languages.Command | undefined { + asCommand (command: Command | undefined): monaco.languages.Command | undefined { if (!command) { return undefined; } @@ -736,7 +736,7 @@ export class ProtocolToMonacoConverter { }; } - asDocumentSymbol(value: DocumentSymbol): monaco.languages.DocumentSymbol { + asDocumentSymbol (value: DocumentSymbol): monaco.languages.DocumentSymbol { const children = value.children && value.children.map(c => this.asDocumentSymbol(c)); return { name: value.name, @@ -749,7 +749,7 @@ export class ProtocolToMonacoConverter { }; } - asDocumentSymbols(values: SymbolInformation[] | DocumentSymbol[]): monaco.languages.DocumentSymbol[] { + asDocumentSymbols (values: SymbolInformation[] | DocumentSymbol[]): monaco.languages.DocumentSymbol[] { if (DocumentSymbol.is(values[0])) { return (values as DocumentSymbol[]).map(s => this.asDocumentSymbol(s)); } @@ -759,14 +759,14 @@ export class ProtocolToMonacoConverter { asSymbolInformations(values: SymbolInformation[], uri?: monaco.Uri): monaco.languages.DocumentSymbol[]; asSymbolInformations(values: undefined | null, uri?: monaco.Uri): undefined; asSymbolInformations(values: SymbolInformation[] | undefined | null, uri?: monaco.Uri): monaco.languages.DocumentSymbol[] | undefined; - asSymbolInformations(values: SymbolInformation[] | undefined | null, uri?: monaco.Uri): monaco.languages.DocumentSymbol[] | undefined { + asSymbolInformations (values: SymbolInformation[] | undefined | null, uri?: monaco.Uri): monaco.languages.DocumentSymbol[] | undefined { if (!values) { return undefined; } return values.map(information => this.asSymbolInformation(information, uri)); } - asSymbolInformation(item: SymbolInformation, uri?: monaco.Uri): monaco.languages.DocumentSymbol { + asSymbolInformation (item: SymbolInformation, uri?: monaco.Uri): monaco.languages.DocumentSymbol { const location = this.asLocation(uri ? { ...item.location, uri: uri.toString() } : item.location); return { name: item.name, @@ -779,7 +779,7 @@ export class ProtocolToMonacoConverter { }; } - asSymbolKind(item: SymbolKind): monaco.languages.SymbolKind { + asSymbolKind (item: SymbolKind): monaco.languages.SymbolKind { if (item <= SymbolKind.TypeParameter) { // Symbol kind is one based in the protocol and zero based in code. return item - 1; @@ -790,20 +790,20 @@ export class ProtocolToMonacoConverter { asDocumentHighlights(values: DocumentHighlight[]): monaco.languages.DocumentHighlight[]; asDocumentHighlights(values: undefined | null): undefined; asDocumentHighlights(values: DocumentHighlight[] | undefined | null): monaco.languages.DocumentHighlight[] | undefined; - asDocumentHighlights(values: DocumentHighlight[] | undefined | null): monaco.languages.DocumentHighlight[] | undefined { + asDocumentHighlights (values: DocumentHighlight[] | undefined | null): monaco.languages.DocumentHighlight[] | undefined { if (!values) { return undefined; } return values.map(item => this.asDocumentHighlight(item)); } - asDocumentHighlight(item: DocumentHighlight): monaco.languages.DocumentHighlight { + asDocumentHighlight (item: DocumentHighlight): monaco.languages.DocumentHighlight { const range = this.asRange(item.range)!; const kind = Is.number(item.kind) ? this.asDocumentHighlightKind(item.kind) : undefined!; return { range, kind }; } - asDocumentHighlightKind(item: number): monaco.languages.DocumentHighlightKind { + asDocumentHighlightKind (item: number): monaco.languages.DocumentHighlightKind { switch (item) { case DocumentHighlightKind.Text: return this._monaco.languages.DocumentHighlightKind.Text; @@ -818,7 +818,7 @@ export class ProtocolToMonacoConverter { asReferences(values: Location[]): monaco.languages.Location[]; asReferences(values: undefined | null): monaco.languages.Location[] | undefined; asReferences(values: Location[] | undefined | null): monaco.languages.Location[] | undefined; - asReferences(values: Location[] | undefined | null): monaco.languages.Location[] | undefined { + asReferences (values: Location[] | undefined | null): monaco.languages.Location[] | undefined { if (!values) { return undefined; } @@ -829,7 +829,7 @@ export class ProtocolToMonacoConverter { asDefinitionResult(item: DefinitionLink[]): monaco.languages.Definition; asDefinitionResult(item: undefined | null): undefined; asDefinitionResult(item: Definition | DefinitionLink[] | undefined | null): monaco.languages.Definition | undefined; - asDefinitionResult(item: Definition | DefinitionLink[] | undefined | null): monaco.languages.Definition | undefined { + asDefinitionResult (item: Definition | DefinitionLink[] | undefined | null): monaco.languages.Definition | undefined { if (!item) { return undefined; } @@ -851,7 +851,7 @@ export class ProtocolToMonacoConverter { asLocation(item: Location): monaco.languages.Location; asLocation(item: undefined | null): undefined; asLocation(item: Location | undefined | null): monaco.languages.Location | undefined; - asLocation(item: Location | undefined | null): monaco.languages.Location | undefined { + asLocation (item: Location | undefined | null): monaco.languages.Location | undefined { if (!item) { return undefined; } @@ -864,7 +864,7 @@ export class ProtocolToMonacoConverter { asLocationLink(item: undefined | null): undefined; asLocationLink(item: ls.LocationLink): monaco.languages.LocationLink; - asLocationLink(item: ls.LocationLink | undefined | null): monaco.languages.LocationLink | undefined { + asLocationLink (item: ls.LocationLink | undefined | null): monaco.languages.LocationLink | undefined { if (!item) { return undefined; } @@ -883,7 +883,7 @@ export class ProtocolToMonacoConverter { asSignatureHelpResult(item: undefined | null): undefined; asSignatureHelpResult(item: SignatureHelp): monaco.languages.SignatureHelpResult; asSignatureHelpResult(item: SignatureHelp | undefined | null): monaco.languages.SignatureHelpResult | undefined; - asSignatureHelpResult(item: SignatureHelp | undefined | null): monaco.languages.SignatureHelpResult | undefined { + asSignatureHelpResult (item: SignatureHelp | undefined | null): monaco.languages.SignatureHelpResult | undefined { if (!item) { return undefined; } @@ -911,11 +911,11 @@ export class ProtocolToMonacoConverter { }; } - asSignatureInformations(items: SignatureInformation[]): monaco.languages.SignatureInformation[] { + asSignatureInformations (items: SignatureInformation[]): monaco.languages.SignatureInformation[] { return items.map(item => this.asSignatureInformation(item)); } - asSignatureInformation(item: SignatureInformation): monaco.languages.SignatureInformation { + asSignatureInformation (item: SignatureInformation): monaco.languages.SignatureInformation { const result = { label: item.label }; if (item.documentation) { result.documentation = this.asDocumentation(item.documentation); } if (item.parameters) { @@ -927,11 +927,11 @@ export class ProtocolToMonacoConverter { return result; } - asParameterInformations(item: ParameterInformation[]): monaco.languages.ParameterInformation[] { + asParameterInformations (item: ParameterInformation[]): monaco.languages.ParameterInformation[] { return item.map(item => this.asParameterInformation(item)); } - asParameterInformation(item: ParameterInformation): monaco.languages.ParameterInformation { + asParameterInformation (item: ParameterInformation): monaco.languages.ParameterInformation { const result = { label: item.label }; if (item.documentation) { result.documentation = this.asDocumentation(item.documentation); } return result; @@ -940,7 +940,7 @@ export class ProtocolToMonacoConverter { asHover(hover: Hover): monaco.languages.Hover; asHover(hover: undefined | null): undefined; asHover(hover: Hover | undefined | null): monaco.languages.Hover | undefined; - asHover(hover: Hover | undefined | null): monaco.languages.Hover | undefined { + asHover (hover: Hover | undefined | null): monaco.languages.Hover | undefined { if (!hover) { return undefined; } @@ -950,14 +950,14 @@ export class ProtocolToMonacoConverter { }; } - asHoverContent(contents: MarkedString | MarkedString[] | MarkupContent): monaco.IMarkdownString[] { + asHoverContent (contents: MarkedString | MarkedString[] | MarkupContent): monaco.IMarkdownString[] { if (Array.isArray(contents)) { return contents.map(content => this.asMarkdownString(content)); } return [this.asMarkdownString(contents)]; } - asDocumentation(value: string | MarkupContent): string | monaco.IMarkdownString { + asDocumentation (value: string | MarkupContent): string | monaco.IMarkdownString { if (Is.string(value)) { return value; } @@ -967,7 +967,7 @@ export class ProtocolToMonacoConverter { return this.asMarkdownString(value); } - asMarkdownString(content: MarkedString | MarkupContent): monaco.IMarkdownString { + asMarkdownString (content: MarkedString | MarkupContent): monaco.IMarkdownString { if (MarkupContent.is(content)) { return { value: content.value @@ -982,7 +982,7 @@ export class ProtocolToMonacoConverter { }; } - asSeverity(severity?: ls.DiagnosticSeverity): monaco.MarkerSeverity { + asSeverity (severity?: ls.DiagnosticSeverity): monaco.MarkerSeverity { if (severity === 1) { return this._monaco.MarkerSeverity.Error; } @@ -998,14 +998,14 @@ export class ProtocolToMonacoConverter { asDiagnostics(diagnostics: undefined): undefined; asDiagnostics(diagnostics: Diagnostic[]): monaco.editor.IMarkerData[]; asDiagnostics(diagnostics: Diagnostic[] | undefined): monaco.editor.IMarkerData[] | undefined; - asDiagnostics(diagnostics: Diagnostic[] | undefined): monaco.editor.IMarkerData[] | undefined { + asDiagnostics (diagnostics: Diagnostic[] | undefined): monaco.editor.IMarkerData[] | undefined { if (!diagnostics) { return undefined; } return diagnostics.map(diagnostic => this.asDiagnostic(diagnostic)); } - asDiagnostic(diagnostic: Diagnostic): monaco.editor.IMarkerData { + asDiagnostic (diagnostic: Diagnostic): monaco.editor.IMarkerData { return { code: typeof diagnostic.code === 'number' ? diagnostic.code.toString() : diagnostic.code, severity: this.asSeverity(diagnostic.severity), @@ -1020,14 +1020,14 @@ export class ProtocolToMonacoConverter { }; } - asRelatedInformations(relatedInformation?: DiagnosticRelatedInformation[]): monaco.editor.IRelatedInformation[] | undefined { + asRelatedInformations (relatedInformation?: DiagnosticRelatedInformation[]): monaco.editor.IRelatedInformation[] | undefined { if (!relatedInformation) { return undefined; } return relatedInformation.map(item => this.asRelatedInformation(item)); } - asRelatedInformation(relatedInformation: DiagnosticRelatedInformation): monaco.editor.IRelatedInformation { + asRelatedInformation (relatedInformation: DiagnosticRelatedInformation): monaco.editor.IRelatedInformation { return { resource: this._monaco.Uri.parse(relatedInformation.location.uri), startLineNumber: relatedInformation.location.range.start.line + 1, @@ -1038,7 +1038,7 @@ export class ProtocolToMonacoConverter { }; } - asCompletionResult(result: CompletionItem[] | CompletionList | null | undefined, defaultMonacoRange: monaco.IRange): monaco.languages.CompletionList { + asCompletionResult (result: CompletionItem[] | CompletionList | null | undefined, defaultMonacoRange: monaco.IRange): monaco.languages.CompletionList { if (!result) { return { incomplete: false, @@ -1059,7 +1059,7 @@ export class ProtocolToMonacoConverter { }; } - asCompletionItem(item: CompletionItem, defaultMonacoRange: monaco.IRange | RangeReplace, defaultRange?: monaco.IRange | RangeReplace, itemDefaults?: CompletionList['itemDefaults']): ProtocolCompletionItem { + asCompletionItem (item: CompletionItem, defaultMonacoRange: monaco.IRange | RangeReplace, defaultRange?: monaco.IRange | RangeReplace, itemDefaults?: CompletionList['itemDefaults']): ProtocolCompletionItem { const result = { label: this.asCompletionItemLabel(item) }; if (item.detail) { result.detail = item.detail; } if (item.documentation) { @@ -1098,7 +1098,7 @@ export class ProtocolToMonacoConverter { return result; } - getCompletionItemDefaultRange(list: CompletionList): monaco.Range | RangeReplace | undefined { + getCompletionItemDefaultRange (list: CompletionList): monaco.Range | RangeReplace | undefined { const rangeDefaults = list.itemDefaults?.editRange; return ls.Range.is(rangeDefaults) ? this.asRange(rangeDefaults) @@ -1107,7 +1107,7 @@ export class ProtocolToMonacoConverter { : undefined; } - asCompletionItemLabel(item: ls.CompletionItem): monaco.languages.CompletionItemLabel | string { + asCompletionItemLabel (item: ls.CompletionItem): monaco.languages.CompletionItemLabel | string { if (ls.CompletionItemLabelDetails.is(item.labelDetails)) { return { label: item.label, @@ -1119,7 +1119,7 @@ export class ProtocolToMonacoConverter { } } - asCompletionItemKind(value: CompletionItemKind): [monaco.languages.CompletionItemKind, CompletionItemKind | undefined] { + asCompletionItemKind (value: CompletionItemKind): [monaco.languages.CompletionItemKind, CompletionItemKind | undefined] { if (CompletionItemKind.Text <= value && value <= CompletionItemKind.TypeParameter) { switch (value) { case CompletionItemKind.Text: return [this._monaco.languages.CompletionItemKind.Text, undefined]; @@ -1153,7 +1153,7 @@ export class ProtocolToMonacoConverter { return [CompletionItemKind.Text, value]; } - asCompletionInsertText(item: CompletionItem, defaultRange?: monaco.IRange | RangeReplace, defaultInsertTextFormat?: InsertTextFormat): { insertText: string, range?: monaco.IRange | RangeReplace, fromEdit: boolean, isSnippet: boolean } { + asCompletionInsertText (item: CompletionItem, defaultRange?: monaco.IRange | RangeReplace, defaultInsertTextFormat?: InsertTextFormat): { insertText: string, range?: monaco.IRange | RangeReplace, fromEdit: boolean, isSnippet: boolean } { const insertTextFormat = item.insertTextFormat ?? defaultInsertTextFormat; const isSnippet = insertTextFormat === InsertTextFormat.Snippet; @@ -1169,7 +1169,7 @@ export class ProtocolToMonacoConverter { return { insertText: item.label, range: defaultRange, fromEdit: false, isSnippet: false }; } - getCompletionRangeAndText(value: ls.TextEdit | ls.InsertReplaceEdit): [monaco.Range | RangeReplace, string] { + getCompletionRangeAndText (value: ls.TextEdit | ls.InsertReplaceEdit): [monaco.Range | RangeReplace, string] { if (ls.InsertReplaceEdit.is(value)) { return [{ insert: this.asRange(value.insert), replace: this.asRange(value.replace) }, value.newText]; } else { @@ -1177,12 +1177,12 @@ export class ProtocolToMonacoConverter { } } - asDocumentLinks(documentLinks: DocumentLink[]): monaco.languages.ILinksList { + asDocumentLinks (documentLinks: DocumentLink[]): monaco.languages.ILinksList { const links = documentLinks.map(link => this.asDocumentLink(link)); return { links }; } - asDocumentLink(documentLink: DocumentLink): ProtocolDocumentLink { + asDocumentLink (documentLink: DocumentLink): ProtocolDocumentLink { return { range: this.asRange(documentLink.range), url: documentLink.target, @@ -1199,7 +1199,7 @@ export class ProtocolToMonacoConverter { asRange(range: RecursivePartial): Partial; asRange(range: RecursivePartial | undefined): monaco.Range | Partial | undefined; asRange(range: RecursivePartial | null): monaco.Range | Partial | null; - asRange(range: RecursivePartial | undefined | null): monaco.Range | Partial | undefined | null { + asRange (range: RecursivePartial | undefined | null): monaco.Range | Partial | undefined | null { if (range === undefined) { return undefined; } @@ -1226,7 +1226,7 @@ export class ProtocolToMonacoConverter { asPosition(position: Partial): Partial; asPosition(position: Partial | undefined): monaco.Position | Partial | undefined; asPosition(position: Partial | null): monaco.Position | Partial | null; - asPosition(position: Partial | undefined | null): monaco.Position | Partial | undefined | null { + asPosition (position: Partial | undefined | null): monaco.Position | Partial | undefined | null { if (position === undefined) { return undefined; } @@ -1242,22 +1242,22 @@ export class ProtocolToMonacoConverter { return { lineNumber, column }; } - asColorInformations(items: ColorInformation[]): monaco.languages.IColorInformation[] { + asColorInformations (items: ColorInformation[]): monaco.languages.IColorInformation[] { return items.map(item => this.asColorInformation(item)); } - asColorInformation(item: ColorInformation): monaco.languages.IColorInformation { + asColorInformation (item: ColorInformation): monaco.languages.IColorInformation { return { range: this.asRange(item.range), color: item.color }; } - asColorPresentations(items: ColorPresentation[]): monaco.languages.IColorPresentation[] { + asColorPresentations (items: ColorPresentation[]): monaco.languages.IColorPresentation[] { return items.map(item => this.asColorPresentation(item)); } - asColorPresentation(item: ColorPresentation): monaco.languages.IColorPresentation { + asColorPresentation (item: ColorPresentation): monaco.languages.IColorPresentation { return { label: item.label, textEdit: this.asTextEdit(item.textEdit), @@ -1267,14 +1267,14 @@ export class ProtocolToMonacoConverter { asFoldingRanges(items: undefined | null): undefined | null; asFoldingRanges(items: FoldingRange[]): monaco.languages.FoldingRange[]; - asFoldingRanges(items: FoldingRange[] | undefined | null): monaco.languages.FoldingRange[] | undefined | null { + asFoldingRanges (items: FoldingRange[] | undefined | null): monaco.languages.FoldingRange[] | undefined | null { if (!items) { return items; } return items.map(item => this.asFoldingRange(item)); } - asFoldingRange(item: FoldingRange): monaco.languages.FoldingRange { + asFoldingRange (item: FoldingRange): monaco.languages.FoldingRange { return { start: item.startLine + 1, end: item.endLine + 1, @@ -1282,7 +1282,7 @@ export class ProtocolToMonacoConverter { }; } - asFoldingRangeKind(kind?: string): monaco.languages.FoldingRangeKind | undefined { + asFoldingRangeKind (kind?: string): monaco.languages.FoldingRangeKind | undefined { if (kind) { switch (kind) { case FoldingRangeKind.Comment: @@ -1296,14 +1296,14 @@ export class ProtocolToMonacoConverter { return undefined; } - asSemanticTokens(semanticTokens: SemanticTokens): monaco.languages.SemanticTokens { + asSemanticTokens (semanticTokens: SemanticTokens): monaco.languages.SemanticTokens { return { resultId: semanticTokens.resultId, data: Uint32Array.from(semanticTokens.data) }; } - asInlayHintLabelPart(part: InlayHintLabelPart): monaco.languages.InlayHintLabelPart { + asInlayHintLabelPart (part: InlayHintLabelPart): monaco.languages.InlayHintLabelPart { return { label: part.value, command: this.asCommand(part.command), @@ -1312,14 +1312,14 @@ export class ProtocolToMonacoConverter { }; } - asInlayHintLabel(label: string | InlayHintLabelPart[]): string | monaco.languages.InlayHintLabelPart[] { + asInlayHintLabel (label: string | InlayHintLabelPart[]): string | monaco.languages.InlayHintLabelPart[] { if (Array.isArray(label)) { return label.map(part => this.asInlayHintLabelPart(part)); } return label; } - asInlayHint(inlayHint: InlayHint): ProtocolInlayHint { + asInlayHint (inlayHint: InlayHint): ProtocolInlayHint { return { data: inlayHint.data, label: this.asInlayHintLabel(inlayHint.label), @@ -1334,7 +1334,7 @@ export class ProtocolToMonacoConverter { asInlayHintList(items: InlayHint[]): monaco.languages.InlayHintList; asInlayHintList(items: undefined | null): undefined; asInlayHintList(items: InlayHint[] | undefined | null): monaco.languages.InlayHintList | undefined; - asInlayHintList(items: InlayHint[] | undefined | null): monaco.languages.InlayHintList | undefined { + asInlayHintList (items: InlayHint[] | undefined | null): monaco.languages.InlayHintList | undefined { if (!items) { return undefined; } diff --git a/packages/client/src/monaco-language-client.ts b/packages/client/src/monaco-language-client.ts index df976515e..338cdbefb 100644 --- a/packages/client/src/monaco-language-client.ts +++ b/packages/client/src/monaco-language-client.ts @@ -48,7 +48,7 @@ export class MonacoLanguageClient extends BaseLanguageClient { protected readonly connectionProvider: IConnectionProvider; - constructor({ id, name, clientOptions, connectionProvider }: MonacoLanguageClient.Options) { + constructor ({ id, name, clientOptions, connectionProvider }: MonacoLanguageClient.Options) { super(id || name.toLowerCase(), name, clientOptions); this.connectionProvider = connectionProvider; @@ -70,15 +70,15 @@ export class MonacoLanguageClient extends BaseLanguageClient { }; } - protected createMessageTransports(encoding: string): Promise { + protected createMessageTransports (encoding: string): Promise { return this.connectionProvider.get(encoding); } - protected getLocale(): string { + protected getLocale (): string { return navigator.language || 'en-US'; } - protected override registerBuiltinFeatures() { + protected override registerBuiltinFeatures () { this.registerFeature(new DidOpenTextDocumentFeature(this, this['_syncedDocuments'])); this.registerFeature(new DidChangeTextDocumentFeature(this)); this.registerFeature(new DidCloseTextDocumentFeature(this, this['_syncedDocuments'])); @@ -114,18 +114,18 @@ export class MonacoLanguageClient extends BaseLanguageClient { this.registerFeature(new DiagnosticFeature(this)); } - public registerTextDocumentSaveFeatures() { + public registerTextDocumentSaveFeatures () { this.registerFeature(new WillSaveFeature(this)); this.registerFeature(new WillSaveWaitUntilFeature(this)); this.registerFeature(new DidSaveTextDocumentFeature(this)); } - public registerConfigurationFeatures() { + public registerConfigurationFeatures () { this.registerFeature(new ConfigurationFeature(this)); this.registerFeature(new SyncConfigurationFeature(this)); } - public registerProgressFeatures() { + public registerProgressFeatures () { this.registerFeature(new ProgressFeature(this)); } } diff --git a/packages/client/src/monaco-services.ts b/packages/client/src/monaco-services.ts index c6e760f31..71ab783ca 100644 --- a/packages/client/src/monaco-services.ts +++ b/packages/client/src/monaco-services.ts @@ -18,17 +18,17 @@ export namespace MonacoServices { rootPath?: string } export type Provider = () => MonacoServices; - export function create(options: Options = {}): MonacoServices { + export function create (options: Options = {}): MonacoServices { return { workspace: new MonacoWorkspace(options.workspaceFolders, options.rootPath), window: new ConsoleWindow() }; } - export function install(options: Options = {}): vscode.Disposable { + export function install (options: Options = {}): vscode.Disposable { const services = create(options); return Services.install(services); } - export function get(): MonacoServices { + export function get (): MonacoServices { return Services.get() as MonacoServices; } } diff --git a/packages/client/src/monaco-workspace.ts b/packages/client/src/monaco-workspace.ts index 9fc63dbcd..4dda921c2 100644 --- a/packages/client/src/monaco-workspace.ts +++ b/packages/client/src/monaco-workspace.ts @@ -6,7 +6,7 @@ import * as vscode from 'vscode'; import { Workspace } from 'vscode/services'; export class MonacoWorkspace implements Workspace { - constructor( + constructor ( public readonly workspaceFolders?: vscode.WorkspaceFolder[], public readonly rootPath?: string | undefined ) {