Skip to content

Commit 40f66b7

Browse files
Fix completion for project-defined packages
When the user references an imported project before a '.', we should only return the packages that are actually defined in the referenced project, not all ones. For eng/ide/ada_language_server#1398
1 parent d551c90 commit 40f66b7

File tree

2 files changed

+17
-629
lines changed

2 files changed

+17
-629
lines changed

source/gpr/lsp-gpr_completions.adb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ package body LSP.GPR_Completions is
6666
Response : in out LSP.Structures.Completion_Result);
6767
-- Handle completion when cursor after "package" keyword or after a project
6868
-- reference.
69+
-- If Unexisting_Only is returned, only the packages that have not been
70+
-- defined in the given project file will be returned. Otherwise, only
71+
-- the package that have been defined will be returned.
6972

7073
procedure Fill_Type_Completion_Response
7174
(File : LSP.GPR_Files.File_Access;
@@ -242,8 +245,9 @@ package body LSP.GPR_Completions is
242245
for Id of PRP.All_Packages loop
243246
declare
244247
Item : LSP.Structures.CompletionItem;
248+
Exists_In_File : constant Boolean := File.In_Packages (Id);
245249
begin
246-
if (not File.In_Packages (Id) or else not Unexisting_Only)
250+
if (Unexisting_Only xor Exists_In_File)
247251
and then PRP.Is_Allowed_In (Id, Kind)
248252
and then VSS.Strings.Starts_With
249253
(To_Lower (VSS.Strings.To_Virtual_String

0 commit comments

Comments
 (0)