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 clearAll when request is sent', async (done) => {
await client.sendRequest(new rpc.RequestType0('clearAll'))
expect(cache.clearAll).toHaveBeenCalledWith()
done()
})
import { RequestType, RequestType0 } from 'vscode-jsonrpc';
export interface HistoryEntryItem {
element: string;
usage: number;
}
export const HistoryEntryGetRequestType: RequestType0<
HistoryEntryItem[],
any,
any
> = new RequestType0('zenscript/getHistoryEntries');
export const HistoryEntryAddRequestType: RequestType<
string,
HistoryEntryItem[],
any,
any
> = new RequestType('zenscript/addHistoryEntry');
export interface InitializeParameters {
options?: any
}
export namespace ActionMessageNotification {
export const type = new NotificationType('process');
}
export namespace InitializeRequest {
export const type = new RequestType('initialize');
}
export namespace ShutdownRequest {
export const type = new RequestType0('shutdown');
}
export namespace ExitNotification {
export const type = new NotificationType0('exit');
}
* The associated URI for this workspace folder.
*/
uri: string;
/**
* The name of the workspace folder. Used to refer to this
* workspace folder in the user interface.
*/
name: string;
}
/**
* The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.
*/
export namespace WorkspaceFoldersRequest {
export const type = new RequestType0('workspace/workspaceFolders');
export type HandlerSignature = RequestHandler0;
export type MiddlewareSignature = (token: CancellationToken, next: HandlerSignature) => HandlerResult;
}
/**
* The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace
* folder configuration changes.
*/
export namespace DidChangeWorkspaceFoldersNotification {
export const type = new NotificationType('workspace/didChangeWorkspaceFolders');
export type HandlerSignature = NotificationHandler;
export type MiddlewareSignature = (params: DidChangeWorkspaceFoldersParams, next: HandlerSignature) => void;
}
/**
* The parameters of a `workspace/didChangeWorkspaceFolders` notification.
* is allowed to send requests from the server to the client.
*/
export namespace InitializedNotification {
export const type = new NotificationType('initialized');
}
//---- Shutdown Method ----
/**
* A shutdown request is sent from the client to the server.
* It is sent once when the client descides to shutdown the
* server. The only notification that is sent after a shudown request
* is the exit event.
*/
export namespace ShutdownRequest {
export const type = new RequestType0('shutdown');
}
//---- Exit Notification ----
/**
* The exit event is sent from the client to the server to
* ask the server to exit its process.
*/
export namespace ExitNotification {
export const type = new NotificationType0('exit');
}
//---- Configuration notification ----
/**
* The configuration change notification is sent from the client to the server
export const triggerWorkspaceCollection = new RequestType0("vrdev.server.collect.workspace")
export const triggerVroCollection = new RequestType("vrdev.server.collect.vro")
export const giveVroCollectionStatus = new RequestType0("vrdev.server.collect.vro.status")
export const giveAllActions = new RequestType0("vrdev.server.giveAllActions")
export const giveActionModules = new RequestType0("vrdev.server.giveActionModules")
export const giveActionsForModule = new RequestType(
"vrdev.server.giveActionsForModule"
)
export const giveAllConfigElements = new RequestType0(
"vrdev.server.giveAllConfigElements"
)
export const giveConfigCategories = new RequestType0(
"vrdev.server.giveConfigCategories"
)
export const giveConfigsForCategory = new RequestType(
"vrdev.server.giveConfigsForCategory"
)
export const giveEntitySource = new RequestType("vrdev.server.giveEntitySource")
(function (ShutdownRequest) {
ShutdownRequest.type = new vscode_jsonrpc_1.RequestType0('shutdown');
})(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));
//---- Exit Notification ----
public async getInterpreterInformation(): Promise {
try {
this.throwIfRPCConnectionIsDead();
type InterpreterInfoResponse = ErrorResponse & { versionInfo: PythonVersionInfo; sysPrefix: string; sysVersion: string; is64Bit: boolean };
const request = new RequestType0('get_interpreter_information');
const response = await this.sendRequestWithoutArgs(request);
const versionValue = response.versionInfo.length === 4 ? `${response.versionInfo.slice(0, 3).join('.')}-${response.versionInfo[3]}` : response.versionInfo.join('.');
return {
architecture: response.is64Bit ? Architecture.x64 : Architecture.x86,
path: this.pythonPath,
version: parsePythonVersion(versionValue),
sysVersion: response.sysVersion,
sysPrefix: response.sysPrefix
};
} catch (ex) {
traceWarning('Falling back to Python Execution Service due to failure in daemon', ex);
return this.pythonExecutionService.getInterpreterInformation();
}
}
public async getExecutablePath(): 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])
}
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')