11// Copyright (c) Microsoft Corporation. All rights reserved.
22// Licensed under the MIT license.
33
4- import { commands , type ExtensionContext , extensions , workspace , type WorkspaceFolder } from "vscode" ;
4+ import { commands , type ExtensionContext , workspace , type WorkspaceFolder } from "vscode" ;
55
66import { Jdtls } from "../java/jdtls" ;
77import { languageServerApiManager } from "../languageServerApi/languageServerApiManager" ;
@@ -11,13 +11,13 @@ import { Commands } from "../commands";
1111import notificationManager from "./display/notificationManager" ;
1212import { Settings } from "../settings" ;
1313import assessmentManager from "./assessmentManager" ;
14+ import { checkOrInstallExtension } from "./utility" ;
1415
1516const DEFAULT_UPGRADE_PROMPT = "Upgrade Java project dependency to latest version." ;
1617
1718
1819function shouldRunCheckup ( ) {
19- return Settings . getEnableDependencyCheckup ( )
20- && ! ! extensions . getExtension ( ExtensionName . APP_MODERNIZATION_UPGRADE_FOR_JAVA ) ;
20+ return Settings . getEnableDependencyCheckup ( ) ;
2121}
2222
2323class UpgradeManager {
@@ -26,13 +26,13 @@ class UpgradeManager {
2626
2727 // Commands to be used
2828 context . subscriptions . push ( instrumentOperationAsVsCodeCommand ( Commands . JAVA_UPGRADE_WITH_COPILOT , async ( promptText ?: string ) => {
29+ await checkOrInstallExtension ( ExtensionName . APP_MODERNIZATION_UPGRADE_FOR_JAVA , ExtensionName . APP_MODERNIZATION_FOR_JAVA ) ;
2930 const promptToUse = promptText ?? DEFAULT_UPGRADE_PROMPT ;
3031 await commands . executeCommand ( Commands . GOTO_AGENT_MODE , { prompt : promptToUse } ) ;
3132 } ) ) ;
32- commands . executeCommand ( 'setContext' , 'isModernizationExtensionInstalled' ,
33- ! ! extensions . getExtension ( ExtensionName . APP_MODERNIZATION_FOR_JAVA ) ) ;
34- context . subscriptions . push ( instrumentOperationAsVsCodeCommand ( Commands . VIEW_MODERNIZE_JAVA_PROJECT , ( ) => {
35- commands . executeCommand ( "workbench.view.extension.azureJavaMigrationExplorer" ) ;
33+ context . subscriptions . push ( instrumentOperationAsVsCodeCommand ( Commands . VIEW_MODERNIZE_JAVA_PROJECT , async ( ) => {
34+ await checkOrInstallExtension ( ExtensionName . APP_MODERNIZATION_FOR_JAVA ) ;
35+ await commands . executeCommand ( "workbench.view.extension.azureJavaMigrationExplorer" ) ;
3636 } ) ) ;
3737
3838 UpgradeManager . scan ( ) ;
0 commit comments