From dfdb85d46f212e20de9df17074e84b97c4e7f95e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dirk=20B=C3=A4umer?= Date: Mon, 18 Sep 2023 16:36:57 +0200 Subject: [PATCH] Fix folding range tests (#1320) --- README.md | 8 ++++++++ client-node-tests/src/integration.test.ts | 5 +++-- client/package.json | 2 +- client/src/common/client.ts | 9 +++++---- client/src/common/features.ts | 13 ++++++++----- 5 files changed, 25 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index ba9720d69..3e982d043 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,14 @@ After cloning the repository, run `npm install` to install dependencies and `npm ## History +## 3.17.0 Protocol, 8.2.0 JSON-RPC 9.0.0 Client and 9.0.0 Server + +- added proposed refresh method for folding ranges. This changed the shape of the folding range feature since we need to expose the event emitter. The change is breaking. To get to the provider you now need to do + ```ts + client.getFeature(lsclient.FoldingRangeRequest.method).getProvider(document)?.provider; + ``` +- various [bug fixes](https://github.com/microsoft/vscode-languageserver-node/milestone/46?closed=1) + ## 3.17.4-next.0 Protocol, 8.2.0-next.0 JSON-RPC, 8.2.0-next.0 Client and 8.2.0-next.0 Server. - middleware support for general notifications and requests as well as for register and unregister capabilities. diff --git a/client-node-tests/src/integration.test.ts b/client-node-tests/src/integration.test.ts index edf90a5a2..d02406d2b 100644 --- a/client-node-tests/src/integration.test.ts +++ b/client-node-tests/src/integration.test.ts @@ -763,8 +763,9 @@ suite('Client integration', () => { }); test('Folding Ranges', async () => { - const provider = client.getFeature(lsclient.FoldingRangeRequest.method).getProvider(document); - isDefined(provider); + const providerData = client.getFeature(lsclient.FoldingRangeRequest.method).getProvider(document); + isDefined(providerData); + const provider = providerData.provider; const result = (await provider.provideFoldingRanges(document, {}, tokenSource.token)); isArray(result, vscode.FoldingRange, 1); diff --git a/client/package.json b/client/package.json index 320f9653f..bc78048ec 100644 --- a/client/package.json +++ b/client/package.json @@ -15,7 +15,7 @@ "bugs": { "url": "https://github.com/Microsoft/vscode-languageserver-node/issues" }, - "enabledApiProposals": ["formatMultipleRanges"], + "enabledApiProposals": [], "main": "./lib/node/main.js", "browser": { "./lib/node/main.js": "./lib/browser/main.js" diff --git a/client/src/common/client.ts b/client/src/common/client.ts index 47a8fc971..733d38742 100644 --- a/client/src/common/client.ts +++ b/client/src/common/client.ts @@ -9,7 +9,7 @@ import { MessageItem, WorkspaceFolder as VWorkspaceFolder, env as Env, TextDocumentShowOptions, CancellationError, CancellationTokenSource, FileCreateEvent, FileRenameEvent, FileDeleteEvent, FileWillCreateEvent, FileWillRenameEvent, FileWillDeleteEvent, CompletionItemProvider, HoverProvider, SignatureHelpProvider, DefinitionProvider, ReferenceProvider, DocumentHighlightProvider, CodeActionProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, - OnTypeFormattingEditProvider, RenameProvider, DocumentSymbolProvider, DocumentLinkProvider, DeclarationProvider, FoldingRangeProvider, ImplementationProvider, + OnTypeFormattingEditProvider, RenameProvider, DocumentSymbolProvider, DocumentLinkProvider, DeclarationProvider, ImplementationProvider, DocumentColorProvider, SelectionRangeProvider, TypeDefinitionProvider, CallHierarchyProvider, LinkedEditingRangeProvider, TypeHierarchyProvider, WorkspaceSymbolProvider, ProviderResult, TextEdit as VTextEdit, InlineCompletionItemProvider } from 'vscode'; @@ -36,7 +36,7 @@ import { TypeHierarchyPrepareRequest, InlineValueRequest, InlayHintRequest, WorkspaceSymbolRequest, TextDocumentRegistrationOptions, FileOperationRegistrationOptions, ConnectionOptions, PositionEncodingKind, DocumentDiagnosticRequest, NotebookDocumentSyncRegistrationType, NotebookDocumentSyncRegistrationOptions, ErrorCodes, MessageStrategy, DidOpenTextDocumentParams, CodeLensResolveRequest, CompletionResolveRequest, CodeActionResolveRequest, InlayHintResolveRequest, DocumentLinkResolveRequest, WorkspaceSymbolResolveRequest, - CancellationToken as ProtocolCancellationToken, InlineCompletionRequest, InlineCompletionRegistrationOptions + CancellationToken as ProtocolCancellationToken, InlineCompletionRequest, InlineCompletionRegistrationOptions, ExecuteCommandRequest, ExecuteCommandOptions } from 'vscode-languageserver-protocol'; import * as c2p from './codeConverter'; @@ -79,7 +79,7 @@ import { DocumentFormattingFeature, DocumentOnTypeFormattingFeature, DocumentRan import { RenameFeature, RenameMiddleware } from './rename'; import { DocumentLinkFeature, DocumentLinkMiddleware } from './documentLink'; import { ExecuteCommandFeature, ExecuteCommandMiddleware } from './executeCommand'; -import { FoldingRangeProviderMiddleware } from './foldingRange'; +import { FoldingRangeProviderMiddleware, FoldingRangeProviderShape } from './foldingRange'; import { DeclarationMiddleware } from './declaration'; import { SelectionRangeProviderMiddleware } from './selectionRange'; import { CallHierarchyMiddleware } from './callHierarchy'; @@ -1737,7 +1737,7 @@ export abstract class BaseLanguageClient implements FeatureClient & TextDocumentProviderFeature; getFeature(request: typeof DocumentColorRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof DeclarationRequest.method): DynamicFeature & TextDocumentProviderFeature; - getFeature(request: typeof FoldingRangeRequest.method): DynamicFeature & TextDocumentProviderFeature; + getFeature(request: typeof FoldingRangeRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof ImplementationRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof SelectionRangeRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof TypeDefinitionRequest.method): DynamicFeature & TextDocumentProviderFeature; @@ -1751,6 +1751,7 @@ export abstract class BaseLanguageClient implements FeatureClient & TextDocumentProviderFeature | undefined; getFeature(request: typeof NotebookDocumentSyncRegistrationType.method): DynamicFeature & NotebookDocumentProviderShape | undefined; getFeature(request: typeof InlineCompletionRequest.method): DynamicFeature & TextDocumentProviderFeature; + getFeature(request: typeof ExecuteCommandRequest.method): DynamicFeature; public getFeature(request: string): DynamicFeature | undefined { return this._dynamicFeatures.get(request); } diff --git a/client/src/common/features.ts b/client/src/common/features.ts index cbdd9f234..6f7417b0e 100644 --- a/client/src/common/features.ts +++ b/client/src/common/features.ts @@ -8,17 +8,17 @@ import { Disposable, CancellationToken, ProviderResult, TextEdit as VTextEdit, ReferenceProvider, DefinitionProvider, SignatureHelpProvider, HoverProvider, CompletionItemProvider, WorkspaceSymbolProvider, DocumentHighlightProvider, CodeActionProvider, DocumentFormattingEditProvider, DocumentRangeFormattingEditProvider, OnTypeFormattingEditProvider, RenameProvider, DocumentSymbolProvider, DocumentLinkProvider, DocumentColorProvider, - DeclarationProvider, FoldingRangeProvider, ImplementationProvider, SelectionRangeProvider, TypeDefinitionProvider, CallHierarchyProvider, + DeclarationProvider, ImplementationProvider, SelectionRangeProvider, TypeDefinitionProvider, CallHierarchyProvider, LinkedEditingRangeProvider, TypeHierarchyProvider, FileCreateEvent, FileRenameEvent, FileDeleteEvent, FileWillCreateEvent, FileWillRenameEvent, - FileWillDeleteEvent, CancellationError + FileWillDeleteEvent, CancellationError, InlineCompletionItemProvider } from 'vscode'; import { CallHierarchyPrepareRequest, ClientCapabilities, CodeActionRequest, CodeLensRequest, CompletionRequest, DeclarationRequest, DefinitionRequest, DidChangeTextDocumentNotification, DidCloseTextDocumentNotification, DidCreateFilesNotification, DidDeleteFilesNotification, DidOpenTextDocumentNotification, DidRenameFilesNotification, DidSaveTextDocumentNotification, DocumentColorRequest, DocumentDiagnosticRequest, DocumentFormattingRequest, DocumentHighlightRequest, - DocumentLinkRequest, DocumentOnTypeFormattingRequest, DocumentRangeFormattingRequest, DocumentSelector, DocumentSymbolRequest, FileOperationRegistrationOptions, - FoldingRangeRequest, GenericNotificationHandler, GenericRequestHandler, HoverRequest, ImplementationRequest, InitializeParams, InlayHintRequest, InlineValueRequest, + DocumentLinkRequest, DocumentOnTypeFormattingRequest, DocumentRangeFormattingRequest, DocumentSelector, DocumentSymbolRequest, ExecuteCommandOptions, ExecuteCommandRequest, FileOperationRegistrationOptions, + FoldingRangeRequest, GenericNotificationHandler, GenericRequestHandler, HoverRequest, ImplementationRequest, InitializeParams, InlayHintRequest, InlineCompletionRegistrationOptions, InlineCompletionRequest, InlineValueRequest, LinkedEditingRangeRequest, MessageSignature, NotebookDocumentSyncRegistrationOptions, NotebookDocumentSyncRegistrationType, NotificationHandler, NotificationHandler0, NotificationType, NotificationType0, ProgressType, ProtocolNotificationType, ProtocolNotificationType0, ProtocolRequestType, ProtocolRequestType0, ReferencesRequest, RegistrationType, RenameRequest, RequestHandler, RequestHandler0, RequestType, RequestType0, SelectionRangeRequest, SemanticTokensRegistrationType, ServerCapabilities, @@ -650,6 +650,7 @@ import type { InlineValueProviderShape } from './inlineValue'; import type { InlayHintsProviderShape } from './inlayHint'; import type { DiagnosticProviderShape } from './diagnostic'; import type { NotebookDocumentProviderShape } from './notebook'; +import { FoldingRangeProviderShape } from './foldingRange'; export interface FeatureClient { @@ -727,7 +728,7 @@ export interface FeatureClient { getFeature(request: typeof DocumentLinkRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof DocumentColorRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof DeclarationRequest.method): DynamicFeature & TextDocumentProviderFeature; - getFeature(request: typeof FoldingRangeRequest.method): DynamicFeature & TextDocumentProviderFeature; + getFeature(request: typeof FoldingRangeRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof ImplementationRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof SelectionRangeRequest.method): DynamicFeature & TextDocumentProviderFeature; getFeature(request: typeof TypeDefinitionRequest.method): DynamicFeature & TextDocumentProviderFeature; @@ -740,4 +741,6 @@ export interface FeatureClient { getFeature(request: typeof WorkspaceSymbolRequest.method): DynamicFeature & WorkspaceProviderFeature; getFeature(request: typeof DocumentDiagnosticRequest.method): DynamicFeature & TextDocumentProviderFeature | undefined; getFeature(request: typeof NotebookDocumentSyncRegistrationType.method): DynamicFeature & NotebookDocumentProviderShape | undefined; + getFeature(request: typeof InlineCompletionRequest.method): DynamicFeature & TextDocumentProviderFeature; + getFeature(request: typeof ExecuteCommandRequest.method): DynamicFeature; } \ No newline at end of file