@@ -122,7 +122,6 @@ package body LSP.Ada_Definition is
122122 Manual_Fallback : Libadalang.Analysis.Defining_Name;
123123 Definition_Node : Libadalang.Analysis.Basic_Decl;
124124 Decl_For_Find_Overrides : Libadalang.Analysis.Basic_Decl;
125- Entry_Decl_Node : Libadalang.Analysis.Entry_Decl;
126125
127126 Ignore : Boolean;
128127 begin
@@ -186,7 +185,37 @@ package body LSP.Ada_Definition is
186185
187186 -- Search for accept statements only if we are on an entry
188187 if Definition_Node.Kind in Libadalang.Common.Ada_Entry_Decl_Range then
189- Entry_Decl_Node := Definition_Node.As_Entry_Decl;
188+ declare
189+ Entry_Decl_Node : constant Libadalang.Analysis.Entry_Decl :=
190+ Definition_Node.As_Entry_Decl;
191+ Entry_Parent_Node : constant Libadalang.Analysis.Basic_Decl :=
192+ Entry_Decl_Node.P_Parent_Basic_Decl;
193+ begin
194+ -- P_Accept_Stmts is only valid for entries declared in tasks
195+ if Entry_Parent_Node.Kind in
196+ Libadalang.Common.Ada_Task_Type_Decl_Range
197+ then
198+ for Accept_Node of Entry_Decl_Node.P_Accept_Stmts loop
199+ Self.Parent.Context.Append_Location
200+ (Self.Response,
201+ Self.Filter,
202+ Accept_Node.F_Body_Decl.F_Name);
203+ end loop ;
204+
205+ -- Others entries are are handled as simple subprograms
206+ else
207+ declare
208+ Other_Part_For_Decl : constant
209+ Libadalang.Analysis.Basic_Decl :=
210+ Laltools.Common.Find_Next_Part_For_Decl
211+ (Definition_Node, Trace);
212+ begin
213+ if not Other_Part_For_Decl.Is_Null then
214+ Other_Part := Other_Part_For_Decl.P_Defining_Name;
215+ end if ;
216+ end ;
217+ end if ;
218+ end ;
190219
191220 elsif Definition_Node.Kind in
192221 Libadalang.Common.Ada_Single_Task_Type_Decl_Range |
@@ -265,15 +294,6 @@ package body LSP.Ada_Definition is
265294 end loop ;
266295 end ;
267296 end if ;
268-
269- if not Entry_Decl_Node.Is_Null then
270- for Accept_Node of Entry_Decl_Node.P_Accept_Stmts loop
271- Self.Parent.Context.Append_Location
272- (Self.Response,
273- Self.Filter,
274- Accept_Node.F_Body_Decl.F_Name);
275- end loop ;
276- end if ;
277297 end Execute_Ada_Request ;
278298
279299end LSP.Ada_Definition ;
0 commit comments