@@ -17,8 +17,10 @@ import * as vscode from "vscode";
1717
1818import { FolderContext } from "./FolderContext" ;
1919import { FolderOperation } from "./WorkspaceContext" ;
20+ import { handleMissingSwiftly } from "./commands/installSwiftly" ;
2021import { SwiftLogger } from "./logging/SwiftLogger" ;
2122import { BuildFlags } from "./toolchain/BuildFlags" ;
23+ import { handleMissingSwiftlyToolchain } from "./toolchain/swiftly" ;
2224import { showReloadExtensionNotification } from "./ui/ReloadExtension" ;
2325import { fileExists } from "./utilities/filesystem" ;
2426import { Version } from "./utilities/version" ;
@@ -140,6 +142,31 @@ export class PackageWatcher {
140142 async handleSwiftVersionFileChange ( ) {
141143 const version = await this . readSwiftVersionFile ( ) ;
142144 if ( version ?. toString ( ) !== this . currentVersion ?. toString ( ) ) {
145+ if ( version ) {
146+ const swiftlyInstalled = await handleMissingSwiftly ( this . logger ) ;
147+ if ( swiftlyInstalled ) {
148+ const toolchainInstalled = await handleMissingSwiftlyToolchain (
149+ version . toString ( ) ,
150+ this . folderContext . workspaceContext . extensionContext . extensionPath ,
151+ this . logger ,
152+ this . folderContext . folder
153+ ) ;
154+ if ( toolchainInstalled ) {
155+ // Build dynamic message based on installation results
156+ const message =
157+ "Swiftly and Swift toolchain have been installed. Please reload the extension to use the new toolchain." ;
158+ await showReloadExtensionNotification ( message ) ;
159+ return ;
160+ } else {
161+ // Only Swiftly was installed
162+ const message =
163+ "Swiftly has been installed. Please reload the extension to continue." ;
164+ await showReloadExtensionNotification ( message ) ;
165+ return ;
166+ }
167+ }
168+ }
169+
143170 await this . folderContext . fireEvent ( FolderOperation . swiftVersionUpdated ) ;
144171 await showReloadExtensionNotification (
145172 "Changing the swift toolchain version requires the extension to be reloaded"
0 commit comments