Skip to content

Commit bb85e80

Browse files
committed
Introduce registration type and cleanup deprecated result type
1 parent 0d92d1f commit bb85e80

28 files changed

+347
-394
lines changed

client-node-tests/src/integration.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ suite('Client integration', () => {
620620
assert.strictEqual(middlewareCalled, true);
621621
});
622622
test('Semantic Tokens', async () => {
623-
const provider = client.getFeature(lsclient.SemanticTokensRequest.method).getProvider(document);
623+
const provider = client.getFeature(lsclient.SemanticTokensRegistrationType.method).getProvider(document);
624624
const rangeProvider = provider?.range;
625625
isDefined(rangeProvider);
626626
const rangeResult = (await rangeProvider.provideDocumentRangeSemanticTokens(document, range, tokenSource.token)) as vscode.SemanticTokens;

client/src/common/callHierarchy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export class CallHierarchyFeature extends TextDocumentFeature<boolean | CallHier
127127
if (!id || !options) {
128128
return;
129129
}
130-
this.register(this.messages, { id: id, registerOptions: options });
130+
this.register({ id: id, registerOptions: options });
131131
}
132132

133133
protected registerLanguageProvider(options: CallHierarchyRegistrationOptions): [Disposable, CallHierarchyProvider] {

client/src/common/client.ts

+98-116
Large diffs are not rendered by default.

client/src/common/colorProvider.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class ColorProviderFeature extends TextDocumentFeature<boolean | Document
4747
if (!id || !options) {
4848
return;
4949
}
50-
this.register(this.messages, { id: id, registerOptions: options });
50+
this.register({ id: id, registerOptions: options });
5151
}
5252

5353
protected registerLanguageProvider(options: DocumentColorRegistrationOptions): [Disposable, DocumentColorProvider] {

client/src/common/declaration.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class DeclarationFeature extends TextDocumentFeature<boolean | Declaratio
4343
if (!id || !options) {
4444
return;
4545
}
46-
this.register(this.messages, { id: id, registerOptions: options });
46+
this.register({ id: id, registerOptions: options });
4747
}
4848

4949
protected registerLanguageProvider(options: DeclarationRegistrationOptions): [Disposable, DeclarationProvider] {

client/src/common/foldingRange.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class FoldingRangeFeature extends TextDocumentFeature<boolean | FoldingRa
4444
if (!id || !options) {
4545
return;
4646
}
47-
this.register(this.messages, { id: id, registerOptions: options });
47+
this.register({ id: id, registerOptions: options });
4848
}
4949

5050
protected registerLanguageProvider(options: FoldingRangeRegistrationOptions): [Disposable, FoldingRangeProvider] {

client/src/common/implementation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export class ImplementationFeature extends TextDocumentFeature<boolean | Impleme
4343
if (!id || !options) {
4444
return;
4545
}
46-
this.register(this.messages, { id: id, registerOptions: options });
46+
this.register({ id: id, registerOptions: options });
4747
}
4848

4949
protected registerLanguageProvider(options: ImplementationRegistrationOptions): [Disposable, ImplementationProvider] {

client/src/common/progressPart.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ import {
88
} from 'vscode';
99

1010
import {
11-
ProgressToken, ProgressType, NotificationHandler, NotificationType, WorkDoneProgress, WorkDoneProgressBegin, WorkDoneProgressCancelNotification, WorkDoneProgressReport
11+
ProgressToken, ProgressType, NotificationHandler, ProtocolNotificationType, WorkDoneProgress, WorkDoneProgressBegin, WorkDoneProgressCancelNotification, WorkDoneProgressReport
1212
} from 'vscode-languageserver-protocol';
1313

1414
import * as Is from './utils/is';
1515

1616
export interface ProgressContext {
1717
onProgress<P>(type: ProgressType<P>, token: string | number, handler: NotificationHandler<P>): Disposable;
18-
sendNotification<P, RO>(type: NotificationType<P, RO>, params?: P): void;
18+
sendNotification<P, RO>(type: ProtocolNotificationType<P, RO>, params?: P): void;
1919
}
2020

2121
export class ProgressPart {

client/src/common/selectionRange.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export class SelectionRangeFeature extends TextDocumentFeature<boolean | Selecti
4242
if (!id || !options) {
4343
return;
4444
}
45-
this.register(this.messages, { id: id, registerOptions: options });
45+
this.register({ id: id, registerOptions: options });
4646
}
4747

4848
protected registerLanguageProvider(options: SelectionRangeRegistrationOptions): [Disposable, SelectionRangeProvider] {

client/src/common/semanticTokens.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import * as vscode from 'vscode';
77
import { Middleware, BaseLanguageClient, TextDocumentFeature } from './client';
88
import { ClientCapabilities, ServerCapabilities, DocumentSelector, SemanticTokenTypes, SemanticTokenModifiers, SemanticTokens,
99
TokenFormat, SemanticTokensOptions, SemanticTokensRegistrationOptions, SemanticTokensParams,
10-
SemanticTokensRequest, SemanticTokensDeltaParams, SemanticTokensDeltaRequest, SemanticTokensRangeParams, SemanticTokensRangeRequest, SemanticTokensRefreshRequest
10+
SemanticTokensRequest, SemanticTokensDeltaParams, SemanticTokensDeltaRequest, SemanticTokensRangeParams, SemanticTokensRangeRequest, SemanticTokensRefreshRequest,
11+
SemanticTokensRegistrationType
1112
} from 'vscode-languageserver-protocol';
1213

1314
function ensure<T, K extends keyof T>(target: T, key: K): T[K] {
@@ -45,7 +46,7 @@ export interface SemanticTokensProviders {
4546
export class SemanticTokensFeature extends TextDocumentFeature<boolean | SemanticTokensOptions, SemanticTokensRegistrationOptions, SemanticTokensProviders> {
4647

4748
constructor(client: BaseLanguageClient) {
48-
super(client, SemanticTokensRequest.type);
49+
super(client, SemanticTokensRegistrationType.type);
4950
}
5051

5152
public fillClientCapabilities(capabilites: ClientCapabilities): void {
@@ -108,7 +109,7 @@ export class SemanticTokensFeature extends TextDocumentFeature<boolean | Semanti
108109
if (!id || !options) {
109110
return;
110111
}
111-
this.register(this.messages, { id: id, registerOptions: options });
112+
this.register({ id: id, registerOptions: options });
112113
}
113114

114115
protected registerLanguageProvider(options: SemanticTokensRegistrationOptions): [vscode.Disposable, SemanticTokensProviders] {

client/src/common/typeDefinition.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export class TypeDefinitionFeature extends TextDocumentFeature<boolean | TypeDef
4444
if (!id || !options) {
4545
return;
4646
}
47-
this.register(this.messages, { id: id, registerOptions: options });
47+
this.register({ id: id, registerOptions: options });
4848
}
4949

5050
protected registerLanguageProvider(options: TypeDefinitionRegistrationOptions): [Disposable, TypeDefinitionProvider] {

client/src/common/workspaceFolders.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { workspace, Disposable, WorkspaceFolder as VWorkspaceFolder, WorkspaceFo
99

1010
import { DynamicFeature, RegistrationData, BaseLanguageClient, NextSignature } from './client';
1111
import {
12-
ClientCapabilities, InitializeParams, MessageSignature, CancellationToken, ServerCapabilities, WorkspaceFoldersRequest, WorkspaceFolder,
13-
DidChangeWorkspaceFoldersNotification, DidChangeWorkspaceFoldersParams
12+
ClientCapabilities, InitializeParams, CancellationToken, ServerCapabilities, WorkspaceFoldersRequest, WorkspaceFolder,
13+
DidChangeWorkspaceFoldersNotification, DidChangeWorkspaceFoldersParams, RegistrationType
1414
} from 'vscode-languageserver-protocol';
1515

1616
function access<T, K extends keyof T>(target: T | undefined, key: K): T[K] | undefined {
@@ -37,7 +37,7 @@ export class WorkspaceFoldersFeature implements DynamicFeature<undefined> {
3737
constructor(private _client: BaseLanguageClient) {
3838
}
3939

40-
public get messages(): MessageSignature {
40+
public get registrationType(): RegistrationType<undefined> {
4141
return DidChangeWorkspaceFoldersNotification.type;
4242
}
4343

@@ -87,10 +87,7 @@ export class WorkspaceFoldersFeature implements DynamicFeature<undefined> {
8787
id = UUID.generateUuid();
8888
}
8989
if (id) {
90-
this.register(this.messages, {
91-
id: id,
92-
registerOptions: undefined
93-
});
90+
this.register({ id: id, registerOptions: undefined });
9491
}
9592
}
9693

@@ -118,7 +115,7 @@ export class WorkspaceFoldersFeature implements DynamicFeature<undefined> {
118115
this._client.sendNotification(DidChangeWorkspaceFoldersNotification.type, params);
119116
}
120117

121-
public register(_message: MessageSignature, data: RegistrationData<undefined>): void {
118+
public register(data: RegistrationData<undefined>): void {
122119
let id = data.id;
123120
let client = this._client;
124121
let disposable = workspace.onDidChangeWorkspaceFolders((event) => {

0 commit comments

Comments
 (0)