diff --git a/server/src/common/server.ts b/server/src/common/server.ts index 0e3babb57..660311d15 100644 --- a/server/src/common/server.ts +++ b/server/src/common/server.ts @@ -1509,10 +1509,7 @@ export function createConnection(type: string | MessageSignature, ...params: any[]): Promise => connection.sendRequest(Is.string(type) ? type : type.method, ...params), onRequest: (type: string | MessageSignature | StarRequestHandler, handler?: GenericRequestHandler): Disposable => (connection as any).onRequest(type, handler), - sendNotification: (type: string | MessageSignature, param?: any): Promise => { - const method = Is.string(type) ? type : type.method; - return connection.sendNotification(method, param); - }, + sendNotification: (type: string | MessageSignature, ...params: [any?]): Promise => connection.sendNotification(Is.string(type) ? type : type.method, ...params), onNotification: (type: string | MessageSignature | StarNotificationHandler, handler?: GenericNotificationHandler): Disposable => (connection as any).onNotification(type, handler), onProgress: connection.onProgress, diff --git a/server/src/node/test/connection.test.ts b/server/src/node/test/connection.test.ts index 03a885006..66aaac112 100644 --- a/server/src/node/test/connection.test.ts +++ b/server/src/node/test/connection.test.ts @@ -10,7 +10,7 @@ import { Duplex } from 'stream'; import { InitializeParams, InitializeRequest, InitializeResult, createConnection, DidChangeConfigurationNotification, DidChangeConfigurationParams, Connection, DeclarationRequest, DeclarationParams, ProgressToken, WorkDoneProgress, - LocationLink, WorkDoneProgressReporter + LocationLink, WorkDoneProgressReporter, NotificationType0 } from '../main'; class TestStream extends Duplex { @@ -84,6 +84,16 @@ suite('Connection Tests', () => { void clientConnection.sendNotification(DidChangeConfigurationNotification.type, param); }); + test('Ensure notification without parameters is sent without parameters', (done) => { + const type = new NotificationType0('test/notification0'); + serverConnection.onNotification(type, (...args: any[]) => { + assert.strictEqual(args.length, 0, 'No parameters are transferred'); + done(); + }); + + void clientConnection.sendNotification(type); + }); + test('Ensure work done converted', (done) => { serverConnection.onDeclaration((_params, _cancel, workDone, result) => { assert.ok(workDone !== undefined, 'Work Done token converted.');