import { ContinueRcJson, IDE, IdeInfo, IndexTag, Problem, Range, Thread, } from "./typings"; export class MessageIde implements IDE { constructor( private readonly request: (messageType: string, data: any) => Promise, ) {} getRepoName(dir: string): Promise { return this.request("getRepoName", { dir }); } getDebugLocals(threadIndex: number): Promise { return this.request("getDebugLocals", { threadIndex }); } getTopLevelCallStackSources( threadIndex: number, stackDepth: number, ): Promise { return this.request("getTopLevelCallStackSources", { threadIndex, stackDepth, }); } getAvailableThreads(): Promise { return this.request("getAvailableThreads", undefined); } getTags(artifactId: string): Promise { return this.request("getTags", artifactId); } getIdeInfo(): Promise { return this.request("getIdeInfo", undefined); } readRangeInFile(filepath: string, range: Range): Promise { return this.request("readRangeInFile", { filepath, range }); } getStats(directory: string): Promise<{ [path: string]: number }> { throw new Error("Method not implemented."); } isTelemetryEnabled(): Promise { return this.request("isTelemetryEnabled", undefined); } getUniqueId(): Promise { return this.request("getUniqueId", undefined); } getWorkspaceConfigs(): Promise { return this.request("getWorkspaceConfigs", undefined); } async getDiff() { return await this.request("getDiff", undefined); } async getTerminalContents() { return await this.request("getTerminalContents", undefined); } async listWorkspaceContents(directory?: string): Promise { return await this.request("listWorkspaceContents", undefined); } async getWorkspaceDirs(): Promise { return await this.request("getWorkspaceDirs", undefined); } async showLines( filepath: string, startLine: number, endLine: number, ): Promise { return await this.request("showLines", { filepath, startLine, endLine }); } async listFolders(): Promise { return await this.request("listFolders", undefined); } _continueDir: string | null = null; async getContinueDir(): Promise { if (this._continueDir) { return this._continueDir; } const dir = await this.request("getContinueDir", undefined); this._continueDir = dir; return dir; } async writeFile(path: string, contents: string): Promise { await this.request("writeFile", { path, contents }); } async showVirtualFile(title: string, contents: string): Promise { await this.request("showVirtualFile", { name: title, content: contents }); } async openFile(path: string): Promise { await this.request("openFile", { path }); } async runCommand(command: string): Promise { await this.request("runCommand", { command }); } async saveFile(filepath: string): Promise { await this.request("saveFile", { filepath }); } async readFile(filepath: string): Promise { return await this.request("readFile", { filepath }); } async showDiff( filepath: string, newContents: string, stepIndex: number, ): Promise { await this.request("showDiff", { filepath, newContents, stepIndex }); } getOpenFiles(): Promise { return this.request("getOpenFiles", undefined); } getPinnedFiles(): Promise { return this.request("getPinnedFiles", undefined); } getSearchResults(query: string): Promise { return this.request("getSearchResults", { query }); } getProblems(filepath?: string | undefined): Promise { return this.request("getProblems", { filepath }); } subprocess(command: string): Promise<[string, string]> { return this.request("subprocess", { command }); } async getBranch(dir: string): Promise { return this.request("getBranch", { dir }); } }