@@ -9,10 +9,12 @@ use async_lsp::{
9
9
} ;
10
10
11
11
use common:: InputDb ;
12
+ use resolver:: {
13
+ ingot:: { source_files:: SourceFiles , Ingot as ResolvedIngot , IngotResolver } ,
14
+ Resolver ,
15
+ } ;
12
16
use rustc_hash:: FxHashSet ;
13
- use resolver:: { Resolver , ingot:: { IngotResolver , Ingot as ResolvedIngot , source_files:: SourceFiles } } ;
14
17
use url:: Url ;
15
- use glob;
16
18
17
19
use super :: { capabilities:: server_capabilities, hover:: hover_helper} ;
18
20
@@ -59,7 +61,7 @@ async fn discover_and_load_ingots(
59
61
// Find all fe.toml files in the workspace
60
62
let pattern = format ! ( "{}/**/fe.toml" , root_path. to_string_lossy( ) ) ;
61
63
let config_paths = glob:: glob ( & pattern)
62
- . map_err ( |e| ResponseError :: new ( ErrorCode :: INTERNAL_ERROR , format ! ( "Glob error: {}" , e ) ) ) ?
64
+ . map_err ( |e| ResponseError :: new ( ErrorCode :: INTERNAL_ERROR , format ! ( "Glob error: {e}" ) ) ) ?
63
65
. filter_map ( Result :: ok)
64
66
. collect :: < Vec < _ > > ( ) ;
65
67
@@ -71,7 +73,7 @@ async fn discover_and_load_ingots(
71
73
let ingot_url = Url :: from_directory_path ( ingot_dir) . map_err ( |_| {
72
74
ResponseError :: new (
73
75
ErrorCode :: INTERNAL_ERROR ,
74
- format ! ( "Invalid ingot path: {:?}" , ingot_dir ) ,
76
+ format ! ( "Invalid ingot path: {ingot_dir :?}" ) ,
75
77
)
76
78
} ) ?;
77
79
@@ -82,12 +84,18 @@ async fn discover_and_load_ingots(
82
84
} ) => {
83
85
// Touch the config file if it exists
84
86
if let Some ( config) = config {
85
- backend. db . workspace ( ) . touch ( & mut backend. db , config. url , Some ( config. content ) ) ;
87
+ backend
88
+ . db
89
+ . workspace ( )
90
+ . touch ( & mut backend. db , config. url , Some ( config. content ) ) ;
86
91
}
87
-
92
+
88
93
// Touch all source files
89
94
for ( file_url, content) in files {
90
- backend. db . workspace ( ) . touch ( & mut backend. db , file_url, Some ( content) ) ;
95
+ backend
96
+ . db
97
+ . workspace ( )
98
+ . touch ( & mut backend. db , file_url, Some ( content) ) ;
91
99
}
92
100
}
93
101
Ok ( _) => {
@@ -104,7 +112,7 @@ async fn discover_and_load_ingots(
104
112
let root_url = Url :: from_directory_path ( root_path) . map_err ( |_| {
105
113
ResponseError :: new (
106
114
ErrorCode :: INTERNAL_ERROR ,
107
- format ! ( "Invalid workspace root path: {:?}" , root_path ) ,
115
+ format ! ( "Invalid workspace root path: {root_path :?}" ) ,
108
116
)
109
117
} ) ?;
110
118
@@ -114,14 +122,23 @@ async fn discover_and_load_ingots(
114
122
source_files : Some ( SourceFiles { files, .. } ) ,
115
123
} ) => {
116
124
if let Some ( config) = config {
117
- backend. db . workspace ( ) . touch ( & mut backend. db , config. url , Some ( config. content ) ) ;
125
+ backend
126
+ . db
127
+ . workspace ( )
128
+ . touch ( & mut backend. db , config. url , Some ( config. content ) ) ;
118
129
}
119
130
for ( file_url, content) in files {
120
- backend. db . workspace ( ) . touch ( & mut backend. db , file_url, Some ( content) ) ;
131
+ backend
132
+ . db
133
+ . workspace ( )
134
+ . touch ( & mut backend. db , file_url, Some ( content) ) ;
121
135
}
122
136
}
123
137
Ok ( ResolvedIngot :: SingleFile { url, content } ) => {
124
- backend. db . workspace ( ) . touch ( & mut backend. db , url, Some ( content) ) ;
138
+ backend
139
+ . db
140
+ . workspace ( )
141
+ . touch ( & mut backend. db , url, Some ( content) ) ;
125
142
}
126
143
Ok ( _) => {
127
144
info ! ( "No Fe source files found in workspace root" ) ;
@@ -168,10 +185,14 @@ pub async fn initialized(
168
185
info ! ( "language server initialized! recieved notification!" ) ;
169
186
170
187
// Get all files from the workspace
171
- let all_files: Vec < _ > = backend. db . workspace ( ) . all_files ( & backend. db ) . iter ( )
188
+ let all_files: Vec < _ > = backend
189
+ . db
190
+ . workspace ( )
191
+ . all_files ( & backend. db )
192
+ . iter ( )
172
193
. map ( |( url, _file) | url)
173
194
. collect ( ) ;
174
-
195
+
175
196
for url in all_files {
176
197
let _ = backend. client . emit ( NeedsDiagnostics ( url) ) ;
177
198
}
@@ -266,7 +287,8 @@ pub async fn handle_file_change(
266
287
} ;
267
288
268
289
// Check if this is a fe.toml file
269
- let is_fe_toml = path. file_name ( )
290
+ let is_fe_toml = path
291
+ . file_name ( )
270
292
. and_then ( |name| name. to_str ( ) )
271
293
. map ( |name| name == "fe.toml" )
272
294
. unwrap_or ( false ) ;
@@ -295,7 +317,7 @@ pub async fn handle_file_change(
295
317
. db
296
318
. workspace ( )
297
319
. touch ( & mut backend. db , url. clone ( ) , Some ( contents) ) ;
298
-
320
+
299
321
// If a fe.toml was created, discover and load all files in the new ingot
300
322
if is_fe_toml {
301
323
if let Some ( ingot_dir) = path. parent ( ) {
@@ -322,7 +344,7 @@ pub async fn handle_file_change(
322
344
. db
323
345
. workspace ( )
324
346
. touch ( & mut backend. db , url. clone ( ) , Some ( contents) ) ;
325
-
347
+
326
348
// If fe.toml was modified, re-scan the ingot for any new files
327
349
if is_fe_toml {
328
350
if let Some ( ingot_dir) = path. parent ( ) {
@@ -348,23 +370,26 @@ async fn load_ingot_files(
348
370
ingot_dir : & std:: path:: Path ,
349
371
) -> Result < ( ) , ResponseError > {
350
372
info ! ( "Loading ingot files from: {:?}" , ingot_dir) ;
351
-
373
+
352
374
let mut ingot_resolver = IngotResolver :: default ( ) ;
353
375
let ingot_url = Url :: from_directory_path ( ingot_dir) . map_err ( |_| {
354
376
ResponseError :: new (
355
377
ErrorCode :: INTERNAL_ERROR ,
356
- format ! ( "Invalid ingot path: {:?}" , ingot_dir ) ,
378
+ format ! ( "Invalid ingot path: {ingot_dir :?}" ) ,
357
379
)
358
380
} ) ?;
359
381
360
382
match ingot_resolver. resolve ( & ingot_url) {
361
383
Ok ( ResolvedIngot :: Folder {
362
- config : _, // Already loaded by the file change handler
384
+ config : _, // Already loaded by the file change handler
363
385
source_files : Some ( SourceFiles { files, .. } ) ,
364
386
} ) => {
365
387
// Touch all source files
366
388
for ( file_url, content) in files {
367
- backend. db . workspace ( ) . touch ( & mut backend. db , file_url. clone ( ) , Some ( content) ) ;
389
+ backend
390
+ . db
391
+ . workspace ( )
392
+ . touch ( & mut backend. db , file_url. clone ( ) , Some ( content) ) ;
368
393
let _ = backend. client . emit ( NeedsDiagnostics ( file_url) ) ;
369
394
}
370
395
}
@@ -375,7 +400,7 @@ async fn load_ingot_files(
375
400
error ! ( "Failed to resolve ingot at {:?}: {:?}" , ingot_dir, e) ;
376
401
}
377
402
}
378
-
403
+
379
404
Ok ( ( ) )
380
405
}
381
406
0 commit comments