From 8282fa0ac9007417d579152fba3be5e476abf588 Mon Sep 17 00:00:00 2001 From: Kai Salmen Date: Fri, 4 Aug 2023 15:33:32 +0200 Subject: [PATCH] Updated to monaco-vscode-api 1.80.2. Clean-up monaco-language-client --- README.md | 3 +- package-lock.json | 10 +- packages/client/CHANGELOG.md | 4 + packages/client/README.md | 1 - packages/client/package.json | 4 +- packages/client/src/index.ts | 1 + packages/client/src/monaco-language-client.ts | 141 ++---------------- .../client/src/monaco-vscode-api-services.ts | 28 +--- .../main/src/langium/langiumClient.ts | 2 +- .../main/src/langium/statemachineClient.ts | 4 - packages/verify/pnpm/package.json | 2 +- 11 files changed, 32 insertions(+), 168 deletions(-) diff --git a/README.md b/README.md index 5c9810d4..004ae847 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,7 @@ The following table describes which version of **monaco-languageclient** and **m | monaco-languageclient | monaco-vscode-api | monaco-editor | comment | | :---- | :---- | :--- | :--- | +| 6.3.0 | 1.80.2 | 0.40.0 | Released 2023-08-0x | | 6.2.0 | 1.79.3 | 0.39.0 | Released 2023-06-16 | | 6.1.0 | 1.79.1 | 0.38.0 | Released 2023-06-12 | | 6.0.3 | 1.78.8 | 0.37.1 | Released 2023-05-31 | @@ -250,7 +251,7 @@ loader.config({ monaco }); If you use pnpm, you have to add `vscode` / `monaco-vscode-api` as direct dependency (see the [following table](#monaco-editor--monaco-vscode-api-compatibility-table)), otherwise the installation will fail. ```json -"vscode": "npm:@codingame/monaco-vscode-api@~1.80.0" +"vscode": "npm:@codingame/monaco-vscode-api@~1.80.2" ``` ## Licenses diff --git a/package-lock.json b/package-lock.json index 9948092d..5583b485 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5924,9 +5924,9 @@ }, "node_modules/vscode": { "name": "@codingame/monaco-vscode-api", - "version": "1.80.1-next.0", - "resolved": "https://registry.npmjs.org/@codingame/monaco-vscode-api/-/monaco-vscode-api-1.80.1-next.0.tgz", - "integrity": "sha512-6RukMMKKidOs6oUWCEOUufnH+k5qgBfsZQgb1aHyZtOg9L+1fK55pdqUrb6PSVZbgh7sB02Zvgy1K3+sdfHvAg==", + "version": "1.80.2", + "resolved": "https://registry.npmjs.org/@codingame/monaco-vscode-api/-/monaco-vscode-api-1.80.2.tgz", + "integrity": "sha512-B8vo78YAhnJNnlXIataVvUiv5ANoKk6foLLeJGmx+rSWx3Qk9MKiGYWJGF+L6UdgwFCRP824yY9Cedu0wEaXmw==", "dependencies": { "toposort": "^2.0.2" }, @@ -6436,7 +6436,7 @@ "license": "MIT", "dependencies": { "monaco-editor": "~0.40.0", - "vscode": "npm:@codingame/monaco-vscode-api@1.80.1-next.0", + "vscode": "npm:@codingame/monaco-vscode-api@1.80.2", "vscode-jsonrpc": "~8.1.0", "vscode-languageclient": "~8.1.0" }, @@ -6446,7 +6446,7 @@ }, "peerDependencies": { "monaco-editor": "~0.40.0", - "vscode": "npm:@codingame/monaco-vscode-api@1.80.1-next.0" + "vscode": "npm:@codingame/monaco-vscode-api@1.80.2" }, "peerDependenciesMeta": { "monaco-editor": { diff --git a/packages/client/CHANGELOG.md b/packages/client/CHANGELOG.md index fe0ddeae..900e787b 100644 --- a/packages/client/CHANGELOG.md +++ b/packages/client/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this npm module are documented in this file. +## [6.3.0] - 2023-08-0x + +- Update to `monaco-editor` `0.40.0` and `monaco-vscode-api` `1.80.2` [#513](https://github.com/TypeFox/monaco-languageclient/pull/513) + ## [6.2.0] - 2023-06-16 - Updated `monaco-vscode-api` to version `1.79.3`, `monaco-editor` to version `0.39.0` and `monaco-editor-workers` to version `0.39.1` [#503](https://github.com/TypeFox/monaco-languageclient/pull/503) diff --git a/packages/client/README.md b/packages/client/README.md index 892ca950..b0bdf3db 100644 --- a/packages/client/README.md +++ b/packages/client/README.md @@ -12,7 +12,6 @@ See [here](https://github.com/TypeFox/monaco-languageclient/blob/main/README.md) ## History - For the history please see the [README](https://github.com/TypeFox/monaco-languageclient/blob/main/README.md#latest-important-project-changes) and [CHANGELOG](https://github.com/TypeFox/monaco-languageclient/blob/main/CHANGELOG.md). ## License diff --git a/packages/client/package.json b/packages/client/package.json index a0991029..bacb84d3 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -49,13 +49,13 @@ ], "dependencies": { "monaco-editor": "~0.40.0", - "vscode": "npm:@codingame/monaco-vscode-api@1.80.1-next.0", + "vscode": "npm:@codingame/monaco-vscode-api@1.80.2", "vscode-jsonrpc": "~8.1.0", "vscode-languageclient": "~8.1.0" }, "peerDependencies": { "monaco-editor": "~0.40.0", - "vscode": "npm:@codingame/monaco-vscode-api@1.80.1-next.0" + "vscode": "npm:@codingame/monaco-vscode-api@1.80.2" }, "peerDependenciesMeta": { "monaco-editor": { diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts index e1ec9371..4e25d561 100644 --- a/packages/client/src/index.ts +++ b/packages/client/src/index.ts @@ -3,5 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ +export type { IConnectionProvider, MonacoLanguageClientOptions } from './monaco-language-client.js'; export * from './monaco-language-client.js'; export * from './monaco-vscode-api-services.js'; diff --git a/packages/client/src/monaco-language-client.ts b/packages/client/src/monaco-language-client.ts index 7698d7cd..14e61a35 100644 --- a/packages/client/src/monaco-language-client.ts +++ b/packages/client/src/monaco-language-client.ts @@ -3,72 +3,25 @@ * Licensed under the MIT License. See License.txt in the project root for license information. * ------------------------------------------------------------------------------------------ */ -/* eslint-disable @typescript-eslint/dot-notation */ - import { BaseLanguageClient, MessageTransports, LanguageClientOptions } from 'vscode-languageclient/lib/common/client.js'; -import { ConfigurationFeature, SyncConfigurationFeature } from 'vscode-languageclient/lib/common/configuration.js'; -import { DidChangeTextDocumentFeature, DidCloseTextDocumentFeature, DidOpenTextDocumentFeature, DidSaveTextDocumentFeature, WillSaveFeature, WillSaveWaitUntilFeature } from 'vscode-languageclient/lib/common/textSynchronization.js'; -import { CompletionItemFeature } from 'vscode-languageclient/lib/common/completion.js'; -import { HoverFeature } from 'vscode-languageclient/lib/common/hover.js'; -import { SignatureHelpFeature } from 'vscode-languageclient/lib/common/signatureHelp.js'; -import { DefinitionFeature } from 'vscode-languageclient/lib/common/definition.js'; -import { ReferencesFeature } from 'vscode-languageclient/lib/common/reference.js'; -import { DocumentHighlightFeature } from 'vscode-languageclient/lib/common/documentHighlight.js'; -import { DocumentSymbolFeature } from 'vscode-languageclient/lib/common/documentSymbol.js'; -import { CodeActionFeature } from 'vscode-languageclient/lib/common/codeAction.js'; -import { CodeLensFeature } from 'vscode-languageclient/lib/common/codeLens.js'; -import { DocumentFormattingFeature, DocumentOnTypeFormattingFeature, DocumentRangeFormattingFeature } from 'vscode-languageclient/lib/common/formatting.js'; -import { RenameFeature } from 'vscode-languageclient/lib/common/rename.js'; -import { DocumentLinkFeature } from 'vscode-languageclient/lib/common/documentLink.js'; -import { ExecuteCommandFeature } from 'vscode-languageclient/lib/common/executeCommand.js'; -import { TypeDefinitionFeature } from 'vscode-languageclient/lib/common/typeDefinition.js'; -import { ImplementationFeature } from 'vscode-languageclient/lib/common/implementation.js'; -import { ColorProviderFeature } from 'vscode-languageclient/lib/common/colorProvider.js'; -import { WorkspaceFoldersFeature } from 'vscode-languageclient/lib/common/workspaceFolder.js'; -import { FoldingRangeFeature } from 'vscode-languageclient/lib/common/foldingRange.js'; -import { DeclarationFeature } from 'vscode-languageclient/lib/common/declaration.js'; -import { SelectionRangeFeature } from 'vscode-languageclient/lib/common/selectionRange.js'; -import { SemanticTokensFeature } from 'vscode-languageclient/lib/common/semanticTokens.js'; -import { LinkedEditingFeature } from 'vscode-languageclient/lib/common/linkedEditingRange.js'; -import { InlayHintsFeature } from 'vscode-languageclient/lib/common/inlayHint.js'; -import { DiagnosticFeature } from 'vscode-languageclient/lib/common/diagnostic.js'; -import { ProgressFeature } from 'vscode-languageclient/lib/common/progress.js'; -import { RegistrationParams, UnregistrationParams } from 'vscode-languageclient'; -import { TextDocument } from 'vscode'; -import { WorkspaceSymbolFeature } from 'vscode-languageclient/lib/common/workspaceSymbol.js'; -import { CallHierarchyFeature } from 'vscode-languageclient/lib/common/callHierarchy.js'; -import { DidCreateFilesFeature, DidDeleteFilesFeature, DidRenameFilesFeature, WillCreateFilesFeature, WillDeleteFilesFeature, WillRenameFilesFeature } from 'vscode-languageclient/lib/common/fileOperations.js'; -import { TypeHierarchyFeature } from 'vscode-languageclient/lib/common/typeHierarchy.js'; -import { InlineValueFeature } from 'vscode-languageclient/lib/common/inlineValue.js'; -import { NotebookDocumentSyncFeature } from 'vscode-languageclient/lib/common/notebook.js'; export interface IConnectionProvider { get(encoding: string): Promise; } +export type MonacoLanguageClientOptions = { + name: string; + id?: string; + clientOptions: LanguageClientOptions; + connectionProvider: IConnectionProvider; +} + export class MonacoLanguageClient extends BaseLanguageClient { protected readonly connectionProvider: IConnectionProvider; - constructor({ id, name, clientOptions, connectionProvider }: MonacoLanguageClient.Options) { + constructor({ id, name, clientOptions, connectionProvider }: MonacoLanguageClientOptions) { super(id || name.toLowerCase(), name, clientOptions); this.connectionProvider = connectionProvider; - - // Hack because vscode-language client rejects the whole registration block if one capability registration has no associated client feature registered - // Some language servers still send the registration even though the client says it doesn't support it - const originalHandleRegistrationRequest: (params: RegistrationParams) => Promise = this['handleRegistrationRequest'].bind(this); - this['handleRegistrationRequest'] = (params: RegistrationParams) => { - originalHandleRegistrationRequest({ - ...params, - registrations: params.registrations.filter(registration => this.getFeature(registration.method) != null) - }); - }; - const originalHandleUnregistrationRequest: (params: UnregistrationParams) => Promise = this['handleUnregistrationRequest'].bind(this); - this['handleUnregistrationRequest'] = (params: UnregistrationParams) => { - originalHandleUnregistrationRequest({ - ...params, - unregisterations: params.unregisterations.filter(unregistration => this.getFeature(unregistration.method) != null) - }); - }; } protected createMessageTransports(encoding: string): Promise { @@ -76,82 +29,6 @@ export class MonacoLanguageClient extends BaseLanguageClient { } protected override getLocale(): string { - return navigator.language || 'en-US'; - } - - protected override registerBuiltinFeatures() { - const pendingFullTextDocumentChanges: Map = new Map(); - this.registerFeature(new ConfigurationFeature(this)); - this.registerFeature(new DidOpenTextDocumentFeature(this, this['_syncedDocuments'])); - this['_didChangeTextDocumentFeature'] = new DidChangeTextDocumentFeature(this, pendingFullTextDocumentChanges); - this['_didChangeTextDocumentFeature'].onPendingChangeAdded(() => { - this['triggerPendingChangeDelivery'](); - }); - this.registerFeature(this['_didChangeTextDocumentFeature']); - this.registerFeature(new DidCloseTextDocumentFeature(this, this['_syncedDocuments'], pendingFullTextDocumentChanges)); - this.registerFeature(new CompletionItemFeature(this)); - this.registerFeature(new HoverFeature(this)); - this.registerFeature(new SignatureHelpFeature(this)); - this.registerFeature(new DefinitionFeature(this)); - this.registerFeature(new ReferencesFeature(this)); - this.registerFeature(new DocumentHighlightFeature(this)); - this.registerFeature(new DocumentSymbolFeature(this)); - this.registerFeature(new CodeActionFeature(this)); - this.registerFeature(new CodeLensFeature(this)); - this.registerFeature(new DocumentFormattingFeature(this)); - this.registerFeature(new DocumentRangeFormattingFeature(this)); - this.registerFeature(new DocumentOnTypeFormattingFeature(this)); - this.registerFeature(new RenameFeature(this)); - this.registerFeature(new DocumentLinkFeature(this)); - this.registerFeature(new ExecuteCommandFeature(this)); - this.registerFeature(new SyncConfigurationFeature(this)); - this.registerFeature(new TypeDefinitionFeature(this)); - this.registerFeature(new ImplementationFeature(this)); - this.registerFeature(new ColorProviderFeature(this)); - // We only register the workspace folder feature if the client is not locked - // to a specific workspace folder. - if (this.clientOptions.workspaceFolder === undefined) { - this.registerFeature(new WorkspaceFoldersFeature(this)); - } - this.registerFeature(new FoldingRangeFeature(this)); - this.registerFeature(new DeclarationFeature(this)); - this.registerFeature(new SelectionRangeFeature(this)); - this.registerFeature(new SemanticTokensFeature(this)); - this.registerFeature(new LinkedEditingFeature(this)); - this.registerFeature(new InlayHintsFeature(this)); - this.registerFeature(new DiagnosticFeature(this)); - // enabled since monaco-vscode-api 1.78.5 (PR https://github.com/CodinGame/monaco-vscode-api/pull/109) - this.registerFeature(new WillSaveFeature(this)); - this.registerFeature(new WillSaveWaitUntilFeature(this)); - this.registerFeature(new DidSaveTextDocumentFeature(this)); - // enabled since monaco-vscode-api 1.79.0 (PR https://github.com/CodinGame/monaco-vscode-api/pull/110) - this.registerFeature(new WorkspaceSymbolFeature(this)); - this.registerFeature(new DidCreateFilesFeature(this)); - this.registerFeature(new DidRenameFilesFeature(this)); - this.registerFeature(new DidDeleteFilesFeature(this)); - this.registerFeature(new WillCreateFilesFeature(this)); - this.registerFeature(new WillRenameFilesFeature(this)); - this.registerFeature(new WillDeleteFilesFeature(this)); - this.registerFeature(new CallHierarchyFeature(this)); - this.registerFeature(new TypeHierarchyFeature(this)); - this.registerFeature(new InlineValueFeature(this)); - } - - /** - * These are all contained in BaseLanguageClient#registerBuiltinFeatures but not registered - * in MonacoLanguageClient. This method is not called! - */ - public registerNotUsedFeatures() { - // these will stay unsupported for now - this.registerFeature(new ProgressFeature(this)); - this.registerFeature(new NotebookDocumentSyncFeature(this)); - } -} -export namespace MonacoLanguageClient { - export interface Options { - name: string; - id?: string; - clientOptions: LanguageClientOptions; - connectionProvider: IConnectionProvider; + return super.getLocale() || 'en-US'; } } diff --git a/packages/client/src/monaco-vscode-api-services.ts b/packages/client/src/monaco-vscode-api-services.ts index 0d1d74dd..f1a05fb0 100644 --- a/packages/client/src/monaco-vscode-api-services.ts +++ b/packages/client/src/monaco-vscode-api-services.ts @@ -14,8 +14,6 @@ interface MonacoEnvironmentEnhanced extends Environment { } export type InitializeServiceConfig = { - enableFilesService?: boolean; - enableExtensionsService?: boolean; enableDialogService?: boolean; enableNotificationService?: boolean; enableModelService?: boolean; @@ -43,8 +41,6 @@ export type InitializeServiceConfig = { enableSearchService?: boolean; enableMarkersService?: boolean; enableAccessibilityService?: boolean; - enableEnvironmentService?: boolean; - enableLayoutService?: boolean; enableLanguageDetectionWorkerService?: boolean; userServices?: editor.IEditorOverrideServices; debugLogging?: boolean; @@ -75,11 +71,14 @@ export const initServices = async (config?: InitializeServiceConfig) => { (window.MonacoEnvironment as MonacoEnvironmentEnhanced).vscodeApiInitialised = true; }; -type ModuleWithDefaultExport = { +export type ModuleWithDefaultExport = { default: (x?: any) => editor.IEditorOverrideServices } -const importAllServices = async (config?: InitializeServiceConfig) => { +/** + * files, extension, environment and layout services are loaded automatically by monaco-vscode-api + */ +export const importAllServices = async (config?: InitializeServiceConfig) => { const serviceNames: string[] = []; const promises: Promise[] = []; const lc: InitializeServiceConfig = config ?? {}; @@ -90,12 +89,6 @@ const importAllServices = async (config?: InitializeServiceConfig) => { promises.push(promise); }; - if (lc.enableFilesService === true) { - addService('files', import('vscode/service-override/files')); - } - if (lc.enableExtensionsService === true) { - addService('extensions', import('vscode/service-override/extensions')); - } if (lc.enableModelService === true) { addService('model', import('vscode/service-override/model')); } @@ -157,12 +150,6 @@ const importAllServices = async (config?: InitializeServiceConfig) => { if (lc.enableAccessibilityService === true) { addService('accessibility', import('vscode/service-override/accessibility')); } - if (lc.enableEnvironmentService === true) { - addService('environment', import('vscode/service-override/environment')); - } - if (lc.enableLayoutService === true) { - addService('layout', import('vscode/service-override/layout')); - } if (lc.enableLanguageDetectionWorkerService === true) { addService('languageDetectionWorker', import('vscode/service-override/languageDetectionWorker')); } @@ -193,8 +180,6 @@ const importAllServices = async (config?: InitializeServiceConfig) => { reportServiceLoading(userServices, lc.debugLogging === true, 'user'); } - // files service and extension service are loaded automatically by monaco-vscode-api - // theme requires textmate if ((serviceNames.includes('theme') || Object.keys(overrideServices).includes('themeService')) && !(serviceNames.includes('textmate') || Object.keys(overrideServices).includes('textMateTokenizationFeature'))) { @@ -240,7 +225,7 @@ const importAllServices = async (config?: InitializeServiceConfig) => { services = loadedImport.default(lc.configureTerminalServiceConfig.backendImpl); } } else if (serviceName === 'quickaccess') { - if (lc.configureEditorOrViewsServiceConfig?.enableViewsService) { + if (lc.configureEditorOrViewsServiceConfig?.enableViewsService === true) { const { isEditorPartVisible } = await import('vscode/service-override/views'); @@ -248,6 +233,7 @@ const importAllServices = async (config?: InitializeServiceConfig) => { isKeybindingConfigurationVisible: isEditorPartVisible, shouldUseGlobalPicker: isEditorPartVisible }); + services = loadedImport.default(); } else { services = loadedImport.default(); } diff --git a/packages/examples/main/src/langium/langiumClient.ts b/packages/examples/main/src/langium/langiumClient.ts index d7917c60..e5a8985d 100644 --- a/packages/examples/main/src/langium/langiumClient.ts +++ b/packages/examples/main/src/langium/langiumClient.ts @@ -116,7 +116,6 @@ const run = async () => { try { await initServices({ - enableFilesService: true, enableThemeService: true, enableTextmateService: true, enableModelService: true, @@ -129,6 +128,7 @@ try { }, enableKeybindingsService: true, enableLanguagesService: true, + enableQuickaccessService: true, debugLogging: true }); await setup(); diff --git a/packages/examples/main/src/langium/statemachineClient.ts b/packages/examples/main/src/langium/statemachineClient.ts index 389afe0b..e0a995f9 100644 --- a/packages/examples/main/src/langium/statemachineClient.ts +++ b/packages/examples/main/src/langium/statemachineClient.ts @@ -137,10 +137,6 @@ try { enableQuickaccessService: true, enableOutputService: true, enableSearchService: true, - enableMarkersService: false, - // don't enable files and extensions services. They will be enabled automatically - enableFilesService: false, - enableExtensionsService: false, enableLanguageDetectionWorkerService: true, // This should demonstrate that you can chose to not use the built-in loading mechanism, // but do it manually, see below diff --git a/packages/verify/pnpm/package.json b/packages/verify/pnpm/package.json index e53bf92d..b382ac88 100644 --- a/packages/verify/pnpm/package.json +++ b/packages/verify/pnpm/package.json @@ -5,7 +5,7 @@ "dependencies": { "monaco-languageclient": "6.3.0-next.1", "monaco-editor": "~0.40.0", - "vscode": "npm:@codingame/monaco-vscode-api@~1.80.1-next.0" + "vscode": "npm:@codingame/monaco-vscode-api@~1.80.2" }, "devDependencies": { "shx": "~0.3.4"