Make more things private

This commit is contained in:
Lukas Wirth 2022-10-17 15:05:20 +02:00
parent 8aaafddee8
commit d68616a140
5 changed files with 31 additions and 23 deletions

View file

@ -14,6 +14,10 @@ export interface RustAnalyzerExtensionApi {
readonly client?: lc.LanguageClient;
}
export async function deactivate() {
await setContextValue(RUST_PROJECT_CONTEXT_NAME, undefined);
}
export async function activate(
context: vscode.ExtensionContext
): Promise<RustAnalyzerExtensionApi> {
@ -56,12 +60,14 @@ export async function activate(
const ctx = new Ctx(context, workspace);
// VS Code doesn't show a notification when an extension fails to activate
// so we do it ourselves.
return await activateServer(ctx).catch((err) => {
const api = await activateServer(ctx).catch((err) => {
void vscode.window.showErrorMessage(
`Cannot activate rust-analyzer extension: ${err.message}`
);
throw err;
});
await setContextValue(RUST_PROJECT_CONTEXT_NAME, true);
return api;
}
async function activateServer(ctx: Ctx): Promise<RustAnalyzerExtensionApi> {
@ -112,8 +118,6 @@ async function initCommonContext(ctx: Ctx) {
);
ctx.pushExtCleanup(defaultOnEnter);
await setContextValue(RUST_PROJECT_CONTEXT_NAME, true);
// Commands which invokes manually via command palette, shortcut, etc.
ctx.registerCommand("reload", (_) => async () => {
void vscode.window.showInformationMessage("Reloading rust-analyzer...");