@@ -29,11 +29,9 @@ with Libadalang.Preprocessing;
29
29
30
30
with VSS.Strings.Conversions ;
31
31
32
- with Spawn.Environments ;
33
-
34
32
with LSP.Ada_Contexts ;
35
33
with LSP.Ada_Context_Sets ;
36
- with LSP.Ada_Handlers. Alire ;
34
+ with LSP.Alire ;
37
35
with LSP.Ada_Handlers.File_Readers ;
38
36
with LSP.Ada_Indexing ;
39
37
with LSP.Enumerations ;
@@ -85,10 +83,6 @@ package body LSP.Ada_Handlers.Project_Loading is
85
83
-- Mark all sources in all projects for indexing. This factorizes code
86
84
-- between Load_Project and Load_Implicit_Project.
87
85
88
- function Root
89
- (Self : Message_Handler'Class) return GNATCOLL.VFS.Virtual_File;
90
- -- Return the root directory of the client workspace
91
-
92
86
-- -------------------------
93
87
-- Ensure_Project_Loaded --
94
88
-- -------------------------
@@ -125,7 +119,7 @@ package body LSP.Ada_Handlers.Project_Loading is
125
119
if not Self.Client.Root.Is_Empty then
126
120
declare
127
121
Files : GNATCOLL.VFS.File_Array_Access :=
128
- Root ( Self) .Read_Dir (GNATCOLL.VFS.Files_Only);
122
+ Self.Client.Root_Directory .Read_Dir (GNATCOLL.VFS.Files_Only);
129
123
begin
130
124
for X of Files.all loop
131
125
if X.Has_Suffix (" .gpr" ) then
@@ -203,7 +197,7 @@ package body LSP.Ada_Handlers.Project_Loading is
203
197
-- root directory in the workspace.
204
198
205
199
if not Self.Client.Root.Is_Empty then
206
- Self.Project_Dirs_Loaded.Include (Root ( Self) );
200
+ Self.Project_Dirs_Loaded.Include (Self.Client.Root_Directory );
207
201
end if ;
208
202
209
203
Reload_Implicit_Project_Dirs (Self);
@@ -313,8 +307,11 @@ package body LSP.Ada_Handlers.Project_Loading is
313
307
-- relative path; if so, we're assuming it's relative
314
308
-- to Self.Root.
315
309
316
- if not Project_File.Is_Absolute_Path and then not Self.Client.Root.Is_Empty then
317
- Project_File := GNATCOLL.VFS.Join (Root (Self), Project_File);
310
+ if not Project_File.Is_Absolute_Path
311
+ and then not Self.Client.Root.Is_Empty
312
+ then
313
+ Project_File := GNATCOLL.VFS.Join (Self.Client.Root_Directory,
314
+ Project_File);
318
315
end if ;
319
316
320
317
-- Unload the project tree and the project environment
@@ -424,30 +421,24 @@ package body LSP.Ada_Handlers.Project_Loading is
424
421
Environment : GPR2.Environment.Object :=
425
422
GPR2.Environment.Process_Environment;
426
423
427
- Alire_TOML : constant GNATCOLL.VFS.Virtual_File :=
428
- (if Self.Client.Root.Is_Empty then GNATCOLL.VFS.No_File
429
- else Root (Self).Create_From_Dir (" alire.toml" ));
430
-
431
424
begin
432
- if Alire_TOML.Is_Regular_File
433
- and Spawn.Environments.System_Environment.Value (" ALIRE" ) /= " True"
434
- then
425
+ if LSP.Alire.Alire_Active (Self.Client) then
435
426
436
427
Self.Tracer.Trace (" Check alire:" );
437
428
438
429
if Project.Is_Empty then
439
430
440
- LSP.Ada_Handlers. Alire.Determine_Alire_Project
441
- (Root => Root ( Self) .Display_Full_Name,
431
+ LSP.Alire.Determine_Alire_Project
432
+ (Root => Self.Client.Root_Directory .Display_Full_Name,
442
433
Has_Alire => Has_Alire,
443
434
Error => Errors,
444
435
Project => Project);
445
436
446
437
Status := Alire_Project;
447
438
end if ;
448
439
449
- LSP.Ada_Handlers. Alire.Setup_Alire_Env
450
- (Root => Root ( Self) .Display_Full_Name,
440
+ LSP.Alire.Setup_Alire_Env
441
+ (Root => Self.Client.Root_Directory .Display_Full_Name,
451
442
Has_Alire => Has_Alire,
452
443
Error => Errors,
453
444
Environment => Environment);
@@ -628,23 +619,6 @@ package body LSP.Ada_Handlers.Project_Loading is
628
619
end if ;
629
620
end Reload_Project ;
630
621
631
- -- --------
632
- -- Root --
633
- -- --------
634
-
635
- function Root
636
- (Self : Message_Handler'Class) return GNATCOLL.VFS.Virtual_File
637
- is
638
- Value : constant VSS.Strings.Virtual_String := Self.Client.Root;
639
- Root : constant String :=
640
- VSS.Strings.Conversions.To_UTF_8_String (Value);
641
- begin
642
- return GNATCOLL.VFS.Create_From_UTF8
643
- (if Value.Starts_With (" file://" )
644
- then URIs.Conversions.To_File (Root, True)
645
- else Root);
646
- end Root ;
647
-
648
622
-- -------------------------------------
649
623
-- Update_Project_Predefined_Sources --
650
624
-- -------------------------------------
0 commit comments