Skip to content

Commit 1f91789

Browse files
Merge branch 'topic/als.1272.unsafe_update_sources' into 'master'
Fix unsafe call to Update_Sources See merge request eng/ide/ada_language_server!1513
2 parents a71256c + efb6c22 commit 1f91789

File tree

8 files changed

+829
-0
lines changed

8 files changed

+829
-0
lines changed

source/ada/lsp-ada_handlers-project_loading.adb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,11 @@ package body LSP.Ada_Handlers.Project_Loading is
423423
Build_Path => Project_Environment.Build_Path,
424424
Environment => Environment);
425425

426+
if Self.Project_Tree.Are_Sources_Loaded then
427+
-- Update_Sources can't be called when the sources are already
428+
-- loaded
429+
Self.Project_Tree.Invalidate_Sources;
430+
end if;
426431
Self.Project_Tree.Update_Sources (With_Runtime => True);
427432

428433
exception
@@ -687,6 +692,10 @@ package body LSP.Ada_Handlers.Project_Loading is
687692
Project => Project,
688693
Context => GPR2.Context.Empty);
689694

695+
if Self.Project_Tree.Are_Sources_Loaded then
696+
-- Update_Sources can't be called when the sources are already loaded
697+
Self.Project_Tree.Invalidate_Sources;
698+
end if;
690699
Self.Project_Tree.Update_Sources (With_Runtime => True);
691700

692701
exception

source/ada/lsp-ada_handlers.adb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,6 +2295,10 @@ package body LSP.Ada_Handlers is
22952295

22962296
-- New sources were created on this project, so recompute its view
22972297

2298+
if Self.Project_Tree.Are_Sources_Loaded then
2299+
-- Update_Sources can't be called when the sources are already loaded
2300+
Self.Project_Tree.Invalidate_Sources;
2301+
end if;
22982302
Self.Project_Tree.Update_Sources (With_Runtime => True);
22992303

23002304
-- For each created file of Value.files:
@@ -2346,6 +2350,10 @@ package body LSP.Ada_Handlers is
23462350

23472351
-- Some project sources were deleted, so recompute its view
23482352

2353+
if Self.Project_Tree.Are_Sources_Loaded then
2354+
-- Update_Sources can't be called when the sources are already loaded
2355+
Self.Project_Tree.Invalidate_Sources;
2356+
end if;
23492357
Self.Project_Tree.Update_Sources (With_Runtime => True);
23502358

23512359
-- For each delete file of Value.files:
@@ -2461,6 +2469,10 @@ package body LSP.Ada_Handlers is
24612469

24622470
-- Some project sources were renamed, so recompute its view
24632471

2472+
if Self.Project_Tree.Are_Sources_Loaded then
2473+
-- Update_Sources can't be called when the sources are already loaded
2474+
Self.Project_Tree.Invalidate_Sources;
2475+
end if;
24642476
Self.Project_Tree.Update_Sources (With_Runtime => True);
24652477

24662478
-- For each oldUri of Value.files:
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package Foo.Bar1 is
2+
procedure N is null;
3+
end Foo.Bar1;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package Foo is
2+
procedure Do_Nothing is null;
3+
end Foo;
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
with Foo.Bar1;
2+
3+
procedure Main is
4+
begin
5+
Foo.Bar1.N;
6+
end Main;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
project Test is
2+
for Main use ("main.adb");
3+
end Test;

0 commit comments

Comments
 (0)