@@ -26,7 +26,7 @@ export async function generateSourcekitConfiguration(ctx: WorkspaceContext): Pro
26
26
27
27
if ( ctx . folders . length === 1 ) {
28
28
const folder = ctx . folders [ 0 ] ;
29
- const success = await createSourcekitConfiguration ( folder ) ;
29
+ const success = await createSourcekitConfiguration ( ctx , folder ) ;
30
30
void vscode . window . showTextDocument ( vscode . Uri . file ( sourcekitConfigFilePath ( folder ) ) ) ;
31
31
return success ;
32
32
}
@@ -40,22 +40,32 @@ export async function generateSourcekitConfiguration(ctx: WorkspaceContext): Pro
40
40
}
41
41
42
42
return (
43
- await Promise . all ( foldersToGenerate . map ( folder => createSourcekitConfiguration ( folder ) ) )
43
+ await Promise . all (
44
+ foldersToGenerate . map ( folder => createSourcekitConfiguration ( ctx , folder ) )
45
+ )
44
46
) . reduceRight ( ( prev , curr ) => prev || curr ) ;
45
47
}
46
48
47
49
export const sourcekitFolderPath = ( f : FolderContext ) => join ( f . folder . fsPath , ".sourcekit-lsp" ) ;
48
50
export const sourcekitConfigFilePath = ( f : FolderContext ) =>
49
51
join ( sourcekitFolderPath ( f ) , "config.json" ) ;
50
52
51
- async function createSourcekitConfiguration ( folderContext : FolderContext ) : Promise < boolean > {
53
+ async function createSourcekitConfiguration (
54
+ workspaceContext : WorkspaceContext ,
55
+ folderContext : FolderContext
56
+ ) : Promise < boolean > {
52
57
const sourcekitFolder = vscode . Uri . file ( sourcekitFolderPath ( folderContext ) ) ;
53
58
const sourcekitConfigFile = vscode . Uri . file ( sourcekitConfigFilePath ( folderContext ) ) ;
54
59
55
60
try {
56
61
await vscode . workspace . fs . stat ( sourcekitConfigFile ) ;
57
62
return true ;
58
- } catch {
63
+ } catch ( error ) {
64
+ if ( ( error as NodeJS . ErrnoException ) . code !== "ENOENT" ) {
65
+ workspaceContext . outputChannel . appendLine (
66
+ `Failed to read file at ${ sourcekitConfigFile . fsPath } : ${ error } `
67
+ ) ;
68
+ }
59
69
// Ignore, don't care if the file doesn't exist yet
60
70
}
61
71
@@ -67,7 +77,12 @@ async function createSourcekitConfiguration(folderContext: FolderContext): Promi
67
77
) ;
68
78
return false ;
69
79
}
70
- } catch {
80
+ } catch ( error ) {
81
+ if ( ( error as NodeJS . ErrnoException ) . code !== "ENOENT" ) {
82
+ workspaceContext . outputChannel . appendLine (
83
+ `Failed to read folder at ${ sourcekitFolder . fsPath } : ${ error } `
84
+ ) ;
85
+ }
71
86
await vscode . workspace . fs . createDirectory ( sourcekitFolder ) ;
72
87
}
73
88
const version = folderContext . toolchain . swiftVersion ;
0 commit comments