mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-18 00:00:03 +00:00
vscode: migrate to more type-safe assert impl
This commit is contained in:
parent
d2bf2adc27
commit
1b9ab04d4b
3 changed files with 10 additions and 8 deletions
|
@ -1,22 +1,26 @@
|
|||
import * as lc from "vscode-languageclient";
|
||||
import * as vscode from "vscode";
|
||||
import { strict as nodeAssert } from "assert";
|
||||
|
||||
let enabled: boolean = false;
|
||||
export function assert(condition: unknown, explanation: string): asserts condition {
|
||||
nodeAssert(condition, explanation);
|
||||
}
|
||||
|
||||
export const log = {
|
||||
enabled: true,
|
||||
debug(message?: any, ...optionalParams: any[]): void {
|
||||
if (!enabled) return;
|
||||
if (!log.enabled) return;
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(message, ...optionalParams);
|
||||
},
|
||||
error(message?: any, ...optionalParams: any[]): void {
|
||||
if (!enabled) return;
|
||||
if (!log.enabled) return;
|
||||
debugger;
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(message, ...optionalParams);
|
||||
},
|
||||
setEnabled(yes: boolean): void {
|
||||
enabled = yes;
|
||||
log.enabled = yes;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue