@@ -1848,42 +1848,9 @@ package body LSP.Ada_Handlers is
18481848 begin
18491849 Self.Log_Method_In (" On_DidCreateFiles_Notification" );
18501850
1851- -- New sources were created on this project, so recompute its view
1852- Self.Project_Tree.Clear_Sources;
1853-
1854- -- For each created file of Value.files:
1855- -- - find the contexts that contains its directory
1856- -- - add it to those contexts
1857- -- - index it on those contexts
1858-
1859- for File of Value.files loop
1860- declare
1861- use VSS.Strings.Conversions;
1862-
1863- Created_File : constant GNATCOLL.VFS.Virtual_File :=
1864- Self.To_File (To_DocumentUri (File.uri));
1865-
1866- function Has_Dir
1867- (Context : LSP.Ada_Contexts.Context)
1868- return Boolean
1869- is (Context.List_Source_Directories.Contains
1870- (Created_File.Dir));
1871- -- Return True if Old_File is a source of the project held by
1872- -- Context.
1873-
1874- begin
1875- for Context of Self.Contexts.Each_Context
1876- (Has_Dir'Unrestricted_Access)
1877- loop
1878- Context.Include_File (Created_File);
1879- Context.Index_File (Created_File);
1880-
1881- Self.Tracer.Trace
1882- (" Included " & Created_File.Display_Base_Name
1883- & " in context " & To_UTF_8_String (Context.Id));
1884- end loop ;
1885- end ;
1886- end loop ;
1851+ -- LAL Contexts are not handling source updates so we need a full reload
1852+ -- to avoid caching issues.
1853+ Self.Reload_Project;
18871854
18881855 Self.Log_Method_Out (" On_DidCreateFiles_Notification" );
18891856 end On_DidCreateFiles_Notification ;
@@ -1898,34 +1865,9 @@ package body LSP.Ada_Handlers is
18981865 begin
18991866 Self.Log_Method_In (" On_DidDeleteFiles_Notification" );
19001867
1901- -- Some project sources were deleted, so recompute its view
1902- Self.Project_Tree.Clear_Sources;
1903-
1904- -- For each delete file of Value.files:
1905- -- - find the contexts that contains it
1906- -- - remove it from those contexts
1907- -- - re-index it on those contexts so that an empty unit is reparsed
1908-
1909- for File of Value.files loop
1910- declare
1911- Deleted_URI : constant LSP.Structures.DocumentUri :=
1912- To_DocumentUri (File.uri);
1913-
1914- Deleted_File : constant GNATCOLL.VFS.Virtual_File :=
1915- Self.To_File (Deleted_URI);
1916-
1917- begin
1918- for Context of Self.Contexts_For_File (Deleted_File) loop
1919- Context.Exclude_File (Deleted_File);
1920- Context.Index_File (Deleted_File);
1921-
1922- Self.Tracer.Trace
1923- (" Excluded " & Deleted_File.Display_Base_Name
1924- & " from context "
1925- & VSS.Strings.Conversions.To_UTF_8_String (Context.Id));
1926- end loop ;
1927- end ;
1928- end loop ;
1868+ -- LAL Contexts are not handling source updates so we need a full reload
1869+ -- to avoid caching issues.
1870+ Self.Reload_Project;
19291871
19301872 Self.Log_Method_Out (" On_DidDeleteFiles_Notification" );
19311873 end On_DidDeleteFiles_Notification ;
@@ -1995,100 +1937,13 @@ package body LSP.Ada_Handlers is
19951937
19961938 overriding procedure On_DidRenameFiles_Notification
19971939 (Self : in out Message_Handler;
1998- Value : LSP.Structures.RenameFilesParams)
1999- is
2000- use LSP.Ada_Context_Sets;
2001-
2002- package URI_Contexts_Maps is new
2003- Ada.Containers.Hashed_Maps
2004- (Key_Type => LSP.Structures.DocumentUri,
2005- Element_Type => Context_Lists.List,
2006- Hash => LSP.Structures.Get_Hash,
2007- Equivalent_Keys => LSP.Structures." =" ,
2008- " =" => Context_Lists." =" );
2009-
2010- subtype URI_Contexts_Map is URI_Contexts_Maps.Map;
2011-
2012- URIs_Contexts : URI_Contexts_Map;
2013-
1940+ Value : LSP.Structures.RenameFilesParams) is
20141941 begin
20151942 Self.Log_Method_In (" On_DidRenameFiles_Notification" );
20161943
2017- -- Some project sources were renamed, so recompute its view
2018- Self.Project_Tree.Clear_Sources;
2019-
2020- -- For each oldUri of Value.files:
2021- -- - map it to a list of context that contains it
2022- -- - remove it from those contexts
2023- -- - re-index it on those contexts so that an empty unit is reparsed
2024-
2025- for File_Rename of Value.files loop
2026- declare
2027- use VSS.Strings.Conversions;
2028-
2029- Old_URI : constant LSP.Structures.DocumentUri :=
2030- To_DocumentUri (File_Rename.oldUri);
2031-
2032- Old_File : constant GNATCOLL.VFS.Virtual_File :=
2033- Self.To_File (Old_URI);
2034-
2035- URI_Contexts : Context_Lists.List;
2036-
2037- begin
2038- for Context of Self.Contexts_For_File (Old_File) loop
2039- URI_Contexts.Append (Context);
2040- Context.Exclude_File (Old_File);
2041- Context.Index_File (Old_File);
2042-
2043- Self.Tracer.Trace
2044- (" Excluded " & Old_File.Display_Full_Name
2045- & " from context " & To_UTF_8_String (Context.Id));
2046- end loop ;
2047-
2048- URIs_Contexts.Insert (Old_URI, URI_Contexts);
2049- end ;
2050- end loop ;
2051-
2052- -- For each (oldUri, newUri) tuple:
2053- -- - add newUri to all contexts that contained oldUri
2054- -- - index the newUri (using the appriate method depending if
2055- -- (there's an open document of not)
2056-
2057- for File_Rename of Value.files loop
2058- declare
2059- use VSS.Strings.Conversions;
2060- use type LSP.Ada_Documents.Document_Access;
2061-
2062- New_URI : constant LSP.Structures.DocumentUri :=
2063- To_DocumentUri (File_Rename.newUri);
2064-
2065- Old_URI : constant LSP.Structures.DocumentUri :=
2066- To_DocumentUri (File_Rename.oldUri);
2067-
2068- New_File : constant GNATCOLL.VFS.Virtual_File :=
2069- Self.To_File (New_URI);
2070-
2071- Document : constant LSP.Ada_Documents.Document_Access :=
2072- Get_Open_Document (Self, New_URI);
2073-
2074- Is_Document_Open : constant Boolean := Document /= null ;
2075-
2076- begin
2077- for Context of URIs_Contexts (Old_URI) loop
2078- Context.Include_File (New_File);
2079-
2080- if Is_Document_Open then
2081- Context.Index_Document (Document.all );
2082- else
2083- Context.Index_File (New_File);
2084- end if ;
2085-
2086- Self.Tracer.Trace
2087- (" Included " & New_File.Display_Base_Name & " in context "
2088- & To_UTF_8_String (Context.Id));
2089- end loop ;
2090- end ;
2091- end loop ;
1944+ -- LAL Contexts are not handling source updates so we need a full reload
1945+ -- to avoid caching issues.
1946+ Self.Reload_Project;
20921947
20931948 Self.Log_Method_Out (" On_DidRenameFiles_Notification" );
20941949 end On_DidRenameFiles_Notification ;
0 commit comments