Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('calls getTargets when request is sent', async (done) => {
expect(await client.sendRequest(new rpc.RequestType1('getTargets'), file))
.toEqual(['file://foo/bar.pdf'])
expect(cache.getTargets).toHaveBeenCalledWith(file)
done()
})
it('calls clear when request is sent', async (done) => {
await client.sendRequest(new rpc.RequestType1('clear'), file)
expect(cache.clear).toHaveBeenCalledWith(file)
done()
})
request(action: Action, token?: CancellationToken): Thenable {
token = token || CancellationToken.None;
const requestType = new RequestType1(action.kind)
return this.connection.sendRequest(requestType, action, token);
}
}
export namespace ServerAddedNotification {
export const type = new NotificationType('client/serverAdded');
}
export namespace ServerRemovedNotification {
export const type = new NotificationType('client/serverRemoved');
}
export namespace GetDiscoveryPathsRequest {
export const type = new RequestType0, void, void>('server/getDiscoveryPaths');
}
export namespace FindServerBeansRequest {
export const type = new RequestType1, void, void>('server/findServerBeans');
}
export namespace CreateServerRequest {
export const type = new RequestType1('server/createServer');
}
export namespace GetRequiredAttributesRequest {
export const type = new RequestType1('server/getRequiredAttributes');
}
export namespace GetOptionalAttributesRequest {
export const type = new RequestType1('server/getOptionalAttributes');
}
export namespace GetServerHandlersRequest {
export const type = new RequestType0, void, void>('server/getServerHandles');
private server: cp.ChildProcess
/** @internal */
private cachedBuilders: Map = new Map()
/** @internal */
private clearRequest = new rpc.RequestType1('clear')
/** @internal */
private clearAllRequest = new rpc.RequestType0('clearAll')
/** @internal */
private getTargetsRequest = new rpc.RequestType1('getTargets')
/** @internal */
private exitNotification = new rpc.NotificationType0('exit')
/** @internal */
private killRequest = new rpc.RequestType2('kill')
/** @internal */
private killAllRequest = new rpc.RequestType1('killAll')
/** @internal */
private logNotification = new rpc.NotificationType2('log')
/** @internal */
private runRequest = new rpc.RequestType2('run')
/** @internal */
private setDirectoryOptionsRequest = new rpc.RequestType3('setDirectoryOptions')
/** @internal */
private setInstanceOptionsRequest = new rpc.RequestType3('setInstanceOptions')
/** @internal */
private setProjectOptionsRequest = new rpc.RequestType3('setProjectOptions')
/** @internal */
private setUserOptionsRequest = new rpc.RequestType3('setUserOptions')
constructor (autoStart: boolean = false) {
super()
this.autoStart = autoStart
}
export namespace GetServerHandlersRequest {
export const type = new RequestType0, void, void>('server/getServerHandles');
}
export namespace DeleteServerNotification {
export const type = new NotificationType('server/deleteServer');
}
export namespace StartServerAsyncRequest {
export const type = new RequestType1('server/startServerAsync');
}
export namespace StopServerAsyncRequest {
export const type = new RequestType1('server/stopServerAsync');
}
export namespace ServerStateChangeNotification {
export const type = new NotificationType('client/serverStateChanged');
}
export namespace ServerProcessOutputAppendedNotification {
export const type = new NotificationType('client/serverProcessOutputAppended');
}
import {
BuilderCacheInterface, Command, Message, OptionsSource, Uri
} from '@dicy/core'
import * as rpc from 'vscode-jsonrpc'
export default class Server {
private cache: BuilderCacheInterface
private connection: any
private clearRequest = new rpc.RequestType1('clear')
private clearAllRequest = new rpc.RequestType0('clearAll')
private exitNotification = new rpc.NotificationType0('exit')
private getTargetsRequest = new rpc.RequestType1('getTargets')
private killRequest = new rpc.RequestType2('kill')
private killAllRequest = new rpc.RequestType1('killAll')
private logNotification = new rpc.NotificationType2('log')
private runRequest = new rpc.RequestType2('run')
private setDirectoryOptionsRequest = new rpc.RequestType3('setDirectoryOptions')
private setInstanceOptionsRequest = new rpc.RequestType3('setInstanceOptions')
private setProjectOptionsRequest = new rpc.RequestType3('setProjectOptions')
private setUserOptionsRequest = new rpc.RequestType3('setUserOptions')
constructor (transport: [rpc.MessageReader, rpc.MessageWriter], cache: BuilderCacheInterface) {
this.cache = cache
this.connection = rpc.createMessageConnection(transport[0], transport[1])
export default class Client extends EventEmitter implements BuilderCacheInterface {
/** @internal */
private autoStart: boolean
/** @internal */
private connection: any
/** @internal */
private server: cp.ChildProcess
/** @internal */
private cachedBuilders: Map = new Map()
/** @internal */
private clearRequest = new rpc.RequestType1('clear')
/** @internal */
private clearAllRequest = new rpc.RequestType0('clearAll')
/** @internal */
private getTargetsRequest = new rpc.RequestType1('getTargets')
/** @internal */
private exitNotification = new rpc.NotificationType0('exit')
/** @internal */
private killRequest = new rpc.RequestType2('kill')
/** @internal */
private killAllRequest = new rpc.RequestType1('killAll')
/** @internal */
private logNotification = new rpc.NotificationType2('log')
/** @internal */
private runRequest = new rpc.RequestType2('run')
/** @internal */
private setDirectoryOptionsRequest = new rpc.RequestType3('setDirectoryOptions')
/** @internal */
private setInstanceOptionsRequest = new rpc.RequestType3('setInstanceOptions')
/** @internal */
private setProjectOptionsRequest = new rpc.RequestType3('setProjectOptions')
return this.cache.setProjectOptions(this.file, options, merge)
}
}
export default class Client extends EventEmitter implements BuilderCacheInterface {
/** @internal */
private autoStart: boolean
/** @internal */
private connection: any
/** @internal */
private server: cp.ChildProcess
/** @internal */
private cachedBuilders: Map = new Map()
/** @internal */
private clearRequest = new rpc.RequestType1('clear')
/** @internal */
private clearAllRequest = new rpc.RequestType0('clearAll')
/** @internal */
private getTargetsRequest = new rpc.RequestType1('getTargets')
/** @internal */
private exitNotification = new rpc.NotificationType0('exit')
/** @internal */
private killRequest = new rpc.RequestType2('kill')
/** @internal */
private killAllRequest = new rpc.RequestType1('killAll')
/** @internal */
private logNotification = new rpc.NotificationType2('log')
/** @internal */
private runRequest = new rpc.RequestType2('run')
/** @internal */
private setDirectoryOptionsRequest = new rpc.RequestType3('setDirectoryOptions')
}
export namespace ServerRemovedNotification {
export const type = new NotificationType('client/serverRemoved');
}
export namespace GetDiscoveryPathsRequest {
export const type = new RequestType0, void, void>('server/getDiscoveryPaths');
}
export namespace FindServerBeansRequest {
export const type = new RequestType1, void, void>('server/findServerBeans');
}
export namespace CreateServerRequest {
export const type = new RequestType1('server/createServer');
}
export namespace GetRequiredAttributesRequest {
export const type = new RequestType1('server/getRequiredAttributes');
}
export namespace GetOptionalAttributesRequest {
export const type = new RequestType1('server/getOptionalAttributes');
}
export namespace GetServerHandlersRequest {
export const type = new RequestType0, void, void>('server/getServerHandles');
}
export namespace DeleteServerNotification {
export const type = new NotificationType('server/deleteServer');