vscode: remove logging from inlays, run fix lint issues

This commit is contained in:
Veetaha 2020-03-07 14:34:09 +02:00
parent ef52fd543f
commit 2734ffa20c

View file

@ -3,7 +3,7 @@ import * as vscode from 'vscode';
import * as ra from './rust-analyzer-api'; import * as ra from './rust-analyzer-api';
import { Ctx, Disposable } from './ctx'; import { Ctx, Disposable } from './ctx';
import { sendRequestWithRetry, isRustDocument, RustDocument, RustEditor, log } from './util'; import { sendRequestWithRetry, isRustDocument, RustDocument, RustEditor } from './util';
export function activateInlayHints(ctx: Ctx) { export function activateInlayHints(ctx: Ctx) {
@ -86,7 +86,8 @@ class HintsUpdater implements Disposable {
// Set up initial cache shape // Set up initial cache shape
ctx.visibleRustEditors.forEach(editor => self.sourceFiles.set( ctx.visibleRustEditors.forEach(editor => self.sourceFiles.set(
editor.document.uri.toString(), { editor.document.uri.toString(),
{
document: editor.document, document: editor.document,
inlaysRequest: null, inlaysRequest: null,
cachedDecorations: null cachedDecorations: null
@ -106,7 +107,6 @@ class HintsUpdater implements Disposable {
onDidChangeTextDocument({ contentChanges, document }: vscode.TextDocumentChangeEvent) { onDidChangeTextDocument({ contentChanges, document }: vscode.TextDocumentChangeEvent) {
if (contentChanges.length === 0 || !isRustDocument(document)) return; if (contentChanges.length === 0 || !isRustDocument(document)) return;
log.debug(`[inlays]: changed text doc!`);
this.syncCacheAndRenderHints(); this.syncCacheAndRenderHints();
} }
@ -126,7 +126,6 @@ class HintsUpdater implements Disposable {
} }
onDidChangeVisibleTextEditors() { onDidChangeVisibleTextEditors() {
log.debug(`[inlays]: changed visible text editors`);
const newSourceFiles = new Map<string, RustSourceFile>(); const newSourceFiles = new Map<string, RustSourceFile>();
// Rerendering all, even up-to-date editors for simplicity // Rerendering all, even up-to-date editors for simplicity
@ -184,11 +183,7 @@ class HintsUpdater implements Disposable {
return decorations; return decorations;
} }
lastReqId = 0;
private async fetchHints(file: RustSourceFile): Promise<null | ra.InlayHint[]> { private async fetchHints(file: RustSourceFile): Promise<null | ra.InlayHint[]> {
const reqId = ++this.lastReqId;
log.debug(`[inlays]: ${reqId} requesting`);
file.inlaysRequest?.cancel(); file.inlaysRequest?.cancel();
const tokenSource = new vscode.CancellationTokenSource(); const tokenSource = new vscode.CancellationTokenSource();
@ -197,18 +192,12 @@ class HintsUpdater implements Disposable {
const request = { textDocument: { uri: file.document.uri.toString() } }; const request = { textDocument: { uri: file.document.uri.toString() } };
return sendRequestWithRetry(this.ctx.client, ra.inlayHints, request, tokenSource.token) return sendRequestWithRetry(this.ctx.client, ra.inlayHints, request, tokenSource.token)
.catch(_ => { .catch(_ => null)
log.debug(`[inlays]: ${reqId} err`);
return null;
})
.finally(() => { .finally(() => {
if (file.inlaysRequest === tokenSource) { if (file.inlaysRequest === tokenSource) {
file.inlaysRequest = null; file.inlaysRequest = null;
log.debug(`[inlays]: ${reqId} got response!`);
} else {
log.debug(`[inlays]: ${reqId} cancelled!`);
} }
}) });
} }
} }
@ -227,5 +216,5 @@ interface RustSourceFile {
*/ */
cachedDecorations: null | InlaysDecorations; cachedDecorations: null | InlaysDecorations;
document: RustDocument document: RustDocument;
} }