Skip to content

Commit 18357f1

Browse files
committed
Perform project loading right after initialization
1 parent 21e0992 commit 18357f1

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

source/ada/lsp-ada_handlers.adb

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2537,30 +2537,27 @@ package body LSP.Ada_Handlers is
25372537
(Self : in out Message_Handler;
25382538
Value : LSP.Structures.InitializedParams) is
25392539
begin
2540-
-- The client is notifying us that it has initialized. If a project was
2541-
-- provided with the initialize request, we can load it and start
2542-
-- communicating with the client.
2540+
-- The client is notifying us that it has initialized. It is good at
2541+
-- this stage to load a project so that subsequent requests, e.g.
2542+
-- project attribute requests to support VS Code integration, work on a
2543+
-- valid project.
25432544
--
2544-
-- We only perform loading in case ada.projectFile was provided with the
2545-
-- initialize request. That's because some clients don't provide
2546-
-- settings in the initialize request, and instead send a
2547-
-- onDidChangeConfiguration notification immediately after
2548-
-- initialization. In this scenario, loading a project unconditionally
2549-
-- here would result in automatically searching for a project (unique
2550-
-- project at the root, or implicit fallback) and loading it, only to
2551-
-- load another project shortly after, upon receiving
2552-
-- onDidChangeConfiguration. To avoid the first useless load, we only
2553-
-- load a project here if it was specified in the initialize request.
2554-
--
2555-
-- Moreover, there is an impact on legacy tests. The prior project
2545+
-- However, there is an impact on legacy tests. The prior project
25562546
-- loading policy was to wait for the first onDidChangeConfiguration
25572547
-- notification to obtain settings and load a project. Many existing
25582548
-- tests do not set the project in the initialize request and don't
25592549
-- expect messages pertaining to project loading after the initialize
2560-
-- request. If we were to always load the project here, tests would
2561-
-- receive different messages and potentially fail. So the conditional
2562-
-- project loading here is backwards compatible with existing tests.
2563-
if not Self.Configuration.Project_File.Is_Empty then
2550+
-- request. If we were to always load the project here, tests would
2551+
-- receive different messages and potentially fail.
2552+
--
2553+
-- To mitigate that, we perform project loading conditionally to
2554+
-- Base_Configuration_Received. If Base_Configuration_Received is True,
2555+
-- it means that we received non-empty initializationOptions which is
2556+
-- the typical case in IDEs like GNAT Studio and VS Code.
2557+
--
2558+
-- This conditional load allows us to load a project early while
2559+
-- remaining backwards compatible with legacy tests.
2560+
if Self.Base_Configuration_Received then
25642561
LSP.Ada_Handlers.Project_Loading.Ensure_Project_Loaded (Self);
25652562
end if;
25662563
end On_Initialized_Notification;

0 commit comments

Comments
 (0)