1818with GNATCOLL.Traces ;
1919with GNATCOLL.VFS ;
2020
21- with GPR2.Context ;
2221with GPR2.Path_Name ;
2322with GPR2.Project.View ;
2423with GPR2.Containers ;
@@ -29,7 +28,6 @@ with GPR2.Project.Tree.View_Builder;
2928with Libadalang.Preprocessing ;
3029
3130with VSS.Strings.Conversions ;
32- with VSS.String_Vectors ;
3331
3432with Spawn.Environments ;
3533
@@ -40,6 +38,7 @@ with LSP.Ada_Handlers.File_Readers;
4038with LSP.Ada_Indexing ;
4139with LSP.Enumerations ;
4240with LSP.Structures ;
41+ with LSP.Utils ;
4342
4443with URIs ;
4544with LSP.Ada_Documents ; use LSP.Ada_Documents;
@@ -54,7 +53,7 @@ package body LSP.Ada_Handlers.Project_Loading is
5453 procedure Load_Project_With_Alire
5554 (Self : in out Message_Handler'Class;
5655 Project_File : VSS.Strings.Virtual_String := " " ;
57- Scenario_Variables : LSP.Ada_Configurations.Variable_List ;
56+ Context : GPR2.Context.Object ;
5857 Charset : VSS.Strings.Virtual_String);
5958 -- Core procedure to find project, search path, scenario and load the
6059 -- project.
@@ -86,26 +85,10 @@ package body LSP.Ada_Handlers.Project_Loading is
8685 -- Mark all sources in all projects for indexing. This factorizes code
8786 -- between Load_Project and Load_Implicit_Project.
8887
89- function To_Virtual_String
90- (Value : GNATCOLL.VFS.Virtual_File) return VSS.Strings.Virtual_String is
91- (VSS.Strings.Conversions.To_Virtual_String (Value.Display_Full_Name));
92- -- Cast Virtual_File to Virtual_String
93-
94- function To_Virtual_File
95- (Value : VSS.Strings.Virtual_String) return GNATCOLL.VFS.Virtual_File is
96- (GNATCOLL.VFS.Create_From_UTF8
97- (VSS.Strings.Conversions.To_UTF_8_String (Value)));
98- -- Cast Virtual_String to Virtual_File
99-
10088 function Root
10189 (Self : Message_Handler'Class) return GNATCOLL.VFS.Virtual_File;
10290 -- Return the root directory of the client workspace
10391
104- type Environment is record
105- Context : GPR2.Context.Object := GPR2.Context.Empty;
106- Build_Path : GPR2.Path_Name.Object := GPR2.Path_Name.Undefined;
107- end record ;
108-
10992 -- -------------------------
11093 -- Ensure_Project_Loaded --
11194 -- -------------------------
@@ -127,7 +110,7 @@ package body LSP.Ada_Handlers.Project_Loading is
127110 Load_Project_With_Alire
128111 (Self => Self,
129112 Project_File => VSS.Strings.Empty_Virtual_String,
130- Scenario_Variables => Self.Configuration.Scenario_Variables ,
113+ Context => Self.Configuration.Context ,
131114 Charset => Self.Configuration.Charset);
132115
133116 if not Self.Contexts.Is_Empty then
@@ -148,7 +131,7 @@ package body LSP.Ada_Handlers.Project_Loading is
148131 if X.Has_Suffix (" .gpr" ) then
149132 GPRs_Found := GPRs_Found + 1 ;
150133 exit when GPRs_Found > 1 ;
151- Project_File := To_Virtual_String (X);
134+ Project_File := LSP.Utils. To_Virtual_String (X);
152135 end if ;
153136 end loop ;
154137
@@ -169,7 +152,7 @@ package body LSP.Ada_Handlers.Project_Loading is
169152
170153 Load_Project
171154 (Self => Self, Project_Path => Project_File,
172- Scenario => Self.Configuration.Scenario_Variables ,
155+ Context => Self.Configuration.Context ,
173156 Environment => GPR2.Environment.Process_Environment,
174157 Charset => " iso-8859-1" ,
175158 Status => Single_Project_Found);
@@ -243,23 +226,13 @@ package body LSP.Ada_Handlers.Project_Loading is
243226 procedure Load_Project
244227 (Self : in out Message_Handler'Class;
245228 Project_Path : VSS.Strings.Virtual_String;
246- Scenario : LSP.Ada_Configurations.Variable_List ;
229+ Context : GPR2.Context.Object ;
247230 Environment : GPR2.Environment.Object;
248231 Charset : VSS.Strings.Virtual_String;
249232 Status : Load_Project_Status)
250233 is
251- use type GNATCOLL.VFS.Virtual_File;
252-
253234 Project_File : GNATCOLL.VFS.Virtual_File :=
254- To_Virtual_File (Project_Path);
255-
256- Project_Environment : Project_Loading.Environment;
257-
258- Relocate_Build_Tree : constant GNATCOLL.VFS.Virtual_File :=
259- To_Virtual_File (Self.Configuration.Relocate_Build_Tree);
260-
261- Root_Dir : constant GNATCOLL.VFS.Virtual_File :=
262- To_Virtual_File (Self.Configuration.Relocate_Root);
235+ LSP.Utils.To_Virtual_File (Project_Path);
263236
264237 procedure Create_Context_For_Non_Aggregate
265238 (View : GPR2.Project.View.Object);
@@ -276,7 +249,7 @@ package body LSP.Ada_Handlers.Project_Loading is
276249 use LSP.Ada_Contexts;
277250
278251 C : constant Context_Access :=
279- new Context (Self.Tracer);
252+ new LSP.Ada_Contexts. Context (Self.Tracer);
280253
281254 Reader : LSP.Ada_Handlers.File_Readers.LSP_File_Reader
282255 (Self'Unchecked_Access);
@@ -350,37 +323,12 @@ package body LSP.Ada_Handlers.Project_Loading is
350323 -- Now load the new project
351324 Self.Project_Status.Load_Status := Status;
352325
353- if not Self.Configuration.Relocate_Build_Tree.Is_Empty then
354- Project_Environment.Build_Path :=
355- GPR2.Path_Name.Create (Relocate_Build_Tree);
356-
357- if not Self.Configuration.Relocate_Root.Is_Empty
358- and then Project_File /= GNATCOLL.VFS.No_File
359- then
360- if not Root_Dir.Is_Absolute_Path then
361- Project_Environment.Build_Path :=
362- GPR2.Path_Name.Create_Directory
363- (GPR2.Path_Name.Create (Project_File).Relative_Path
364- (GPR2.Path_Name.Create (Root_Dir)),
365- GPR2.Filename_Type
366- (Project_Environment.Build_Path.Value));
367- end if ;
368- end if ;
369- end if ;
370-
371- -- Update scenario variables with user provided values
372- for J in 1 .. Scenario.Names.Length loop
373- Project_Environment.Context.Insert
374- (GPR2.Optional_Name_Type
375- (VSS.Strings.Conversions.To_UTF_8_String (Scenario.Names (J))),
376- VSS.Strings.Conversions.To_UTF_8_String (Scenario.Values (J)));
377- end loop ;
378-
379326 begin
380327 Self.Project_Tree.Load_Autoconf
381328 (Filename => GPR2.Path_Name.Create (Project_File),
382- Context => Project_Environment.Context,
383- Build_Path => Project_Environment.Build_Path,
329+ Context => Context,
330+ Build_Path => LSP.Ada_Configurations.Build_Path
331+ (Self.Configuration, GPR2.Path_Name.Create (Project_File)),
384332 Environment => Environment);
385333
386334 if Self.Project_Tree.Are_Sources_Loaded then
@@ -454,7 +402,7 @@ package body LSP.Ada_Handlers.Project_Loading is
454402 procedure Load_Project_With_Alire
455403 (Self : in out Message_Handler'Class;
456404 Project_File : VSS.Strings.Virtual_String := " " ;
457- Scenario_Variables : LSP.Ada_Configurations.Variable_List ;
405+ Context : GPR2.Context.Object ;
458406 Charset : VSS.Strings.Virtual_String)
459407 is
460408
@@ -527,7 +475,7 @@ package body LSP.Ada_Handlers.Project_Loading is
527475 Load_Project
528476 (Self => Self,
529477 Project_Path => Project,
530- Scenario => Scenario_Variables ,
478+ Context => Context ,
531479 Environment => Environment,
532480 Charset => (if Charset.Is_Empty then UTF_8 else Charset),
533481 Status => Status);
@@ -545,7 +493,7 @@ package body LSP.Ada_Handlers.Project_Loading is
545493 Load_Project
546494 (Self => Self,
547495 Project_Path => Project,
548- Scenario => Scenario_Variables ,
496+ Context => Context ,
549497 Environment => Environment,
550498 Charset => Charset,
551499 Status => Valid_Project_Configured);
@@ -668,7 +616,7 @@ package body LSP.Ada_Handlers.Project_Loading is
668616 Load_Project_With_Alire
669617 (Self,
670618 Project_File,
671- Self.Configuration.Scenario_Variables ,
619+ Self.Configuration.Context ,
672620 Self.Configuration.Charset);
673621 end if ;
674622 end Reload_Project ;
0 commit comments