@@ -38,6 +38,7 @@ with Langkit_Support.Slocs;
38
38
with Utils.Command_Lines.Common ;
39
39
40
40
with Pp.Actions ;
41
+ with Langkit_Support.Text ;
41
42
42
43
package body LSP.Ada_Contexts is
43
44
@@ -47,6 +48,31 @@ package body LSP.Ada_Contexts is
47
48
48
49
use type Libadalang.Analysis.Analysis_Unit;
49
50
51
+ type LSP_Context_Event_Handler_Type
52
+ is new Libadalang.Analysis.Event_Handler_Interface with record
53
+ Trace : Trace_Handle;
54
+ end record ;
55
+ -- LAL event handler used to log units that have notbeen found when
56
+ -- requested.
57
+
58
+ overriding procedure Unit_Requested_Callback
59
+ (Self : in out LSP_Context_Event_Handler_Type;
60
+ Context : Libadalang.Analysis.Analysis_Context'Class;
61
+ Name : Langkit_Support.Text.Text_Type;
62
+ From : Libadalang.Analysis.Analysis_Unit'Class;
63
+ Found : Boolean;
64
+ Is_Not_Found_Error : Boolean);
65
+
66
+ overriding procedure Unit_Parsed_Callback
67
+ (Self : in out LSP_Context_Event_Handler_Type;
68
+ Context : Libadalang.Analysis.Analysis_Context'Class;
69
+ Unit : Libadalang.Analysis.Analysis_Unit'Class;
70
+ Reparsed : Boolean)
71
+ is null ;
72
+
73
+ overriding procedure Release (Self : in out LSP_Context_Event_Handler_Type)
74
+ is null ;
75
+
50
76
function Get_Charset (Self : Context'Class) return String;
51
77
-- Return the charset with which the context was initialized
52
78
@@ -83,6 +109,25 @@ package body LSP.Ada_Contexts is
83
109
-- Options that are explicitly specified in the .gpr file take precedence
84
110
-- over LSP options.
85
111
112
+ -- ---------------------------
113
+ -- Unit_Requested_Callback --
114
+ -- ---------------------------
115
+
116
+ overriding procedure Unit_Requested_Callback
117
+ (Self : in out LSP_Context_Event_Handler_Type;
118
+ Context : Libadalang.Analysis.Analysis_Context'Class;
119
+ Name : Langkit_Support.Text.Text_Type;
120
+ From : Libadalang.Analysis.Analysis_Unit'Class;
121
+ Found : Boolean;
122
+ Is_Not_Found_Error : Boolean) is
123
+ begin
124
+ if not Found then
125
+ Self.Trace.Trace
126
+ (" Failed to request the following unit: "
127
+ & Langkit_Support.Text.To_UTF8 (Name));
128
+ end if ;
129
+ end Unit_Requested_Callback ;
130
+
86
131
-- -----------------------
87
132
-- Append_Declarations --
88
133
-- -----------------------
@@ -757,6 +802,9 @@ package body LSP.Ada_Contexts is
757
802
Env => Get_Environment (Root),
758
803
Is_Project_Owner => False);
759
804
805
+ Self.Event_Handler := Libadalang.Analysis.Create_Event_Handler_Reference
806
+ (LSP_Context_Event_Handler_Type'(Trace => Self.Trace));
807
+
760
808
Self.Reload;
761
809
Update_Source_Files;
762
810
Pretty_Printer_Setup;
0 commit comments