Skip to content

Commit 52fc04d

Browse files
author
mergerepo
committed
Merge remote branch 'origin/master' into edge
(no-precommit-check no-tn-check)
2 parents e981098 + cf9783f commit 52fc04d

File tree

6 files changed

+45
-7
lines changed

6 files changed

+45
-7
lines changed

source/ada/lsp-ada_documents.adb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,17 @@ package body LSP.Ada_Documents is
19591959
Recompute_Indexes (Self);
19601960
end Initialize;
19611961

1962+
-------------
1963+
-- Cleanup --
1964+
-------------
1965+
1966+
procedure Cleanup (Self : in out Document) is
1967+
begin
1968+
for Source of Self.Diagnostic_Sources loop
1969+
LSP.Diagnostic_Sources.Unchecked_Free (Source);
1970+
end loop;
1971+
end Cleanup;
1972+
19621973
------------------------
19631974
-- Reset_Symbol_Cache --
19641975
------------------------

source/ada/lsp-ada_documents.ads

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ package LSP.Ada_Documents is
5959
-- Create a new document from a TextDocumentItem. Use Diagnostic as
6060
-- project status diagnostic source.
6161

62+
procedure Cleanup (Self : in out Document);
63+
-- Free all the data associated to this document.
64+
6265
-----------------------
6366
-- Contents handling --
6467
-----------------------

source/ada/lsp-ada_handlers.adb

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,6 @@ package body LSP.Ada_Handlers is
174174
procedure Index_Files (Self : access Message_Handler);
175175
-- Index all loaded files in each context. Emit progresormation.
176176

177-
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
178-
(LSP.Ada_Documents.Document, Internal_Document_Access);
179-
180177
procedure Release_Contexts_And_Project_Info (Self : access Message_Handler);
181178
-- Release the memory associated to project information in Self
182179

@@ -528,20 +525,24 @@ package body LSP.Ada_Handlers is
528525
-- Cleanup --
529526
-------------
530527

531-
procedure Cleanup (Self : access Message_Handler) is
528+
procedure Cleanup (Self : access Message_Handler)
529+
is
532530
begin
533531
if Self.File_Monitor.Assigned then
534532
Self.File_Monitor.Stop_Monitoring_Directories;
535533
end if;
536534

537535
-- Cleanup documents
538536
for Document of Self.Open_Documents loop
539-
Unchecked_Free (Document);
537+
Free (Document);
540538
end loop;
541539
Self.Open_Documents.Clear;
542540

543541
-- Cleanup contexts, project and environment
544542
Self.Release_Contexts_And_Project_Info;
543+
544+
-- Free the file monitor
545+
LSP.File_Monitors.Unchecked_Free (Self.File_Monitor);
545546
end Cleanup;
546547

547548
-----------------------
@@ -2615,7 +2616,7 @@ package body LSP.Ada_Handlers is
26152616
Context.Flush_Document (File);
26162617
end loop;
26172618

2618-
Unchecked_Free (Document);
2619+
Free (Document);
26192620

26202621
else
26212622
-- We have received a didCloseTextDocument but the document was
@@ -3748,7 +3749,7 @@ package body LSP.Ada_Handlers is
37483749
(Document.all, Context.all, Pattern,
37493750
Canceled.Has_Been_Canceled'Access, Result.result);
37503751

3751-
Unchecked_Free (Internal_Document_Access (Document));
3752+
Free (Internal_Document_Access (Document));
37523753
end;
37533754
else
37543755
Self.Get_Symbols
@@ -5969,6 +5970,18 @@ package body LSP.Ada_Handlers is
59695970
end if;
59705971
end Publish_Diagnostics;
59715972

5973+
----------
5974+
-- Free --
5975+
----------
5976+
5977+
procedure Free (Self : in out Internal_Document_Access) is
5978+
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
5979+
(LSP.Ada_Documents.Document, Internal_Document_Access);
5980+
begin
5981+
Self.Cleanup;
5982+
Unchecked_Free (Self);
5983+
end Free;
5984+
59725985
------------------
59735986
-- Show_Message --
59745987
------------------

source/ada/lsp-ada_handlers.ads

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ private
113113

114114
type Internal_Document_Access is access all LSP.Ada_Documents.Document;
115115

116+
procedure Free (Self : in out Internal_Document_Access);
117+
-- Free all the data for the given document.
118+
116119
-- Container for documents indexed by URI
117120
package Document_Maps is new Ada.Containers.Hashed_Maps
118121
(Key_Type => GNATCOLL.VFS.Virtual_File,

source/ada/lsp-diagnostic_sources.ads

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
-- of the license. --
1616
------------------------------------------------------------------------------
1717

18+
with Ada.Unchecked_Deallocation;
1819
with LSP.Messages;
1920
limited with LSP.Ada_Contexts;
2021

@@ -38,4 +39,7 @@ package LSP.Diagnostic_Sources is
3839
-- Return True if diagnostic changed since last call to Get_Diagnostic or
3940
-- if Get_Diagnostic was never called and any diagnostic presents.
4041

42+
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
43+
(Diagnostic_Source'Class, Diagnostic_Source_Access);
44+
4145
end LSP.Diagnostic_Sources;

source/server/lsp-file_monitors.ads

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
-- This package provides a file monitoring service interface.
1919

2020
with GNATCOLL.VFS;
21+
with Ada.Unchecked_Deallocation;
2122

2223
package LSP.File_Monitors is
2324

@@ -43,4 +44,7 @@ package LSP.File_Monitors is
4344
-- Stop filesystem monitoring. This is a no-op if no monitoring is
4445
-- ongoing.
4546

47+
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
48+
(File_Monitor'Class, File_Monitor_Access);
49+
4650
end LSP.File_Monitors;

0 commit comments

Comments
 (0)