aboutsummaryrefslogtreecommitdiffstats
path: root/qt-cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qt-cpp')
-rw-r--r--qt-cpp/src/extension.ts46
-rw-r--r--qt-cpp/src/kit-manager.ts7
-rw-r--r--qt-cpp/src/project.ts55
3 files changed, 64 insertions, 44 deletions
diff --git a/qt-cpp/src/extension.ts b/qt-cpp/src/extension.ts
index 3813695..ecb1a0c 100644
--- a/qt-cpp/src/extension.ts
+++ b/qt-cpp/src/extension.ts
@@ -6,7 +6,6 @@ import * as vscode from 'vscode';
import {
CoreAPI,
getCoreApi,
- QtWorkspaceType,
createLogger,
initLogger,
QtWorkspaceConfigMessage,
@@ -16,11 +15,6 @@ import {
QtAdditionalPath,
telemetry
} from 'qt-lib';
-import {
- getQtInsRoot,
- getQtPathsExe,
- getSelectedKit
-} from '@cmd/register-qt-path';
import { registerMinGWgdbCommand } from '@cmd/mingw-gdb';
import { registerResetCommand } from '@cmd/reset-qt-ext';
import { registerNatvisCommand } from '@cmd/natvis';
@@ -58,8 +52,8 @@ export async function activate(context: vscode.ExtensionContext) {
if (vscode.workspace.workspaceFolders !== undefined) {
for (const folder of vscode.workspace.workspaceFolders) {
const project = await createCppProject(folder, context);
- projectManager.addProject(project, true);
- kitManager.addProject(project, true);
+ projectManager.addProject(project);
+ kitManager.addProject(project);
}
}
@@ -89,8 +83,8 @@ export async function activate(context: vscode.ExtensionContext) {
void tryToUseCMakeFromQtTools();
await kitManager.checkForAllQtInstallations();
- await initCoreValues();
- logger.info('Core values initialized');
+ await initConfigValues();
+ logger.info('Config values initialized');
}
export function deactivate() {
@@ -102,26 +96,9 @@ export function deactivate() {
}
}
-export async function initCoreValues() {
- if (!coreAPI) {
- throw new Error('CoreAPI is not initialized');
- }
-
+export async function initConfigValues() {
for (const project of projectManager.getProjects()) {
- const folder = project.folder;
- const kit = await getSelectedKit(folder, true);
- const message = new QtWorkspaceConfigMessage(folder);
- const selectedKitPath = kit ? getQtInsRoot(kit) : undefined;
- logger.info(
- `Setting selected kit path for ${folder.uri.fsPath} to ${selectedKitPath}`
- );
- message.config.set('selectedKitPath', selectedKitPath);
- const selectedQtPaths = kit ? getQtPathsExe(kit) : undefined;
- message.config.set('selectedQtPaths', selectedQtPaths);
- message.config.set('workspaceType', QtWorkspaceType.CMakeExt);
- message.config.set('buildDir', project.buildDir ?? '');
- logger.info('Updating coreAPI with message:', message as unknown as string);
- coreAPI.update(message);
+ await project.initConfigValues();
}
}
@@ -141,14 +118,21 @@ async function processMessage(message: QtWorkspaceConfigMessage) {
}
for (const key of message.config.keys()) {
if (key === QtInsRootConfigName) {
- const value = message.get<string>(QtInsRootConfigName) ?? '';
+ const value =
+ coreAPI?.getValue<string>(
+ message.workspaceFolder,
+ QtInsRootConfigName
+ ) ?? '';
await kitManager.onQtInstallationRootChanged(value, project?.folder);
continue;
}
if (key === AdditionalQtPathsName) {
const additionalQtPaths =
- message.get<QtAdditionalPath[]>(AdditionalQtPathsName) ?? [];
+ coreAPI?.getValue<QtAdditionalPath[]>(
+ message.workspaceFolder,
+ AdditionalQtPathsName
+ ) ?? [];
await kitManager.onQtPathsChanged(additionalQtPaths, project?.folder);
continue;
}
diff --git a/qt-cpp/src/kit-manager.ts b/qt-cpp/src/kit-manager.ts
index 2a80dbe..1540781 100644
--- a/qt-cpp/src/kit-manager.ts
+++ b/qt-cpp/src/kit-manager.ts
@@ -148,11 +148,8 @@ export class KitManager {
this.globalStateManager = new GlobalStateManager(context);
}
- public addProject(project: CppProject, lazy = false) {
+ public addProject(project: CppProject) {
this.projects.add(project);
- if (!lazy) {
- void this.checkForQtInstallations(project);
- }
}
public removeProject(project: CppProject) {
@@ -190,7 +187,7 @@ export class KitManager {
// If the project parameter is undefined, it means that it is a global check
// otherwise, it is a workspace folder check
- private async checkForQtInstallations(project?: CppProject) {
+ public async checkForQtInstallations(project?: CppProject) {
const currentQtInsRoot = project
? KitManager.getWorkspaceFolderQtInsRoot(project.folder)
: getCurrentGlobalQtInstallationRoot();
diff --git a/qt-cpp/src/project.ts b/qt-cpp/src/project.ts
index 23d45fc..38e3550 100644
--- a/qt-cpp/src/project.ts
+++ b/qt-cpp/src/project.ts
@@ -6,7 +6,11 @@ import * as cmakeApi from 'vscode-cmake-tools';
import { WorkspaceStateManager } from '@/state';
import { coreAPI, kitManager } from '@/extension';
-import { createLogger, QtWorkspaceConfigMessage } from 'qt-lib';
+import {
+ createLogger,
+ QtWorkspaceConfigMessage,
+ QtWorkspaceType
+} from 'qt-lib';
import { Project, ProjectManager } from 'qt-lib';
import {
getQtInsRoot,
@@ -60,11 +64,21 @@ export class CppProject implements Project {
}
const selectedKitPath = kit ? getQtInsRoot(kit) : undefined;
const message = new QtWorkspaceConfigMessage(this.folder);
- message.config.set('selectedKitPath', selectedKitPath);
+ coreAPI?.setValue(
+ this.folder,
+ 'selectedKitPath',
+ selectedKitPath
+ );
+ message.config.add('selectedKitPath');
const selectedQtPaths = kit ? getQtPathsExe(kit) : undefined;
- message.config.set('selectedQtPaths', selectedQtPaths);
- coreAPI?.update(message);
+ coreAPI?.setValue(
+ this.folder,
+ 'selectedQtPaths',
+ selectedQtPaths
+ );
+ message.config.add('selectedQtPaths');
+ coreAPI?.notify(message);
}
}
);
@@ -79,8 +93,9 @@ export class CppProject implements Project {
);
this._buildDir = currentBuildDir;
const message = new QtWorkspaceConfigMessage(this.folder);
- message.config.set('buildDir', currentBuildDir);
- coreAPI?.update(message);
+ coreAPI?.setValue(this.folder, 'buildDir', currentBuildDir);
+ message.config.add('buildDir');
+ coreAPI?.notify(message);
}
}
);
@@ -88,7 +103,24 @@ export class CppProject implements Project {
this._disposables.push(onSelectedConfigurationChangedHandler);
}
}
-
+ async initConfigValues() {
+ if (!coreAPI) {
+ throw new Error('CoreAPI is not initialized');
+ }
+ const folder = this.folder;
+ const kit = await getSelectedKit(folder, true);
+ const message = new QtWorkspaceConfigMessage(folder);
+ const selectedKitPath = kit ? getQtInsRoot(kit) : undefined;
+ logger.info(
+ `Setting selected kit path for ${folder.uri.fsPath} to ${selectedKitPath}`
+ );
+ coreAPI.setValue(folder, 'selectedKitPath', selectedKitPath);
+ const selectedQtPaths = kit ? getQtPathsExe(kit) : undefined;
+ coreAPI.setValue(folder, 'selectedQtPaths', selectedQtPaths);
+ coreAPI.setValue(folder, 'workspaceType', QtWorkspaceType.CMakeExt);
+ coreAPI.setValue(folder, 'buildDir', this.buildDir);
+ logger.info('Updating coreAPI with message:', message as unknown as string);
+ }
public getStateManager() {
return this._stateManager;
}
@@ -112,9 +144,11 @@ export class CppProjectManager extends ProjectManager<CppProject> {
super(context, createCppProject);
this._disposables.push(
- this.onProjectAdded((project: CppProject) => {
+ this.onProjectAdded(async (project: CppProject) => {
logger.info('Adding project:', project.folder.uri.fsPath);
+ await project.initConfigValues();
kitManager.addProject(project);
+ void kitManager.checkForQtInstallations(project);
})
);
@@ -124,4 +158,9 @@ export class CppProjectManager extends ProjectManager<CppProject> {
})
);
}
+ initConfigValues() {
+ for (const project of this.getProjects()) {
+ void project.initConfigValues();
+ }
+ }
}