mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
internal: use vscode.FileSystem API in main.ts
This commit is contained in:
parent
2022cfce44
commit
3ca7f61a8d
2 changed files with 5 additions and 5 deletions
|
@ -31,10 +31,10 @@ export class Config {
|
||||||
enableProposedApi: boolean | undefined;
|
enableProposedApi: boolean | undefined;
|
||||||
} = vscode.extensions.getExtension(this.extensionId)!.packageJSON;
|
} = vscode.extensions.getExtension(this.extensionId)!.packageJSON;
|
||||||
|
|
||||||
readonly globalStoragePath: string;
|
readonly globalStorageUri: vscode.Uri;
|
||||||
|
|
||||||
constructor(ctx: vscode.ExtensionContext) {
|
constructor(ctx: vscode.ExtensionContext) {
|
||||||
this.globalStoragePath = ctx.globalStorageUri.fsPath;
|
this.globalStorageUri = ctx.globalStorageUri;
|
||||||
vscode.workspace.onDidChangeConfiguration(this.onDidChangeConfiguration, this, ctx.subscriptions);
|
vscode.workspace.onDidChangeConfiguration(this.onDidChangeConfiguration, this, ctx.subscriptions);
|
||||||
this.refreshLogging();
|
this.refreshLogging();
|
||||||
}
|
}
|
||||||
|
|
|
@ -160,7 +160,7 @@ export async function deactivate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function bootstrap(config: Config, state: PersistentState): Promise<string> {
|
async function bootstrap(config: Config, state: PersistentState): Promise<string> {
|
||||||
await fs.mkdir(config.globalStoragePath, { recursive: true });
|
await vscode.workspace.fs.createDirectory(config.globalStorageUri);
|
||||||
|
|
||||||
if (!config.currentExtensionIsNightly) {
|
if (!config.currentExtensionIsNightly) {
|
||||||
await state.updateNightlyReleaseId(undefined);
|
await state.updateNightlyReleaseId(undefined);
|
||||||
|
@ -222,7 +222,7 @@ async function bootstrapExtension(config: Config, state: PersistentState): Promi
|
||||||
const artifact = latestNightlyRelease.assets.find(artifact => artifact.name === "rust-analyzer.vsix");
|
const artifact = latestNightlyRelease.assets.find(artifact => artifact.name === "rust-analyzer.vsix");
|
||||||
assert(!!artifact, `Bad release: ${JSON.stringify(latestNightlyRelease)}`);
|
assert(!!artifact, `Bad release: ${JSON.stringify(latestNightlyRelease)}`);
|
||||||
|
|
||||||
const dest = path.join(config.globalStoragePath, "rust-analyzer.vsix");
|
const dest = path.join(config.globalStorageUri.path, "rust-analyzer.vsix");
|
||||||
|
|
||||||
await downloadWithRetryDialog(state, async () => {
|
await downloadWithRetryDialog(state, async () => {
|
||||||
await download({
|
await download({
|
||||||
|
@ -334,7 +334,7 @@ async function getServer(config: Config, state: PersistentState): Promise<string
|
||||||
platform = "x86_64-unknown-linux-musl";
|
platform = "x86_64-unknown-linux-musl";
|
||||||
}
|
}
|
||||||
const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : "";
|
const ext = platform.indexOf("-windows-") !== -1 ? ".exe" : "";
|
||||||
const dest = path.join(config.globalStoragePath, `rust-analyzer-${platform}${ext}`);
|
const dest = path.join(config.globalStorageUri.path, `rust-analyzer-${platform}${ext}`);
|
||||||
const exists = await fs.stat(dest).then(() => true, () => false);
|
const exists = await fs.stat(dest).then(() => true, () => false);
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
await state.updateServerVersion(undefined);
|
await state.updateServerVersion(undefined);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue