44import { commands , extensions , Uri , window } from "vscode" ;
55import * as semver from "semver" ;
66import { UpgradeReason , type UpgradeIssue } from "./type" ;
7- import { Upgrade } from "../constants" ;
7+ import { ExtensionName , Upgrade } from "../constants" ;
88
99
1010function findEolDate ( currentVersion : string , eolDate : Record < string , string > ) : string | null {
@@ -73,38 +73,33 @@ export function normalizePath(path: string): string {
7373 return Uri . parse ( path ) . toString ( ) ;
7474}
7575
76- export async function checkOrInstallExtension ( extensionIdToCheck : string , extensionIdToInstall ?: string ) : Promise < void > {
76+ export async function checkOrPromptToInstallAppModExtension (
77+ extensionIdToCheck : string ,
78+ notificationText : string ,
79+ buttonText : string ) : Promise < void > {
7780 if ( extensions . getExtension ( extensionIdToCheck ) ) {
7881 return ;
7982 }
8083
81- const actualExtensionIdToInstall = extensionIdToInstall ?? extensionIdToCheck ;
82-
83- {
84- const BTN_TEXT = "Install extension" ;
85- const choice = await window . showInformationMessage (
86- "An extension is needed for the feature to work. Please install it and try again." ,
87- BTN_TEXT
88- ) ;
89- if ( choice === BTN_TEXT ) {
90- await commands . executeCommand ( "workbench.extensions.installExtension" , actualExtensionIdToInstall ) ;
91- }
84+ const choice = await window . showInformationMessage ( notificationText , buttonText ) ;
85+ if ( choice === buttonText ) {
86+ await commands . executeCommand ( "workbench.extensions.installExtension" , ExtensionName . APP_MODERNIZATION_FOR_JAVA ) ;
87+ } else {
88+ return ;
9289 }
9390
94- if ( extensions . getExtension ( actualExtensionIdToInstall ) ) {
91+ if ( extensions . getExtension ( ExtensionName . APP_MODERNIZATION_FOR_JAVA ) ) {
9592 return ;
9693 }
9794
9895 // In this case the extension is disabled.
99- await commands . executeCommand ( "workbench.extensions.search" , actualExtensionIdToInstall ) ;
100- {
101- const BTN_TEXT = "Show extension in sidebar" ;
102- const choice = await window . showInformationMessage (
103- "An extension is needed for the feature to work but it seems disabled. Please enable it manually and try again." ,
104- BTN_TEXT
105- ) ;
106- if ( choice === BTN_TEXT ) {
107- await commands . executeCommand ( "workbench.extensions.search" , actualExtensionIdToInstall ) ;
108- }
96+ await commands . executeCommand ( "workbench.extensions.search" , ExtensionName . APP_MODERNIZATION_FOR_JAVA ) ;
97+ const BTN_TEXT = "Show extension in sidebar" ;
98+ const choice2 = await window . showInformationMessage (
99+ "App Modernization extension is needed for the feature to work but it seems disabled. Please enable it manually and try again." ,
100+ BTN_TEXT
101+ ) ;
102+ if ( choice2 === BTN_TEXT ) {
103+ await commands . executeCommand ( "workbench.extensions.search" , ExtensionName . APP_MODERNIZATION_FOR_JAVA ) ;
109104 }
110105}
0 commit comments