@@ -59,23 +59,24 @@ package body LSP.Ada_Handlers.Project_Loading is
59
59
LSP.GNATCOLL_Tracers.Create (" ALS.PROJECT" , GNATCOLL.Traces.On);
60
60
61
61
Runtime_Indexing : constant GNATCOLL.Traces.Trace_Handle :=
62
- GNATCOLL.Traces.Create (" ALS.RUNTIME_INDEXING" ,
63
- GNATCOLL.Traces.On);
62
+ GNATCOLL.Traces.Create (" ALS.RUNTIME_INDEXING" , GNATCOLL.Traces.On);
64
63
-- Trace to enable/disable runtime indexing. Useful for the testsuite.
65
64
66
65
type GPR2_Reporter is new GPR2.Reporter.Object with record
67
66
Log : GPR2.Log.Object;
68
67
end record ;
69
68
70
- overriding procedure Internal_Report
71
- (Self : in out GPR2_Reporter;
72
- Msg : GPR2.Message.Object);
69
+ overriding
70
+ procedure Internal_Report
71
+ (Self : in out GPR2_Reporter; Msg : GPR2.Message.Object);
73
72
74
- overriding function Verbosity
73
+ overriding
74
+ function Verbosity
75
75
(Self : GPR2_Reporter) return GPR2.Reporter.Verbosity_Level
76
76
is (GPR2.Reporter.Regular);
77
77
78
- LF : VSS.Characters.Virtual_Character renames VSS.Characters.Latin.Line_Feed;
78
+ LF : VSS.Characters.Virtual_Character
79
+ renames VSS.Characters.Latin.Line_Feed;
79
80
80
81
procedure Load_Project
81
82
(Self : in out Message_Handler'Class;
@@ -106,8 +107,7 @@ package body LSP.Ada_Handlers.Project_Loading is
106
107
(Self : in out Message_Handler'Class);
107
108
-- Fill Self.Project_Predefined_Sources with loaded project tree runtime
108
109
109
- procedure Enqueue_Indexing_Job
110
- (Self : in out Message_Handler'Class);
110
+ procedure Enqueue_Indexing_Job (Self : in out Message_Handler'Class);
111
111
-- Enqueue the indexing job, which indexes all the project's sources.
112
112
-- This also indexes immediately any already opened document, creating
113
113
-- the handler's fallback context before for that purpose.
@@ -152,22 +152,34 @@ package body LSP.Ada_Handlers.Project_Loading is
152
152
153
153
elsif Is_Alire_Crate then
154
154
Tracer.Trace (" Workspace is an Alire crate" );
155
- Tracer.Trace (" Determining project from 'alr show' output" );
156
155
157
- LSP.Alire.Determine_Alire_Project
158
- (Root => Self.Client.Root_Directory.Display_Full_Name,
159
- Error => Alire_Error,
160
- Project => Project_File);
156
+ Tracer.Trace (" Performing minimal Alire sync" );
157
+ LSP.Alire.Conservative_Alire_Sync
158
+ (Self.Client.Root_Directory.Display_Full_Name, Alire_Error);
161
159
162
160
if not Alire_Error.Is_Empty then
163
161
Tracer.Trace_Text (" Encountered errors: " & Alire_Error);
164
162
Self.Project_Status.Set_Alire_Messages ([Alire_Error]);
165
163
else
166
- -- Report how we found the project
167
- Self.Project_Status.Set_Project_Type
168
- (LSP.Ada_Project_Loading.Alire_Project);
169
- Self.Project_Status.Set_Alire_Messages ([]);
164
+ Tracer.Trace (" Determining project from 'alr show' output" );
165
+
166
+ LSP.Alire.Determine_Alire_Project
167
+ (Root => Self.Client.Root_Directory.Display_Full_Name,
168
+ Error => Alire_Error,
169
+ Project => Project_File);
170
+
171
+ if not Alire_Error.Is_Empty then
172
+ Tracer.Trace_Text (" Encountered errors: " & Alire_Error);
173
+ Self.Project_Status.Set_Alire_Messages ([Alire_Error]);
174
+ else
175
+ -- Report how we found the project
176
+ Self.Project_Status.Set_Project_Type
177
+ (LSP.Ada_Project_Loading.Alire_Project);
178
+ Self.Project_Status.Set_Alire_Messages ([]);
179
+ end if ;
180
+
170
181
end if ;
182
+
171
183
end if ;
172
184
173
185
-- If still haven't found a project, try to find a unique project at the root
@@ -216,8 +228,7 @@ package body LSP.Ada_Handlers.Project_Loading is
216
228
then
217
229
VSS.Strings.Virtual_String'
218
230
(" utf-8" ) -- Alire projects tend to prefer utf-8
219
- else
220
- " iso-8859-1" );
231
+ else " iso-8859-1" );
221
232
222
233
begin
223
234
-- We have an Alire crate and we did not encounter any issue
@@ -249,7 +260,8 @@ package body LSP.Ada_Handlers.Project_Loading is
249
260
VSS.Strings.Conversions.To_Virtual_String
250
261
(URIs.Conversions.To_File
251
262
(VSS.Strings.Conversions.To_UTF_8_String
252
- (GPR_Configuration_File), True));
263
+ (GPR_Configuration_File),
264
+ True));
253
265
end if ;
254
266
255
267
Load_Project
@@ -288,9 +300,9 @@ package body LSP.Ada_Handlers.Project_Loading is
288
300
-- Internal_Report --
289
301
-- -------------------
290
302
291
- overriding procedure Internal_Report
292
- (Self : in out GPR2_Reporter;
293
- Msg : GPR2.Message.Object) is
303
+ overriding
304
+ procedure Internal_Report
305
+ (Self : in out GPR2_Reporter; Msg : GPR2.Message.Object) is
294
306
begin
295
307
Self.Log.Append (Msg);
296
308
end Internal_Report ;
@@ -309,12 +321,11 @@ package body LSP.Ada_Handlers.Project_Loading is
309
321
310
322
C : constant Context_Access := new Context (Self.Tracer);
311
323
312
- Reader : LSP.Ada_Handlers.File_Readers.LSP_File_Reader
313
- (Self'Unchecked_Access);
324
+ Reader :
325
+ LSP.Ada_Handlers.File_Readers.LSP_File_Reader (Self'Unchecked_Access);
314
326
Root : GNATCOLL.VFS.Virtual_File;
315
327
begin
316
- Tracer.Trace
317
- (" Loading the implicit project because " & Status'Image);
328
+ Tracer.Trace (" Loading the implicit project because " & Status'Image);
318
329
319
330
LSP.Ada_Project_Loading.Set_Project_Type
320
331
(Self.Project_Status, LSP.Ada_Project_Loading.Implicit_Project);
@@ -388,12 +399,12 @@ package body LSP.Ada_Handlers.Project_Loading is
388
399
use type VSS.Strings.Virtual_String;
389
400
use type GNATCOLL.VFS.Virtual_File;
390
401
391
- Project_File : GNATCOLL.VFS.Virtual_File :=
402
+ Project_File : GNATCOLL.VFS.Virtual_File :=
392
403
LSP.Utils.To_Virtual_File (Project_Path);
393
404
394
405
GPR_Config_File : GNATCOLL.VFS.Virtual_File;
395
406
396
- Root : GNATCOLL.VFS.Virtual_File;
407
+ Root : GNATCOLL.VFS.Virtual_File;
397
408
398
409
procedure Create_Context_For_Non_Aggregate
399
410
(View : GPR2.Project.View.Object;
@@ -416,11 +427,12 @@ package body LSP.Ada_Handlers.Project_Loading is
416
427
use LSP.Ada_Context_Sets;
417
428
use LSP.Ada_Contexts;
418
429
419
- C : constant Context_Access :=
430
+ C : constant Context_Access :=
420
431
new LSP.Ada_Contexts.Context (Self.Tracer);
421
432
422
- Reader : LSP.Ada_Handlers.File_Readers.LSP_File_Reader
423
- (Self'Unchecked_Access);
433
+ Reader :
434
+ LSP.Ada_Handlers.File_Readers.LSP_File_Reader
435
+ (Self'Unchecked_Access);
424
436
425
437
Default_Config : Libadalang.Preprocessing.File_Config;
426
438
File_Configs : Libadalang.Preprocessing.File_Config_Maps.Map;
@@ -473,8 +485,9 @@ package body LSP.Ada_Handlers.Project_Loading is
473
485
Tree => Self.Project_Tree,
474
486
Charset => VSS.Strings.Conversions.To_UTF_8_String (Charset));
475
487
476
- Tracer.Trace (" Prepend Context Id: "
477
- & VSS.Strings.Conversions.To_UTF_8_String (C.Id));
488
+ Tracer.Trace
489
+ (" Prepend Context Id: "
490
+ & VSS.Strings.Conversions.To_UTF_8_String (C.Id));
478
491
Self.Contexts.Prepend (C);
479
492
end Create_Context_For_Non_Aggregate ;
480
493
@@ -484,15 +497,16 @@ package body LSP.Ada_Handlers.Project_Loading is
484
497
485
498
procedure Log_GPR2_Diagnostics is
486
499
Log : constant GPR2.Log.Object'Class :=
487
- GPR2_Reporter (Self.Project_Tree.Reporter.Element.all ).Log;
500
+ GPR2_Reporter (Self.Project_Tree.Reporter.Element.all ).Log;
488
501
begin
489
502
Tracer.Increase_Indent;
490
503
if Log.Is_Empty then
491
504
Tracer.Trace (" No GPR2 messages" );
492
505
else
493
506
for Msg of Log loop
494
507
declare
495
- Message : constant String := Msg.Format (Full_Path_Name => True);
508
+ Message : constant String :=
509
+ Msg.Format (Full_Path_Name => True);
496
510
begin
497
511
Tracer.Trace (Message);
498
512
end ;
@@ -544,11 +558,12 @@ package body LSP.Ada_Handlers.Project_Loading is
544
558
end if ;
545
559
546
560
-- Set Valid Status for now, it can be overwritten in case of errors
547
- Self.Project_Status.Set_Load_Status (LSP.Ada_Project_Loading.Valid_Project);
561
+ Self.Project_Status.Set_Load_Status
562
+ (LSP.Ada_Project_Loading.Valid_Project);
548
563
549
564
declare
550
- Opts : GPR2.Options.Object;
551
- Success : Boolean;
565
+ Opts : GPR2.Options.Object;
566
+ Success : Boolean;
552
567
553
568
Reporter : GPR2_Reporter;
554
569
-- This reporter object is passed to the GPR2 Load function, but it
@@ -567,18 +582,20 @@ package body LSP.Ada_Handlers.Project_Loading is
567
582
568
583
Tracer.Trace (" Loading project with GPR2" );
569
584
570
- Success := Self.Project_Tree.Load
571
- (Opts,
572
- Reporter => Reporter,
573
- With_Runtime => True,
574
- Absent_Dir_Error => GPR2.No_Error,
575
- Environment => Environment);
585
+ Success :=
586
+ Self.Project_Tree.Load
587
+ (Opts,
588
+ Reporter => Reporter,
589
+ With_Runtime => True,
590
+ Absent_Dir_Error => GPR2.No_Error,
591
+ Environment => Environment);
576
592
577
593
Tracer.Trace (" GPR2 messages after load:" );
578
594
Log_GPR2_Diagnostics;
579
595
580
596
if not Success then
581
- Self.Project_Status.Set_Load_Status (LSP.Ada_Project_Loading.Invalid_Project);
597
+ Self.Project_Status.Set_Load_Status
598
+ (LSP.Ada_Project_Loading.Invalid_Project);
582
599
end if ;
583
600
584
601
if Success then
@@ -595,7 +612,8 @@ package body LSP.Ada_Handlers.Project_Loading is
595
612
exception
596
613
when E : others =>
597
614
Tracer.Trace_Exception (E);
598
- Self.Project_Status.Set_Load_Status (LSP.Ada_Project_Loading.Invalid_Project);
615
+ Self.Project_Status.Set_Load_Status
616
+ (LSP.Ada_Project_Loading.Invalid_Project);
599
617
end ;
600
618
601
619
if Self.Project_Status.Is_Project_Loaded then
@@ -605,11 +623,11 @@ package body LSP.Ada_Handlers.Project_Loading is
605
623
Self.Project_Tree.Root_Project;
606
624
begin
607
625
-- Only check runtime issues for Ada
608
- Self.Project_Status.Set_Missing_Ada_Runtime (
609
- Value =>
626
+ Self.Project_Status.Set_Missing_Ada_Runtime
627
+ ( Value =>
610
628
(not Root.Is_Defined
611
629
or else Root.Language_Ids.Contains (GPR2.Ada_Language))
612
- and then not Self.Project_Tree.Has_Runtime_Project);
630
+ and then not Self.Project_Tree.Has_Runtime_Project);
613
631
end ;
614
632
615
633
Update_Project_Predefined_Sources (Self);
@@ -632,9 +650,10 @@ package body LSP.Ada_Handlers.Project_Loading is
632
650
else
633
651
declare
634
652
Provider : GPR2_Provider_And_Projects :=
635
- (Provider => Create_Project_Unit_Provider
636
- (Tree => Self.Project_Tree,
637
- Project => Self.Project_Tree.Root_Project),
653
+ (Provider =>
654
+ Create_Project_Unit_Provider
655
+ (Tree => Self.Project_Tree,
656
+ Project => Self.Project_Tree.Root_Project),
638
657
Projects => <>);
639
658
begin
640
659
Provider.Projects.Append (Self.Project_Tree.Root_Project);
@@ -645,7 +664,8 @@ package body LSP.Ada_Handlers.Project_Loading is
645
664
end if ;
646
665
end if ;
647
666
648
- Tracer.Trace (" Project status after loading: " & Self.Project_Status'Image);
667
+ Tracer.Trace
668
+ (" Project status after loading: " & Self.Project_Status'Image);
649
669
650
670
-- We have successfully loaded a real project: monitor the filesystem
651
671
-- for any changes on the sources of the project
@@ -660,9 +680,7 @@ package body LSP.Ada_Handlers.Project_Loading is
660
680
-- Enqueue_Indexing_Job --
661
681
-- ------------------------
662
682
663
- procedure Enqueue_Indexing_Job
664
- (Self : in out Message_Handler'Class)
665
- is
683
+ procedure Enqueue_Indexing_Job (Self : in out Message_Handler'Class) is
666
684
procedure Create_Fallback_Context (Self : in out Message_Handler'Class);
667
685
-- Create a fallback context for the given handler's contexts' set.
668
686
@@ -764,13 +782,12 @@ package body LSP.Ada_Handlers.Project_Loading is
764
782
-- Reload_Implicit_Project_Dirs --
765
783
-- --------------------------------
766
784
767
- procedure Reload_Implicit_Project_Dirs
768
- (Self : in out Message_Handler'Class)
785
+ procedure Reload_Implicit_Project_Dirs (Self : in out Message_Handler'Class)
769
786
is
770
787
Project : GPR2.Project.Tree.View_Builder.Object :=
771
- GPR2.Project.Tree.View_Builder.Create
772
- (Project_Dir => GPR2.Path_Name.Create_Directory (" ." ),
773
- Name => " default" );
788
+ GPR2.Project.Tree.View_Builder.Create
789
+ (Project_Dir => GPR2.Path_Name.Create_Directory (" ." ),
790
+ Name => " default" );
774
791
Values : GPR2.Containers.Value_List;
775
792
Opts : GPR2.Options.Object;
776
793
Success : Boolean;
@@ -785,15 +802,15 @@ package body LSP.Ada_Handlers.Project_Loading is
785
802
end loop ;
786
803
787
804
Project.Set_Attribute
788
- (GPR2.Project.Registry.Attribute.Source_Dirs,
789
- Values);
805
+ (GPR2.Project.Registry.Attribute.Source_Dirs, Values);
790
806
791
807
-- First we load the fallback project
792
- Success := Self.Project_Tree.Load_Virtual_View
793
- (Project,
794
- Opts,
795
- With_Runtime => True,
796
- Absent_Dir_Error => GPR2.No_Error);
808
+ Success :=
809
+ Self.Project_Tree.Load_Virtual_View
810
+ (Project,
811
+ Opts,
812
+ With_Runtime => True,
813
+ Absent_Dir_Error => GPR2.No_Error);
797
814
798
815
if not Success then
799
816
for C in Self.Project_Tree.Log_Messages.Iterate loop
@@ -818,7 +835,8 @@ package body LSP.Ada_Handlers.Project_Loading is
818
835
819
836
procedure Reload_Project (Self : in out Message_Handler'CLass) is
820
837
begin
821
- Tracer.Trace (" Reload_Project was called. Releasing current project context." );
838
+ Tracer.Trace
839
+ (" Reload_Project was called. Releasing current project context." );
822
840
Release_Contexts_And_Project_Info (Self);
823
841
Self.Project_Status := LSP.Ada_Project_Loading.No_Project_Status;
824
842
Ensure_Project_Loaded (Self);
@@ -828,8 +846,7 @@ package body LSP.Ada_Handlers.Project_Loading is
828
846
-- Reload_Implicit_Project --
829
847
-- ---------------------------
830
848
831
- procedure Reload_Implicit_Project
832
- (Self : in out Message_Handler'Class) is
849
+ procedure Reload_Implicit_Project (Self : in out Message_Handler'Class) is
833
850
begin
834
851
Load_Implicit_Project (Self, Self.Project_Status.Get_Load_Status);
835
852
end Reload_Implicit_Project ;
0 commit comments