From a8b512190f69dc4f8fd3f97b2304e8a0d76df909 Mon Sep 17 00:00:00 2001 From: Sanjula Date: Tue, 25 Jun 2024 11:29:37 -0400 Subject: [PATCH 1/4] Add event for buildMap changes Signed-off-by: Sanjula --- src/fileWatcher.ts | 2 ++ src/projectManager.ts | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/fileWatcher.ts b/src/fileWatcher.ts index c5c7cb0b..c0756ac0 100644 --- a/src/fileWatcher.ts +++ b/src/fileWatcher.ts @@ -64,6 +64,8 @@ export namespace ProjectFileWatcher { } } else if (uri.fsPath.endsWith('.ibmi.json')) { iProject.setBuildMap(undefined); + + ProjectManager.fire({ type: 'buildMap', iProject }); } else if (uri.fsPath.endsWith('.env')) { // If the .env was updated only for keeping track of the LIBL state for other // extensions, then we don't want to refresh the UI and state diff --git a/src/projectManager.ts b/src/projectManager.ts index 23c66ca0..cccebfb9 100644 --- a/src/projectManager.ts +++ b/src/projectManager.ts @@ -26,12 +26,21 @@ export enum ProjectExplorerSchemaId { * - `projects` event is fired when there is a change to some project (create, update, or delete) * - `activeProject` event is fired when there is a change to the active project * - `libraryList` event is fired when there is a change to a project's library list + * - `buildMap` event is fired when there is a change to a project's `.ibmi.json` file * - `deployLocation` event is fired when there is a change to a project's deploy location * - `build` event is fired when a build is finished * - `compile` event is fired when a compile is finished * - `includePaths` event is fired when there is a change to a project's include paths */ -export type ProjectExplorerEventT = 'projects' | 'activeProject' | 'libraryList' | 'deployLocation' | 'build' | 'compile' | 'includePaths'; +export type ProjectExplorerEventT = + 'projects' | + 'activeProject' | + 'libraryList' | + 'buildMap' | + 'deployLocation' | + 'build' | + 'compile' | + 'includePaths'; export type ProjectExplorerEventCallback = (iProject?: IProject) => void; /** From 7db13e46327bfe73fcfe192d3119c857987dc2b2 Mon Sep 17 00:00:00 2001 From: Sanjula Date: Wed, 26 Jun 2024 18:52:32 -0400 Subject: [PATCH 2/4] fire build map event with .ibmi.json uri Signed-off-by: Sanjula --- src/fileWatcher.ts | 2 +- src/projectManager.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/fileWatcher.ts b/src/fileWatcher.ts index c0756ac0..01a1ceaf 100644 --- a/src/fileWatcher.ts +++ b/src/fileWatcher.ts @@ -65,7 +65,7 @@ export namespace ProjectFileWatcher { } else if (uri.fsPath.endsWith('.ibmi.json')) { iProject.setBuildMap(undefined); - ProjectManager.fire({ type: 'buildMap', iProject }); + ProjectManager.fire({ type: 'buildMap', iProject, uri }); } else if (uri.fsPath.endsWith('.env')) { // If the .env was updated only for keeping track of the LIBL state for other // extensions, then we don't want to refresh the UI and state diff --git a/src/projectManager.ts b/src/projectManager.ts index cccebfb9..9ba0191a 100644 --- a/src/projectManager.ts +++ b/src/projectManager.ts @@ -41,7 +41,7 @@ export type ProjectExplorerEventT = 'build' | 'compile' | 'includePaths'; -export type ProjectExplorerEventCallback = (iProject?: IProject) => void; +export type ProjectExplorerEventCallback = (iProject?: IProject, uri?: Uri) => void; /** * Project explorer event @@ -56,6 +56,11 @@ export interface ProjectExplorerEvent { * Project associated with event */ iProject?: IProject + + /** + * A uri associated with the event + */ + uri?: Uri } /** @@ -114,7 +119,7 @@ export class ProjectManager { this.emitter.event(e => { this.events.filter(event => event.event === e.type) - .forEach(event => event.callback(e.iProject)); + .forEach(event => event.callback(e?.iProject, e?.uri)); }); this.activeProjectStatusBarItem = window.createStatusBarItem(StatusBarAlignment.Left, 9); From f81c4b7bbe37148ae4dae1709a43d31f267a5a90 Mon Sep 17 00:00:00 2001 From: Sanjula Date: Thu, 27 Jun 2024 11:44:28 -0400 Subject: [PATCH 3/4] load iproj.json and .ibmi.json Signed-off-by: Sanjula --- src/fileWatcher.ts | 1 + src/iproject.ts | 12 ++++++++++++ src/projectManager.ts | 1 + 3 files changed, 14 insertions(+) diff --git a/src/fileWatcher.ts b/src/fileWatcher.ts index 01a1ceaf..14abb34a 100644 --- a/src/fileWatcher.ts +++ b/src/fileWatcher.ts @@ -56,6 +56,7 @@ export namespace ProjectFileWatcher { iProject.setLibraryList(undefined); ProjectManager.fire({ type: 'projects', iProject }); + ProjectManager.fire({ type: 'buildMap', iProject, uri }); } else if (uri.path.endsWith('iproj.json') && (type === 'delete')) { const activeProject = ProjectManager.getActiveProject(); diff --git a/src/iproject.ts b/src/iproject.ts index 1d0ec930..abd12fdb 100644 --- a/src/iproject.ts +++ b/src/iproject.ts @@ -126,6 +126,14 @@ export class IProject { this.deploymentMethod = 'compare'; } + /** + * Load a project `iproj.json` and all `.ibmi.json` files. + */ + public async load() { + await this.getState(); + await this.getBuildMap(); + } + /** * Get the project's name. *Note* that the project's name and associated * workspace folder name are the same. @@ -362,6 +370,10 @@ export class IProject { */ public setBuildMap(buildMap: Map | undefined) { this.buildMap = buildMap; + + if (!this.buildMap) { + this.updateBuildMap(); + } } /** diff --git a/src/projectManager.ts b/src/projectManager.ts index 9ba0191a..d7176b97 100644 --- a/src/projectManager.ts +++ b/src/projectManager.ts @@ -184,6 +184,7 @@ export class ProjectManager { public static async load(workspaceFolder: WorkspaceFolder) { const iProject = new IProject(workspaceFolder); if (!this.loaded[workspaceFolder.index]) { + await iProject.load(); this.loaded[workspaceFolder.index] = iProject; const metadataExists = await iProject.projectFileExists('iproj.json'); From 26adb7d4c11ca8f80f28bff60f99428695877d06 Mon Sep 17 00:00:00 2001 From: Sanjula Date: Thu, 27 Jun 2024 15:16:37 -0400 Subject: [PATCH 4/4] fix comment Signed-off-by: Sanjula --- src/iproject.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iproject.ts b/src/iproject.ts index abd12fdb..d7c2d08f 100644 --- a/src/iproject.ts +++ b/src/iproject.ts @@ -127,7 +127,7 @@ export class IProject { } /** - * Load a project `iproj.json` and all `.ibmi.json` files. + * Load the project's `iproj.json` and all `.ibmi.json` files. */ public async load() { await this.getState();