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 kill when request is sent', async (done) => {
await client.sendRequest(new rpc.RequestType2('kill'), file, 'die!')
expect(cache.kill).toHaveBeenCalledWith(file, 'die!')
done()
})
it('calls run when request is sent', async (done) => {
const commands: Command[] = ['load', 'build', 'save']
expect(await client.sendRequest(new rpc.RequestType2('run'), file, commands)).toBeTruthy()
expect(cache.run).toHaveBeenCalledWith(file, commands)
done()
})
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')
/** @internal */
private setUserOptionsRequest = new rpc.RequestType3('setUserOptions')
constructor (autoStart: boolean = false) {
public createRunAnalysisRequest(): rpc.RequestType2 {
return new rpc.RequestType2('runAnalysis');
}
/** @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
}
/** @internal */
async bootstrap (): Promise {
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])
this.connection.onRequest(this.clearRequest,
(file: Uri): Promise => this.cache.clear(file))
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])
this.connection.onRequest(this.clearRequest,
(file: Uri): Promise => this.cache.clear(file))
this.connection.onRequest(this.clearAllRequest,
(): Promise => this.cache.clearAll())