public async activate()

in src/controllers/mainController.ts [115:165]


	public async activate(): Promise<boolean> {
		// initialize the language client then register the commands
		const didInitialize = await this.initialize();
		if (didInitialize) {
			// register VS Code commands
			this.registerCommand(Constants.cmdConnect);
			this._event.on(Constants.cmdConnect, () => { this.runAndLogErrors(this.onNewConnection()); });
			this.registerCommand(Constants.cmdDisconnect);
			this._event.on(Constants.cmdDisconnect, () => { this.runAndLogErrors(this.onDisconnect()); });
			this.registerCommand(Constants.cmdRunQuery);
			this._event.on(Constants.cmdRunQuery, () => { this.onRunQuery(); });
			this.registerCommand(Constants.cmdManageConnectionProfiles);
			this._event.on(Constants.cmdRunCurrentStatement, () => { this.onRunCurrentStatement(); });
			this.registerCommand(Constants.cmdRunCurrentStatement);
			this._event.on(Constants.cmdManageConnectionProfiles, async () => { await this.onManageProfiles(); });
			this.registerCommand(Constants.cmdChooseDatabase);
			this._event.on(Constants.cmdChooseDatabase, () => { this.runAndLogErrors(this.onChooseDatabase()); });
			this.registerCommand(Constants.cmdChooseLanguageFlavor);
			this._event.on(Constants.cmdChooseLanguageFlavor, () => { this.runAndLogErrors(this.onChooseLanguageFlavor()); });
			this.registerCommand(Constants.cmdCancelQuery);
			this._event.on(Constants.cmdCancelQuery, () => { this.onCancelQuery(); });
			this.registerCommand(Constants.cmdShowGettingStarted);
			this._event.on(Constants.cmdShowGettingStarted, async () => { await this.launchGettingStartedPage(); });
			this.registerCommand(Constants.cmdNewQuery);
			this._event.on(Constants.cmdNewQuery, () => this.runAndLogErrors(this.onNewQuery()));
			this.registerCommand(Constants.cmdRebuildIntelliSenseCache);
			this._event.on(Constants.cmdRebuildIntelliSenseCache, () => { this.onRebuildIntelliSense(); });
			this.registerCommandWithArgs(Constants.cmdLoadCompletionExtension);
			this._event.on(Constants.cmdLoadCompletionExtension, (params: CompletionExtensionParams) => { this.onLoadCompletionExtension(params); });
			this.registerCommand(Constants.cmdToggleSqlCmd);
			this._event.on(Constants.cmdToggleSqlCmd, async () => { await this.onToggleSqlCmd(); });
			this.registerCommand(Constants.cmdAadRemoveAccount);
			this._event.on(Constants.cmdAadRemoveAccount, () => this.removeAadAccount(this._prompter));

			this.initializeObjectExplorer();

			this.initializeQueryHistory();

			this.sqlTasksService = new SqlTasksService(SqlToolsServerClient.instance, this._untitledSqlDocumentService);
			this.dacFxService = new DacFxService(SqlToolsServerClient.instance);
			this.schemaCompareService = new SchemaCompareService(SqlToolsServerClient.instance);
			this.azureFunctionsService = new AzureFunctionsService(SqlToolsServerClient.instance);

			// Add handlers for VS Code generated commands
			this._vscodeWrapper.onDidCloseTextDocument(async (params) => await this.onDidCloseTextDocument(params));
			this._vscodeWrapper.onDidOpenTextDocument(params => this.onDidOpenTextDocument(params));
			this._vscodeWrapper.onDidSaveTextDocument(params => this.onDidSaveTextDocument(params));
			this._vscodeWrapper.onDidChangeConfiguration(params => this.onDidChangeConfiguration(params));
			return true;
		}
	}