18
18
with GNATCOLL.Traces ;
19
19
with GNATCOLL.VFS ;
20
20
21
- with GPR2.Context ;
22
21
with GPR2.Path_Name ;
23
22
with GPR2.Project.View ;
24
23
with GPR2.Containers ;
@@ -29,7 +28,6 @@ with GPR2.Project.Tree.View_Builder;
29
28
with Libadalang.Preprocessing ;
30
29
31
30
with VSS.Strings.Conversions ;
32
- with VSS.String_Vectors ;
33
31
34
32
with Spawn.Environments ;
35
33
@@ -40,6 +38,7 @@ with LSP.Ada_Handlers.File_Readers;
40
38
with LSP.Ada_Indexing ;
41
39
with LSP.Enumerations ;
42
40
with LSP.Structures ;
41
+ with LSP.Utils ;
43
42
44
43
with URIs ;
45
44
with LSP.Ada_Documents ; use LSP.Ada_Documents;
@@ -54,7 +53,7 @@ package body LSP.Ada_Handlers.Project_Loading is
54
53
procedure Load_Project_With_Alire
55
54
(Self : in out Message_Handler'Class;
56
55
Project_File : VSS.Strings.Virtual_String := " " ;
57
- Scenario_Variables : LSP.Ada_Configurations.Variable_List ;
56
+ Context : GPR2.Context.Object ;
58
57
Charset : VSS.Strings.Virtual_String);
59
58
-- Core procedure to find project, search path, scenario and load the
60
59
-- project.
@@ -86,26 +85,10 @@ package body LSP.Ada_Handlers.Project_Loading is
86
85
-- Mark all sources in all projects for indexing. This factorizes code
87
86
-- between Load_Project and Load_Implicit_Project.
88
87
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
-
100
88
function Root
101
89
(Self : Message_Handler'Class) return GNATCOLL.VFS.Virtual_File;
102
90
-- Return the root directory of the client workspace
103
91
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
-
109
92
-- -------------------------
110
93
-- Ensure_Project_Loaded --
111
94
-- -------------------------
@@ -127,7 +110,7 @@ package body LSP.Ada_Handlers.Project_Loading is
127
110
Load_Project_With_Alire
128
111
(Self => Self,
129
112
Project_File => VSS.Strings.Empty_Virtual_String,
130
- Scenario_Variables => Self.Configuration.Scenario_Variables ,
113
+ Context => Self.Configuration.Context ,
131
114
Charset => Self.Configuration.Charset);
132
115
133
116
if not Self.Contexts.Is_Empty then
@@ -148,7 +131,7 @@ package body LSP.Ada_Handlers.Project_Loading is
148
131
if X.Has_Suffix (" .gpr" ) then
149
132
GPRs_Found := GPRs_Found + 1 ;
150
133
exit when GPRs_Found > 1 ;
151
- Project_File := To_Virtual_String (X);
134
+ Project_File := LSP.Utils. To_Virtual_String (X);
152
135
end if ;
153
136
end loop ;
154
137
@@ -169,7 +152,7 @@ package body LSP.Ada_Handlers.Project_Loading is
169
152
170
153
Load_Project
171
154
(Self => Self, Project_Path => Project_File,
172
- Scenario => Self.Configuration.Scenario_Variables ,
155
+ Context => Self.Configuration.Context ,
173
156
Environment => GPR2.Environment.Process_Environment,
174
157
Charset => " iso-8859-1" ,
175
158
Status => Single_Project_Found);
@@ -243,23 +226,13 @@ package body LSP.Ada_Handlers.Project_Loading is
243
226
procedure Load_Project
244
227
(Self : in out Message_Handler'Class;
245
228
Project_Path : VSS.Strings.Virtual_String;
246
- Scenario : LSP.Ada_Configurations.Variable_List ;
229
+ Context : GPR2.Context.Object ;
247
230
Environment : GPR2.Environment.Object;
248
231
Charset : VSS.Strings.Virtual_String;
249
232
Status : Load_Project_Status)
250
233
is
251
- use type GNATCOLL.VFS.Virtual_File;
252
-
253
234
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);
263
236
264
237
procedure Create_Context_For_Non_Aggregate
265
238
(View : GPR2.Project.View.Object);
@@ -276,7 +249,7 @@ package body LSP.Ada_Handlers.Project_Loading is
276
249
use LSP.Ada_Contexts;
277
250
278
251
C : constant Context_Access :=
279
- new Context (Self.Tracer);
252
+ new LSP.Ada_Contexts. Context (Self.Tracer);
280
253
281
254
Reader : LSP.Ada_Handlers.File_Readers.LSP_File_Reader
282
255
(Self'Unchecked_Access);
@@ -350,37 +323,12 @@ package body LSP.Ada_Handlers.Project_Loading is
350
323
-- Now load the new project
351
324
Self.Project_Status.Load_Status := Status;
352
325
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
-
379
326
begin
380
327
Self.Project_Tree.Load_Autoconf
381
328
(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)),
384
332
Environment => Environment);
385
333
386
334
if Self.Project_Tree.Are_Sources_Loaded then
@@ -454,7 +402,7 @@ package body LSP.Ada_Handlers.Project_Loading is
454
402
procedure Load_Project_With_Alire
455
403
(Self : in out Message_Handler'Class;
456
404
Project_File : VSS.Strings.Virtual_String := " " ;
457
- Scenario_Variables : LSP.Ada_Configurations.Variable_List ;
405
+ Context : GPR2.Context.Object ;
458
406
Charset : VSS.Strings.Virtual_String)
459
407
is
460
408
@@ -527,7 +475,7 @@ package body LSP.Ada_Handlers.Project_Loading is
527
475
Load_Project
528
476
(Self => Self,
529
477
Project_Path => Project,
530
- Scenario => Scenario_Variables ,
478
+ Context => Context ,
531
479
Environment => Environment,
532
480
Charset => (if Charset.Is_Empty then UTF_8 else Charset),
533
481
Status => Status);
@@ -545,7 +493,7 @@ package body LSP.Ada_Handlers.Project_Loading is
545
493
Load_Project
546
494
(Self => Self,
547
495
Project_Path => Project,
548
- Scenario => Scenario_Variables ,
496
+ Context => Context ,
549
497
Environment => Environment,
550
498
Charset => Charset,
551
499
Status => Valid_Project_Configured);
@@ -668,7 +616,7 @@ package body LSP.Ada_Handlers.Project_Loading is
668
616
Load_Project_With_Alire
669
617
(Self,
670
618
Project_File,
671
- Self.Configuration.Scenario_Variables ,
619
+ Self.Configuration.Context ,
672
620
Self.Configuration.Charset);
673
621
end if ;
674
622
end Reload_Project ;
0 commit comments