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 setUserOptions when request is sent', async (done) => {
const options: OptionsSource = { foo: 'bar' }
await client.sendRequest(new rpc.RequestType3('setUserOptions'), file, options, true)
expect(cache.setUserOptions).toHaveBeenCalledWith(file, options, true)
done()
})
it('calls setInstanceOptions when request is sent', async (done) => {
const options: OptionsSource = { foo: 'bar' }
await client.sendRequest(new rpc.RequestType3('setInstanceOptions'), file, options, true)
expect(cache.setInstanceOptions).toHaveBeenCalledWith(file, options, true)
done()
})
it('calls setProjectOptions when request is sent', async (done) => {
const options: OptionsSource = { foo: 'bar' }
await client.sendRequest(new rpc.RequestType3('setProjectOptions'), file, options, true)
expect(cache.setProjectOptions).toHaveBeenCalledWith(file, options, true)
done()
})
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())
this.connection.onNotification(this.exitNotification,
(): void => this.exit())
it('calls setDirectoryOptions when request is sent', async (done) => {
const options: OptionsSource = { foo: 'bar' }
await client.sendRequest(new rpc.RequestType3('setDirectoryOptions'), file, options, true)
expect(cache.setDirectoryOptions).toHaveBeenCalledWith(file, options, true)
done()
})
/** @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 {
if (this.autoStart && !this.server) await this.start()
}
createTransport (): [rpc.MessageReader, rpc.MessageWriter] {
const serverPath = require.resolve('@dicy/server')
/** @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 {
if (this.autoStart && !this.server) await this.start()
}
} 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())
this.connection.onNotification(this.exitNotification,
/** @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 {
if (this.autoStart && !this.server) await this.start()
}
createTransport (): [rpc.MessageReader, rpc.MessageWriter] {
/** @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 {
if (this.autoStart && !this.server) await this.start()
}
createTransport (): [rpc.MessageReader, rpc.MessageWriter] {
const serverPath = require.resolve('@dicy/server')
this.server = cp.fork(serverPath, ['--node-ipc'])