Skip to content

Commit 9b0a7f5

Browse files
committed
Monitor the filesystem for changes in all source dirs
... Rather than only monitorint the source dirs for projects that are not externally built. This will provide a slightly better experience, as it will allow the language server to react to the new installation of dependencies for the working project. This is also an opportunity for code simplification, as we were maintaining a separate list of source directories just for this purpose. Implements #1584.
1 parent b4a99ff commit 9b0a7f5

File tree

5 files changed

+13
-43
lines changed

5 files changed

+13
-43
lines changed

source/ada/lsp-ada_context_sets.adb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,16 +164,12 @@ package body LSP.Ada_Context_Sets is
164164
----------------------------
165165

166166
function All_Source_Directories
167-
(Self : Context_Set'Class;
168-
Include_Externally_Built : Boolean := False)
169-
return GNATCOLL.VFS.File_Array
167+
(Self : Context_Set'Class) return GNATCOLL.VFS.File_Array
170168
is
171169
Consolidated_Set : LSP.Ada_File_Sets.File_Sets.Set;
172170
begin
173171
for C of Self.Contexts loop
174-
Consolidated_Set.Union
175-
(C.List_Source_Directories
176-
(Include_Externally_Built => Include_Externally_Built));
172+
Consolidated_Set.Union (C.List_Source_Directories);
177173
end loop;
178174

179175
declare

source/ada/lsp-ada_context_sets.ads

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ package LSP.Ada_Context_Sets is
5858
-- Number of files in all contexts
5959

6060
function All_Source_Directories
61-
(Self : Context_Set'Class;
62-
Include_Externally_Built : Boolean := False)
63-
return GNATCOLL.VFS.File_Array;
61+
(Self : Context_Set'Class) return GNATCOLL.VFS.File_Array;
6462
-- Return the list of all source directories for writable projects in the
6563
-- context, including externally built projects' source directories when
6664
-- Include_Externally_Built is set to True.

source/ada/lsp-ada_contexts.adb

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -158,22 +158,6 @@ package body LSP.Ada_Contexts is
158158
return Source_Units;
159159
end Analysis_Units;
160160

161-
-----------------------------
162-
-- List_Source_Directories --
163-
-----------------------------
164-
165-
function List_Source_Directories
166-
(Self : Context;
167-
Include_Externally_Built : Boolean := False)
168-
return LSP.Ada_File_Sets.File_Sets.Set is
169-
begin
170-
if Include_Externally_Built then
171-
return Self.Source_Dirs.Union (Self.External_Source_Dirs);
172-
else
173-
return Self.Source_Dirs;
174-
end if;
175-
end List_Source_Directories;
176-
177161
----------------------------
178162
-- List_Source_Externsion --
179163
----------------------------
@@ -685,15 +669,9 @@ package body LSP.Ada_Contexts is
685669

686670
procedure Add_Dirs_From_View (View : GPR2.Project.View.Object) is
687671
begin
688-
if View.Is_Externally_Built then
689-
for Dir of View.Source_Directories loop
690-
Self.External_Source_Dirs.Include (Dir.Virtual_File);
691-
end loop;
692-
else
693-
for Dir of View.Source_Directories loop
694-
Self.Source_Dirs.Include (Dir.Virtual_File);
695-
end loop;
696-
end if;
672+
for Dir of View.Source_Directories loop
673+
Self.Source_Dirs.Include (Dir.Virtual_File);
674+
end loop;
697675
end Add_Dirs_From_View;
698676

699677
begin
@@ -702,7 +680,6 @@ package body LSP.Ada_Contexts is
702680
Process_Closure (Root, Add_Sources_From_View'Access);
703681

704682
Self.Source_Dirs.Clear;
705-
Self.External_Source_Dirs.Clear;
706683

707684
Process_Closure (Root, Add_Dirs_From_View'Access);
708685

source/ada/lsp-ada_contexts.ads

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ package LSP.Ada_Contexts is
205205
-- Return the analysis units for all Ada sources known to this context
206206

207207
function List_Source_Directories
208-
(Self : Context; Include_Externally_Built : Boolean := False)
209-
return LSP.Ada_File_Sets.File_Sets.Set;
208+
(Self : Context) return LSP.Ada_File_Sets.File_Sets.Set;
210209
-- List the source directories, including externally built projects' source
211210
-- directories when Include_Externally_Built is set to True.
212211

@@ -325,12 +324,9 @@ private
325324
-- Cache for the list of Ada source files in the loaded project tree.
326325

327326
Source_Dirs : LSP.Ada_File_Sets.File_Sets.Set;
328-
-- All the source dirs in the loaded project, not including
327+
-- All the source dirs in the loaded project, including
329328
-- the externally built projects
330329

331-
External_Source_Dirs : LSP.Ada_File_Sets.File_Sets.Set;
332-
-- All the source dirs coming from externally built projects
333-
334330
Extension_Set : LSP.Ada_File_Sets.Extension_Sets.Set;
335331
-- All the ada extensions valid for the current project
336332

@@ -359,6 +355,10 @@ private
359355
return LSP.Ada_File_Sets.File_Sets.Set_Iterator_Interfaces
360356
.Reversible_Iterator'Class is (Self.Source_Files.Iterate);
361357

358+
function List_Source_Directories
359+
(Self : Context) return LSP.Ada_File_Sets.File_Sets.Set
360+
is (Self.Source_Dirs);
361+
362362
function File_Count (Self : Context) return Natural
363363
is (Self.Source_Files.Length);
364364

source/ada/lsp-ada_handlers-source_dirs_commands.adb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ package body LSP.Ada_Handlers.Source_Dirs_Commands is
5656
end Append;
5757

5858
Source_Dirs : constant GNATCOLL.VFS.File_Array :=
59-
Handler.Contexts.All_Source_Directories
60-
(Include_Externally_Built => True);
59+
Handler.Contexts.All_Source_Directories;
6160
begin
6261
Response := (Is_Null => False, Value => <>);
6362
Append ((Kind => VSS.JSON.Streams.Start_Array));

0 commit comments

Comments
 (0)