Skip to content

Commit

Permalink
Enhance logging for coreAPI notifications and config initialization
Browse files Browse the repository at this point in the history
* Improve logging for coreAPI notifications
* Introduce `toString()` method for `QtWorkspaceConfigMessage`

Change-Id: I7e82196ca641a93ea2a960230203fe21a38c8b4e
Reviewed-by: Marcus Tillmanns <[email protected]>
  • Loading branch information
OrkunTokdemir committed Dec 13, 2024
1 parent f7fa5e7 commit 4acc9e6
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions qt-core/src/installation-root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ export function onQtInsRootUpdated(
const message = new QtWorkspaceConfigMessage(folder);
coreAPI?.setValue(folder, QtInsRootConfigName, newQtInstallationRoot);
message.config.add(QtInsRootConfigName);
logger.info(`Notifying coreAPI with message: ${message.toString()}`);
coreAPI?.notify(message);
}

Expand All @@ -219,5 +220,6 @@ export function onAdditionalQtPathsUpdated(
const message = new QtWorkspaceConfigMessage(folder);
coreAPI?.setValue(folder, AdditionalQtPathsName, newPaths);
message.config.add(AdditionalQtPathsName);
logger.info(`Notifying coreAPI with message: ${message.toString()}`);
coreAPI?.notify(message);
}
1 change: 1 addition & 0 deletions qt-core/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export class CoreProject implements Project {
logger.info(
`Setting additional Qt paths for ${folder.uri.fsPath} to: ${additionalQtPaths.join(', ')}`
);
logger.info('Config values initialized for:', folder.uri.fsPath);
}

dispose() {
Expand Down
18 changes: 16 additions & 2 deletions qt-cpp/src/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ export class CppProject implements Project {
selectedQtPaths
);
message.config.add('selectedQtPaths');
logger.info(
`Notifying coreAPI with message: ${message.toString()}`
);
coreAPI?.notify(message);
}
}
Expand All @@ -95,6 +98,9 @@ export class CppProject implements Project {
const message = new QtWorkspaceConfigMessage(this.folder);
coreAPI?.setValue(this.folder, 'buildDir', currentBuildDir);
message.config.add('buildDir');
logger.info(
`Notifying coreAPI with message: ${message.toString()}`
);
coreAPI?.notify(message);
}
}
Expand All @@ -109,17 +115,25 @@ export class CppProject implements Project {
}
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);
logger.info(
`Setting selected Qt paths for ${folder.uri.fsPath} to ${selectedQtPaths}`
);
coreAPI.setValue(folder, 'workspaceType', QtWorkspaceType.CMakeExt);
logger.info(
`Setting workspace type for ${folder.uri.fsPath} to ${QtWorkspaceType.CMakeExt}`
);
coreAPI.setValue(folder, 'buildDir', this.buildDir);
logger.info('Updating coreAPI with message:', message as unknown as string);
logger.info(
`Setting build directory for ${folder.uri.fsPath} to ${this.buildDir}`
);
logger.info('Config values initialized for:', folder.uri.fsPath);
}
public getStateManager() {
return this._stateManager;
Expand Down
10 changes: 10 additions & 0 deletions qt-lib/src/core-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ export class QtWorkspaceConfigMessage {
this.workspaceFolder = folder ?? 'global';
this.config = new Set() as MessageConfigs;
}
toString(): string {
const configs = Array.from(this.config).join(', ');
let folder: vscode.WorkspaceFolder | string;
if (typeof this.workspaceFolder === 'string') {
folder = this.workspaceFolder;
} else {
folder = this.workspaceFolder.name;
}
return `[${folder}]: ${configs}`;
}
}

export enum QtWorkspaceType {
Expand Down

0 comments on commit 4acc9e6

Please sign in to comment.