Skip to content

Commit

Permalink
Passing context insted of projectProvider directly
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshwinThomasIBM authored and JoshwinThomasIBM committed Nov 25, 2024
1 parent b9473a4 commit 883928a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
item.text = localize("liberty.ls.thumbs.up");
item.tooltip = localize("liberty.ls.started");
toggleItem(window.activeTextEditor, item);
handleWorkspaceSaveInProgress(getProjectProvider(context));
handleWorkspaceSaveInProgress(context);
registerCommands(context);
}, (error: any) => {
console.log("Liberty client was not ready. Did not initialize");
Expand Down Expand Up @@ -255,19 +255,20 @@ async function getJavaExtensionAPI(): Promise<JavaExtensionAPI> {
return Promise.resolve(api);
}

function handleWorkspaceSaveInProgress(projectProvider: ProjectProvider) {
function handleWorkspaceSaveInProgress(context: vscode.ExtensionContext) {
let projectProvider = getProjectProvider(context);
if (projectProvider.getContext().globalState.get('workspaceSaveInProgress') &&
projectProvider.getContext().globalState.get('selectedProject') !== undefined) {
devCommands.addProjectsToTheDashBoard(projectProvider, projectProvider.getContext().globalState.get('selectedProject') as string);
helperUtil.clearDataSavedInGlobalState(projectProvider.getContext());
}
}

function getProjectProvider(context: vscode.ExtensionContext) : ProjectProvider{
function getProjectProvider(context: vscode.ExtensionContext): ProjectProvider {
let projectProvider = ProjectProvider.getInstance();
if ( !projectProvider ) {
projectProvider = new ProjectProvider(context);
ProjectProvider.setInstance(projectProvider);
}
if (!projectProvider) {
projectProvider = new ProjectProvider(context);
ProjectProvider.setInstance(projectProvider);
}
return projectProvider;
}

0 comments on commit 883928a

Please sign in to comment.