@@ -17,8 +17,10 @@ import * as vscode from "vscode";
17
17
18
18
import { FolderContext } from "./FolderContext" ;
19
19
import { FolderOperation } from "./WorkspaceContext" ;
20
+ import { handleMissingSwiftly } from "./commands/installSwiftly" ;
20
21
import { SwiftLogger } from "./logging/SwiftLogger" ;
21
22
import { BuildFlags } from "./toolchain/BuildFlags" ;
23
+ import { handleMissingSwiftlyToolchain } from "./toolchain/swiftly" ;
22
24
import { showReloadExtensionNotification } from "./ui/ReloadExtension" ;
23
25
import { fileExists } from "./utilities/filesystem" ;
24
26
import { Version } from "./utilities/version" ;
@@ -140,6 +142,30 @@ export class PackageWatcher {
140
142
async handleSwiftVersionFileChange ( ) {
141
143
const version = await this . readSwiftVersionFile ( ) ;
142
144
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 . logger ,
151
+ this . folderContext . folder
152
+ ) ;
153
+ if ( toolchainInstalled ) {
154
+ // Build dynamic message based on installation results
155
+ const message =
156
+ "Swiftly and Swift toolchain have been installed. Please reload the extension to use the new toolchain." ;
157
+ await showReloadExtensionNotification ( message ) ;
158
+ return ;
159
+ } else {
160
+ // Only Swiftly was installed
161
+ const message =
162
+ "Swiftly has been installed. Please reload the extension to continue." ;
163
+ await showReloadExtensionNotification ( message ) ;
164
+ return ;
165
+ }
166
+ }
167
+ }
168
+
143
169
await this . folderContext . fireEvent ( FolderOperation . swiftVersionUpdated ) ;
144
170
await showReloadExtensionNotification (
145
171
"Changing the swift toolchain version requires the extension to be reloaded"
0 commit comments