Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions server/src/common/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1509,10 +1509,7 @@ export function createConnection<PConsole = _, PTracer = _, PTelemetry = _, PCli
sendRequest: <R>(type: string | MessageSignature, ...params: any[]): Promise<R> => connection.sendRequest(Is.string(type) ? type : type.method, ...params),
onRequest: <R, E>(type: string | MessageSignature | StarRequestHandler, handler?: GenericRequestHandler<R, E>): Disposable => (connection as any).onRequest(type, handler),

sendNotification: (type: string | MessageSignature, param?: any): Promise<void> => {
const method = Is.string(type) ? type : type.method;
return connection.sendNotification(method, param);
},
sendNotification: (type: string | MessageSignature, ...params: [any?]): Promise<void> => 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,
Expand Down
12 changes: 11 additions & 1 deletion server/src/node/test/connection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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.');
Expand Down