mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-16 23:36:13 +00:00
vscode: migrate inlay_hints to rust-analyzer-api.ts
This commit is contained in:
parent
8aea0ec511
commit
c9230b88b4
2 changed files with 16 additions and 31 deletions
|
@ -20,21 +20,21 @@ export const log = {
|
|||
}
|
||||
};
|
||||
|
||||
export async function sendRequestWithRetry<R>(
|
||||
export async function sendRequestWithRetry<TParam, TRet>(
|
||||
client: lc.LanguageClient,
|
||||
method: string,
|
||||
param: unknown,
|
||||
reqType: lc.RequestType<TParam, TRet, unknown>,
|
||||
param: TParam,
|
||||
token?: vscode.CancellationToken,
|
||||
): Promise<R> {
|
||||
): Promise<TRet> {
|
||||
for (const delay of [2, 4, 6, 8, 10, null]) {
|
||||
try {
|
||||
return await (token
|
||||
? client.sendRequest(method, param, token)
|
||||
: client.sendRequest(method, param)
|
||||
? client.sendRequest(reqType, param, token)
|
||||
: client.sendRequest(reqType, param)
|
||||
);
|
||||
} catch (error) {
|
||||
if (delay === null) {
|
||||
log.error("LSP request timed out", { method, param, error });
|
||||
log.error("LSP request timed out", { method: reqType.method, param, error });
|
||||
throw error;
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,7 @@ export async function sendRequestWithRetry<R>(
|
|||
}
|
||||
|
||||
if (error.code !== lc.ErrorCodes.ContentModified) {
|
||||
log.error("LSP request failed", { method, param, error });
|
||||
log.error("LSP request failed", { method: reqType.method, param, error });
|
||||
throw error;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue