2.04 kBTypeScriptView Raw
1import { Point, TextEditor, Range } from "atom";
2import { CancellationToken, CancellationTokenSource } from "vscode-jsonrpc";
3export declare type ReportBusyWhile = <T>(title: string, f: () => Promise<T>) => Promise<T>;
4/** Obtain the range of the word at the given editor position. Uses the non-word characters from the position's grammar scope. */
5export declare function getWordAtPosition(editor: TextEditor, position: Point): Range;
6export declare function escapeRegExp(string: string): string;
8 * For the given connection and cancellationTokens map, cancel the existing CancellationToken for that connection then
9 * create and store a new CancellationToken to be used for the current request.
10 */
11export declare function cancelAndRefreshCancellationToken<T extends object>(key: T, cancellationTokens: WeakMap<T, CancellationTokenSource>): CancellationToken;
12export declare function doWithCancellationToken<T1 extends object, T2>(key: T1, cancellationTokens: WeakMap<T1, CancellationTokenSource>, work: (token: CancellationToken) => Promise<T2>): Promise<T2>;
13export declare function assertUnreachable(_: never): never;
14export declare function promiseWithTimeout<T>(ms: number, promise: Promise<T>): Promise<T>;
15export declare const rootPathDefault: string;
16export declare const exeExtentionDefault: string;
18 * Finds an exe file in the package assuming it is placed under `rootPath/platform-arch/exe`. If the exe file did not
19 * exist, the given name is returned. For example on Windows x64, if the `exeName` is `serve-d`, it returns the absolute
20 * path to `./bin/win32-x64/exeName.exe`, and if the file did not exist, `serve-d` is returned.
21 *
22 * @param exeName Name of the exe file
23 * @param rootPath The path of the folder of the exe file. Defaults to 'join("bin", `${process.platform}-${process.arch}`)'
24 * @param exeExtention The extention of the exe file. Defaults to `process.platform === "win32" ? ".exe" : ""`
25 */
26export declare function getExePath(exeName: string, rootPath?: string, exeExtention?: string): string;