diff --git a/source/ada/lsp-ada_handlers-project_diagnostics.adb b/source/ada/lsp-ada_handlers-project_diagnostics.adb index 63e3d5b61..57898092d 100644 --- a/source/ada/lsp-ada_handlers-project_diagnostics.adb +++ b/source/ada/lsp-ada_handlers-project_diagnostics.adb @@ -15,36 +15,54 @@ -- of the license. -- ------------------------------------------------------------------------------ +with GPR2.Source_Reference; +with GPR2.Message; +with GPR2.Path_Name; + with VSS.Strings; with LSP.Enumerations; +with LSP.Utils; package body LSP.Ada_Handlers.Project_Diagnostics is - Single_Project_Found_Message : constant VSS.Strings.Virtual_String := - VSS.Strings.To_Virtual_String - ("Unique project in root directory was found and " & - "loaded, but it wasn't explicitly configured."); - - No_Runtime_Found_Message : constant VSS.Strings.Virtual_String := - VSS.Strings.To_Virtual_String - ("The project was loaded, but no Ada runtime found. " & - "Please check the installation of the Ada compiler."); - - No_Project_Found_Message : constant VSS.Strings.Virtual_String := - VSS.Strings.To_Virtual_String - ("No project found in root directory. " & - "Please create a project file and add it to the configuration."); + Project_Loading_Status_Messages : constant array (Load_Project_Status) + of VSS.Strings.Virtual_String := + (Single_Project_Found => + VSS.Strings.To_Virtual_String + ("Unique project in root directory was found and " + & "loaded, but it wasn't explicitly configured."), + No_Runtime_Found => + VSS.Strings.To_Virtual_String + ("The project was loaded, but no Ada runtime found. " + & "Please check the installation of the Ada compiler."), + No_Project_Found => + VSS.Strings.To_Virtual_String + ("No project found in root directory. " + & "Please create a project file and add it to the " + & "configuration."), + Multiple_Projects_Found => + VSS.Strings.To_Virtual_String + ("No project was loaded, because more than one " + & "project file has been found in the root directory. " + & "Please change configuration to point a correct project " + & "file."), + Invalid_Project_Configured => + VSS.Strings.To_Virtual_String + ("Project file has errors and can't be loaded."), + others => VSS.Strings.Empty_Virtual_String); + -- The diagnostics' messages depending on the project loading status. - Multiple_Projects_Found_Message : constant VSS.Strings.Virtual_String := - VSS.Strings.To_Virtual_String - ("No project was loaded, because more than one project file has been " & - "found in the root directory. Please change configuration to point " & - "a correct project file."); - - Invalid_Project_Configured_Message : constant VSS.Strings.Virtual_String := - VSS.Strings.To_Virtual_String - ("Project file has error and can't be loaded."); + Project_Loading_Status_Severities : constant array (Load_Project_Status) + of LSP.Enumerations.DiagnosticSeverity := + (Valid_Project_Configured => LSP.Enumerations.Hint, + Alire_Project => LSP.Enumerations.Hint, + Single_Project_Found => LSP.Enumerations.Hint, + No_Runtime_Found => LSP.Enumerations.Warning, + Multiple_Projects_Found => LSP.Enumerations.Error, + No_Project_Found => LSP.Enumerations.Error, + Invalid_Project_Configured => LSP.Enumerations.Error); + -- The diagnostics' severities depending on the project loading status. -------------------- -- Get_Diagnostic -- @@ -55,33 +73,124 @@ package body LSP.Ada_Handlers.Project_Diagnostics is Context : LSP.Ada_Contexts.Context; Errors : out LSP.Structures.Diagnostic_Vector) is - Item : LSP.Structures.Diagnostic; + use LSP.Structures; + + Parent_Diagnostic : LSP.Structures.Diagnostic; + GPR2_Messages : GPR2.Log.Object renames + Self.Handler.Project_Status.GPR2_Messages; + + procedure Create_Project_Loading_Diagnostic; + -- Create a parent diagnostic for the project loading status. + + procedure Append_GPR2_Diagnostics; + -- Append the GPR2 messages to the given parent diagnostic, if any. + + --------------------------------------- + -- Create_Project_Loading_Diagnostic -- + --------------------------------------- + + procedure Create_Project_Loading_Diagnostic is + Sloc : constant LSP.Structures.A_Range := + (start => (0, 0), + an_end => (0, 0)); + begin + -- Initialize the parent diagnostic. + Parent_Diagnostic.a_range := ((0, 0), (0, 0)); + Parent_Diagnostic.source := "project"; + Parent_Diagnostic.severity := + (True, Project_Loading_Status_Severities (Self.Last_Status)); + + -- If we don't have any GPR2 messages, display the project loading + -- status message in the parent diagnostic directly. + -- Otherwise display a generic message in the parent amnd append it + -- to its children, along with the other GPR2 messages. + if GPR2_Messages.Is_Empty then + Parent_Diagnostic.message := Project_Loading_Status_Messages + (Self.Last_Status); + else + declare + Project_File : GNATCOLL.VFS.Virtual_File renames + Self.Handler.Project_Status.Project_File; + URI : constant LSP.Structures.DocumentUri := + Self.Handler.To_URI + (Project_File.Display_Full_Name); + begin + Parent_Diagnostic.message := "Project Problems"; + Parent_Diagnostic.relatedInformation.Append + (LSP.Structures.DiagnosticRelatedInformation' + (location => + LSP.Structures.Location' + (uri => URI, a_range => Sloc, + others => <>), + message => + Project_Loading_Status_Messages + (Self.Last_Status))); + end; + end if; + end Create_Project_Loading_Diagnostic; + + ----------------------------- + -- Append_GPR2_Diagnostics -- + ----------------------------- + + procedure Append_GPR2_Diagnostics is + use GPR2.Message; + use LSP.Enumerations; + begin + for Msg of GPR2_Messages loop + if Msg.Level in GPR2.Message.Warning .. GPR2.Message.Error then + declare + Sloc : constant GPR2.Source_Reference.Object := + GPR2.Message.Sloc (Msg); + File : constant GPR2.Path_Name.Object := + (if Sloc.Is_Defined and then Sloc.Has_Source_Reference then + GPR2.Path_Name.Create_File + (GPR2.Filename_Type (Sloc.Filename)) + else + Self.Handler.Project_Tree.Root_Path); + begin + Parent_Diagnostic.relatedInformation.Append + (LSP .Structures.DiagnosticRelatedInformation' + (location => LSP.Structures.Location' + (uri => LSP.Utils.To_URI (File), + a_range => LSP.Utils.To_Range (Sloc), + others => <>), + message => VSS.Strings.Conversions.To_Virtual_String + (Msg.Message))); + end; + + -- If we have one error in the GPR2 messages, the parent + -- diagnostic's severity should be "error" too, otherwise + -- "warning". + if Msg.Level = GPR2.Message.Error then + Parent_Diagnostic.severity := + (True, LSP.Enumerations.Error); + elsif Parent_Diagnostic.severity.Value /= + LSP.Enumerations.Error + then + Parent_Diagnostic.severity := + (True, LSP.Enumerations.Warning); + end if; + end if; + end loop; + end Append_GPR2_Diagnostics; + begin - Self.Last_Status := Self.Handler.Project_Status; - Item.a_range := ((0, 0), (0, 0)); - Item.source := "project"; - Item.severity := (True, LSP.Enumerations.Error); - - case Self.Last_Status is - when Valid_Project_Configured | Alire_Project => - null; - when No_Runtime_Found => - Item.message := No_Runtime_Found_Message; - Errors.Append (Item); - when Single_Project_Found => - Item.message := Single_Project_Found_Message; - Item.severity := (True, LSP.Enumerations.Hint); - Errors.Append (Item); - when No_Project_Found => - Item.message := No_Project_Found_Message; - Errors.Append (Item); - when Multiple_Projects_Found => - Item.message := Multiple_Projects_Found_Message; - Errors.Append (Item); - when Invalid_Project_Configured => - Item.message := Invalid_Project_Configured_Message; - Errors.Append (Item); - end case; + Self.Last_Status := Self.Handler.Project_Status.Load_Status; + + -- If we have a valid project return immediately: we want to display + -- diagnostics only if there is an issue to solve or a potential + -- enhancement. + if Self.Last_Status = Valid_Project_Configured + or else (Self.Last_Status = Alire_Project and then GPR2_Messages.Is_Empty) + then + return; + end if; + + Create_Project_Loading_Diagnostic; + Append_GPR2_Diagnostics; + + Errors.Append (Parent_Diagnostic); end Get_Diagnostic; ------------------------ @@ -95,7 +204,9 @@ package body LSP.Ada_Handlers.Project_Diagnostics is is pragma Unreferenced (Context); begin - return Self.Last_Status /= Self.Handler.Project_Status; + return + (Self.Last_Status /= Self.Handler.Project_Status.Load_Status + or else not Self.Handler.Project_Status.GPR2_Messages.Is_Empty); end Has_New_Diagnostic; end LSP.Ada_Handlers.Project_Diagnostics; diff --git a/source/ada/lsp-ada_handlers-project_diagnostics.ads b/source/ada/lsp-ada_handlers-project_diagnostics.ads index 638f795e4..760c9a997 100644 --- a/source/ada/lsp-ada_handlers-project_diagnostics.ads +++ b/source/ada/lsp-ada_handlers-project_diagnostics.ads @@ -39,7 +39,7 @@ private type Diagnostic_Source (Handler : not null access LSP.Ada_Handlers.Message_Handler) is limited new LSP.Diagnostic_Sources.Diagnostic_Source with record - Last_Status : Load_Project_Status := Valid_Project_Configured; + Last_Status : Load_Project_Status := No_Project_Found; end record; end LSP.Ada_Handlers.Project_Diagnostics; diff --git a/source/ada/lsp-ada_handlers-project_loading.adb b/source/ada/lsp-ada_handlers-project_loading.adb index 304e6d430..459e6ca14 100644 --- a/source/ada/lsp-ada_handlers-project_loading.adb +++ b/source/ada/lsp-ada_handlers-project_loading.adb @@ -22,14 +22,12 @@ with GPR2.Context; with GPR2.Path_Name; with GPR2.Project.View; with GPR2.Containers; -with GPR2.Message; with GPR2.Project.Registry.Attribute; with GPR2.Project.Source.Set; with GPR2.Project.Tree.View_Builder; with Libadalang.Preprocessing; -with VSS.Characters.Latin; with VSS.Strings.Conversions; with VSS.String_Vectors; @@ -44,6 +42,7 @@ with LSP.Enumerations; with LSP.Structures; with URIs; +with LSP.Ada_Documents; use LSP.Ada_Documents; package body LSP.Ada_Handlers.Project_Loading is @@ -92,6 +91,12 @@ package body LSP.Ada_Handlers.Project_Loading is (VSS.Strings.Conversions.To_Virtual_String (Value.Display_Full_Name)); -- Cast Virtual_File to Virtual_String + function To_Virtual_File + (Value : VSS.Strings.Virtual_String) return GNATCOLL.VFS.Virtual_File is + (GNATCOLL.VFS.Create_From_UTF8 + (VSS.Strings.Conversions.To_UTF_8_String (Value))); + -- Cast Virtual_String to Virtual_File + function Root (Self : Message_Handler'Class) return GNATCOLL.VFS.Virtual_File; -- Return the root directory of the client workspace @@ -106,8 +111,6 @@ package body LSP.Ada_Handlers.Project_Loading is --------------------------- procedure Ensure_Project_Loaded (Self : in out Message_Handler'Class) is - use type VSS.Strings.Virtual_String; - GPRs_Found : Natural := 0; Project_File : VSS.Strings.Virtual_String; @@ -165,23 +168,12 @@ package body LSP.Ada_Handlers.Project_Loading is Self.Tracer.Trace_Text (Project_File); Load_Project - (Self, - Project_File, - Self.Configuration.Scenario_Variables, - GPR2.Environment.Process_Environment, - "iso-8859-1", - Single_Project_Found); + (Self => Self, Project_Path => Project_File, + Scenario => Self.Configuration.Scenario_Variables, + Environment => GPR2.Environment.Process_Environment, + Charset => "iso-8859-1", + Status => Single_Project_Found); else - -- We have found more than one project: warn the user! - - Self.Sender.On_ShowMessage_Notification - ((a_type => LSP.Enumerations.Error, - message => - "More than one .gpr found." - & VSS.Characters.Latin.Line_Feed - & "Note: you can configure a project " - & " through the ada.projectFile setting.")); - Load_Implicit_Project (Self, Multiple_Projects_Found); end if; end Ensure_Project_Loaded; @@ -204,7 +196,7 @@ package body LSP.Ada_Handlers.Project_Loading is begin Self.Tracer.Trace ("Loading the implicit project"); - Self.Project_Status := Status; + Self.Project_Status.Load_Status := Status; Release_Contexts_And_Project_Info (Self); C.Initialize @@ -250,7 +242,7 @@ package body LSP.Ada_Handlers.Project_Loading is procedure Load_Project (Self : in out Message_Handler'Class; - Project_File : VSS.Strings.Virtual_String; + Project_Path : VSS.Strings.Virtual_String; Scenario : LSP.Ada_Configurations.Variable_List; Environment : GPR2.Environment.Object; Charset : VSS.Strings.Virtual_String; @@ -258,42 +250,20 @@ package body LSP.Ada_Handlers.Project_Loading is is use type GNATCOLL.VFS.Virtual_File; - Message : LSP.Structures.ShowMessageParams; - Errors : VSS.String_Vectors.Virtual_String_Vector; - Warnings : VSS.String_Vectors.Virtual_String_Vector; + Project_File : GNATCOLL.VFS.Virtual_File := + To_Virtual_File (Project_Path); - procedure Create_Context_For_Non_Aggregate - (View : GPR2.Project.View.Object); - - procedure Append_Errors; + Project_Environment : Project_Loading.Environment; - function To_Virtual_File (Value : VSS.Strings.Virtual_String) - return GNATCOLL.VFS.Virtual_File is - (GNATCOLL.VFS.Create_From_UTF8 - (VSS.Strings.Conversions.To_UTF_8_String (Value))); - -- Cast Virtual_String to Virtual_File + Relocate_Build_Tree : constant GNATCOLL.VFS.Virtual_File := + To_Virtual_File (Self.Configuration.Relocate_Build_Tree); - ------------------- - -- Append_Errors -- - ------------------- + Root_Dir : constant GNATCOLL.VFS.Virtual_File := + To_Virtual_File (Self.Configuration.Relocate_Root); - procedure Append_Errors is - begin - for Message of Self.Project_Tree.Log_Messages.all loop - case Message.Level is - when GPR2.Message.Error => - Errors.Append - (VSS.Strings.Conversions.To_Virtual_String - (Message.Format)); - when GPR2.Message.Warning => - Warnings.Append - (VSS.Strings.Conversions.To_Virtual_String - (Message.Format)); - when others => - null; - end case; - end loop; - end Append_Errors; + procedure Create_Context_For_Non_Aggregate + (View : GPR2.Project.View.Object); + -- Create a new context for the given project view. -------------------------------------- -- Create_Context_For_Non_Aggregate -- @@ -305,7 +275,8 @@ package body LSP.Ada_Handlers.Project_Loading is use LSP.Ada_Context_Sets; use LSP.Ada_Contexts; - C : constant Context_Access := new Context (Self.Tracer); + C : constant Context_Access := + new Context (Self.Tracer); Reader : LSP.Ada_Handlers.File_Readers.LSP_File_Reader (Self'Unchecked_Access); @@ -364,43 +335,32 @@ package body LSP.Ada_Handlers.Project_Loading is Self.Contexts.Prepend (C); end Create_Context_For_Non_Aggregate; - GPR : GNATCOLL.VFS.Virtual_File := - To_Virtual_File (Project_File); - - Project_Environment : Project_Loading.Environment; - - Relocate_Build_Tree : constant GNATCOLL.VFS.Virtual_File := - To_Virtual_File (Self.Configuration.Relocate_Build_Tree); - - Root_Dir : constant GNATCOLL.VFS.Virtual_File := - To_Virtual_File (Self.Configuration.Relocate_Root); - begin -- The projectFile may be either an absolute path or a -- relative path; if so, we're assuming it's relative -- to Self.Root. - if not GPR.Is_Absolute_Path and then not Self.Client.Root.Is_Empty then - GPR := GNATCOLL.VFS.Join (Root (Self), GPR); + if not Project_File.Is_Absolute_Path and then not Self.Client.Root.Is_Empty then + Project_File := GNATCOLL.VFS.Join (Root (Self), Project_File); end if; -- Unload the project tree and the project environment Release_Contexts_And_Project_Info (Self); -- Now load the new project - Self.Project_Status := Status; + Self.Project_Status.Load_Status := Status; if not Self.Configuration.Relocate_Build_Tree.Is_Empty then Project_Environment.Build_Path := GPR2.Path_Name.Create (Relocate_Build_Tree); if not Self.Configuration.Relocate_Root.Is_Empty - and then GPR /= GNATCOLL.VFS.No_File + and then Project_File /= GNATCOLL.VFS.No_File then if not Root_Dir.Is_Absolute_Path then Project_Environment.Build_Path := GPR2.Path_Name.Create_Directory - (GPR2.Path_Name.Create (GPR).Relative_Path + (GPR2.Path_Name.Create (Project_File).Relative_Path (GPR2.Path_Name.Create (Root_Dir)), GPR2.Filename_Type (Project_Environment.Build_Path.Value)); @@ -418,7 +378,7 @@ package body LSP.Ada_Handlers.Project_Loading is begin Self.Project_Tree.Load_Autoconf - (Filename => GPR2.Path_Name.Create (GPR), + (Filename => GPR2.Path_Name.Create (Project_File), Context => Project_Environment.Context, Build_Path => Project_Environment.Build_Path, Environment => Environment); @@ -435,26 +395,24 @@ package body LSP.Ada_Handlers.Project_Loading is Self.Tracer.Trace_Exception (E); - Self.Project_Status := Invalid_Project_Configured; + Self.Project_Status.Load_Status := Invalid_Project_Configured; end; - -- Keep errors and warnings - Append_Errors; + -- Retrieve the GPR2 error/warning messages right after loading the + -- project. + Self.Project_Status.GPR2_Messages := Self.Project_Tree.Log_Messages.all; + Self.Project_Status.Project_File := Project_File; - if Self.Project_Status /= Status + if Self.Project_Status.Load_Status /= Status or else not Self.Project_Tree.Is_Defined then -- The project was invalid: fallback on loading the implicit project. - Errors.Prepend - (VSS.Strings.Conversions.To_Virtual_String - ("Unable to load project file: " & GPR.Display_Full_Name)); - Load_Implicit_Project (Self, Invalid_Project_Configured); else -- No exception during Load_Autoconf, check if we have runtime if not Self.Project_Tree.Has_Runtime_Project then - Self.Project_Status := No_Runtime_Found; + Self.Project_Status.Load_Status := No_Runtime_Found; end if; Update_Project_Predefined_Sources (Self); @@ -469,20 +427,6 @@ package body LSP.Ada_Handlers.Project_Loading is end if; end if; - -- Report the warnings, if any - if not Warnings.Is_Empty then - Message.message := Warnings.Join_Lines (VSS.Strings.LF); - Message.a_type := LSP.Enumerations.Warning; - Self.Sender.On_ShowMessage_Notification (Message); - end if; - - -- Report the errors, if any - if not Errors.Is_Empty then - Message.message := Errors.Join_Lines (VSS.Strings.LF); - Message.a_type := LSP.Enumerations.Error; - Self.Sender.On_ShowMessage_Notification (Message); - end if; - -- Reindex all open documents immediately after project reload, so -- that navigation from editors is accurate. for Document of Self.Open_Documents loop @@ -582,7 +526,7 @@ package body LSP.Ada_Handlers.Project_Loading is Load_Project (Self => Self, - Project_File => Project, + Project_Path => Project, Scenario => Scenario_Variables, Environment => Environment, Charset => (if Charset.Is_Empty then UTF_8 else Charset), @@ -600,7 +544,7 @@ package body LSP.Ada_Handlers.Project_Loading is Load_Project (Self => Self, - Project_File => Project, + Project_Path => Project, Scenario => Scenario_Variables, Environment => Environment, Charset => Charset, diff --git a/source/ada/lsp-ada_handlers-project_loading.ads b/source/ada/lsp-ada_handlers-project_loading.ads index ca9448eef..e767094a0 100644 --- a/source/ada/lsp-ada_handlers-project_loading.ads +++ b/source/ada/lsp-ada_handlers-project_loading.ads @@ -26,7 +26,7 @@ package LSP.Ada_Handlers.Project_Loading is procedure Load_Project (Self : in out Message_Handler'Class; - Project_File : VSS.Strings.Virtual_String; + Project_Path : VSS.Strings.Virtual_String; Scenario : LSP.Ada_Configurations.Variable_List; Environment : GPR2.Environment.Object; Charset : VSS.Strings.Virtual_String; diff --git a/source/ada/lsp-ada_handlers.adb b/source/ada/lsp-ada_handlers.adb index 177d2e1cb..bf23219cd 100644 --- a/source/ada/lsp-ada_handlers.adb +++ b/source/ada/lsp-ada_handlers.adb @@ -1258,7 +1258,7 @@ package body LSP.Ada_Handlers is end if; end loop; - case Self.Project_Status is + case Self.Project_Status.Load_Status is when Valid_Project_Configured | Alire_Project => null; when No_Runtime_Found => @@ -2249,7 +2249,7 @@ package body LSP.Ada_Handlers is -- Handle the case where we're loading the implicit project: do -- we need to add the directory in which the document is open? - if Self.Project_Status in Implicit_Project_Loaded then + if Self.Project_Status.Load_Status in Implicit_Project_Loaded then declare Dir : constant GNATCOLL.VFS.Virtual_File := Self.To_File (URI).Dir; begin diff --git a/source/ada/lsp-ada_handlers.ads b/source/ada/lsp-ada_handlers.ads index 6f81a9fe0..2d706d7fb 100644 --- a/source/ada/lsp-ada_handlers.ads +++ b/source/ada/lsp-ada_handlers.ads @@ -25,6 +25,7 @@ with Ada.Exceptions; with GNATCOLL.Traces; with GNATCOLL.VFS; +with GPR2.Log; with GPR2.Project.Tree; with Libadalang.Analysis; @@ -172,6 +173,24 @@ private -- @value Invalid_Project_Configured didChangeConfiguration provided a -- valid project + type Project_Status_Type is record + Project_File : GNATCOLL.VFS.Virtual_File := GNATCOLL.VFS.No_File; + -- The project file we have attempted to load, successfully or not. + + Load_Status : Load_Project_Status := No_Project_Found; + -- Project loading status. + + GPR2_Messages : GPR2.Log.Object := GPR2.Log.Undefined; + -- The warning/error messages emitted by GPR2 while loading the project. + end record; + -- Project loading status. + + No_Project_Status : constant Project_Status_Type := + Project_Status_Type' + (Project_File => GNATCOLL.VFS.No_File, + Load_Status => No_Project_Found, + GPR2_Messages => <>); + type Project_Stamp is mod 2**32; subtype Implicit_Project_Loaded is Load_Project_Status range @@ -251,8 +270,10 @@ private -- A cache for the predefined sources in the loaded project (typically, -- runtime files). - Project_Status : Load_Project_Status := No_Project_Found; - -- Status of loading the project + Project_Status : Project_Status_Type := No_Project_Status; + -- Indicates whether a project has been successfully loaded and + -- how. Stores GPR2 error/warning messages emitted while loading + -- (or attempting to load) the project. Project_Dirs_Loaded : File_Sets.Set; -- The directories to load in the "implicit project" diff --git a/source/ada/lsp-utils.adb b/source/ada/lsp-utils.adb index cf5feadd9..56a5b080e 100644 --- a/source/ada/lsp-utils.adb +++ b/source/ada/lsp-utils.adb @@ -602,4 +602,67 @@ package body LSP.Utils is end return; end To_Unbounded_String; + -------------- + -- To_Range -- + -------------- + + function To_Range + (Sloc : GPR2.Source_Reference.Object) return LSP.Structures.A_Range + is + (if Sloc.Is_Defined and then Sloc.Has_Source_Reference then + (start => + (line => Natural (Sloc.Line) - 1, + character => Natural (Sloc.Column) - 1), + an_end => + (line => Natural (Sloc.Line) - 1, + character => Natural (Sloc.Column) - 1)) + else + (start => (1, 1), an_end => (1, 1))); + + ------------ + -- To_URI -- + ------------ + + function To_URI + (Path : GPR2.Path_Name.Object) return LSP.Structures.DocumentUri + is + (VSS.Strings.Conversions.To_Virtual_String + (URIs.Conversions.From_File (Path.Value)) with null record); + + ------------------------------------ + -- To_Optional_DiagnosticSeverity -- + ------------------------------------ + + function To_Optional_DiagnosticSeverity + (Level : GPR2.Message.Level_Value) + return LSP.Structures.DiagnosticSeverity_Optional + is + (case Level is + when GPR2.Message.Information => (True, LSP.Enumerations.Information), + when GPR2.Message.Warning => (True, LSP.Enumerations.Warning), + when GPR2.Message.Error => (True, LSP.Enumerations.Error), + when GPR2.Message.Lint => (True, LSP.Enumerations.Hint)); + + ----------------------- + -- To_LSP_Diagnostic -- + ----------------------- + + function To_LSP_Diagnostic + (Message : GPR2.Message.Object) return LSP.Structures.Diagnostic + is + use GPR2.Message; + + Diagnostic : LSP.Structures.Diagnostic; + begin + Diagnostic.a_range := To_Range (Message.Sloc); + Diagnostic.severity := To_Optional_DiagnosticSeverity (Message.Level); + Diagnostic.message := + VSS.Strings.Conversions.To_Virtual_String + (Message.Message); + Diagnostic.source := + VSS.Strings.Conversions.To_Virtual_String ("project"); + + return Diagnostic; + end To_LSP_Diagnostic; + end LSP.Utils; diff --git a/source/ada/lsp-utils.ads b/source/ada/lsp-utils.ads index 2e507f13d..ffdfd2ddb 100644 --- a/source/ada/lsp-utils.ads +++ b/source/ada/lsp-utils.ads @@ -19,6 +19,9 @@ with VSS.Strings; +with GPR2.Path_Name; +with GPR2.Message; +with GPR2.Source_Reference; with Libadalang.Analysis; with Langkit_Support.Slocs; with Pp.Scanner; @@ -93,7 +96,27 @@ package LSP.Utils is Slice : out VSS.Strings.Virtual_String); -- Return a slice of the Text in Span range - function Image (Value : LSP.Structures.Integer_Or_Virtual_String) - return VSS.Strings.Virtual_String; + function Image + (Value : LSP.Structures.Integer_Or_Virtual_String) + return VSS.Strings.Virtual_String; + -- Return a string representation of the given value. + + function To_Range + (Sloc : GPR2.Source_Reference.Object) return LSP.Structures.A_Range; + -- Convert a GPR2 source location into a LSP range. + + function To_URI + (Path : GPR2.Path_Name.Object) return LSP.Structures.DocumentUri; + -- Convert a GPR2 file path into a LSP URI. + + function To_Optional_DiagnosticSeverity + (Level : GPR2.Message.Level_Value) + return LSP.Structures.DiagnosticSeverity_Optional; + -- Convert a GPR2 message level into a LSP diagnostic severity. + + function To_LSP_Diagnostic + (Message : GPR2.Message.Object) return LSP.Structures.Diagnostic; + -- Convert a GPR2 message into a proper LSP diagnostic, with the right + -- severity level and the location reported by GPR2. end LSP.Utils; diff --git a/source/gpr/lsp-gpr_handlers.adb b/source/gpr/lsp-gpr_handlers.adb index de409d1a5..7aa53e488 100644 --- a/source/gpr/lsp-gpr_handlers.adb +++ b/source/gpr/lsp-gpr_handlers.adb @@ -21,7 +21,6 @@ with Ada.Unchecked_Deallocation; with GPR2.Log; with GPR2.Message; with GPR2.Path_Name.Set; -with GPR2.Source_Reference; with Langkit_Support.Slocs; @@ -34,20 +33,12 @@ with LSP.GPR_File_Readers; with LSP.GPR_Files.References; with LSP.GPR_Files.Symbols; with LSP.Text_Documents.Langkit_Documents; +with LSP.Utils; with Gpr_Parser.Common; package body LSP.GPR_Handlers is - function To_Optional_DiagnosticSeverity - (Level : GPR2.Message.Level_Value) - return LSP.Structures.DiagnosticSeverity_Optional; - - function To_Range - (File_Provider : LSP.GPR_Files.File_Provider_Access; - Sloc : GPR2.Source_Reference.Object) - return LSP.Structures.A_Range; - function To_Range (File_Provider : LSP.GPR_Files.File_Provider_Access; Reference : Gpr_Parser.Common.Token_Reference) return LSP.Structures.A_Range; @@ -607,16 +598,9 @@ package body LSP.GPR_Handlers is for C in Log.Iterate loop declare Message : constant GPR2.Message.Object := C.Element; - Diagnostic : LSP.Structures.Diagnostic; - + Diagnostic : constant LSP.Structures.Diagnostic := + LSP.Utils.To_LSP_Diagnostic (Message); begin - Diagnostic.a_range := - To_Range (Self'Unchecked_Access, Message.Sloc); - Diagnostic.severity := - To_Optional_DiagnosticSeverity (Message.Level); - Diagnostic.message := - VSS.Strings.Conversions.To_Virtual_String - (Message.Message); Diag.diagnostics.Append (Diagnostic); end; end loop; @@ -634,78 +618,15 @@ package body LSP.GPR_Handlers is end if; end Publish_Diagnostics; - ------------------------------------ - -- To_Optional_DiagnosticSeverity -- - ------------------------------------ - - function To_Optional_DiagnosticSeverity - (Level : GPR2.Message.Level_Value) - return LSP.Structures.DiagnosticSeverity_Optional - is - use all type GPR2.Message.Level_Value; - - begin - case Level is - when Information => - return (True, LSP.Enumerations.Information); - when Warning => - return (True, LSP.Enumerations.Warning); - when Error => - return (True, LSP.Enumerations.Error); - when Lint => - return (True, LSP.Enumerations.Hint); - end case; - end To_Optional_DiagnosticSeverity; - -------------- -- To_Range -- -------------- function To_Range (File_Provider : LSP.GPR_Files.File_Provider_Access; - Sloc : GPR2.Source_Reference.Object) + Reference : Gpr_Parser.Common.Token_Reference) return LSP.Structures.A_Range is - begin - if Sloc.Is_Defined and then Sloc.Has_Source_Reference then - declare - package LKD renames LSP.Text_Documents.Langkit_Documents; - - Path : constant GPR2.Path_Name.Object := - GPR2.Path_Name.Create_File - (GPR2.Filename_Type (Sloc.Filename)); - begin - if Path.Exists then - declare - File : constant LSP.GPR_Files.File_Access := - LSP.GPR_Files.Parse - (File_Provider => File_Provider, - Path => Path); - Line_Text : constant VSS.Strings.Virtual_String := - File.Get_Line (Sloc.Line); - begin - return LKD.To_A_Range - (Start_Line_Text => Line_Text, - End_Line_Text => Line_Text, - A_Range => - (Start_Line => Langkit_Support.Slocs.Line_Number - (Sloc.Line), - End_Line => Langkit_Support.Slocs.Line_Number - (Sloc.Line), - Start_Column => Langkit_Support.Slocs.Column_Number - (Sloc.Column), - End_Column => Langkit_Support.Slocs.Column_Number - (Sloc.Column))); - end; - end if; - end; - end if; - return LSP.Constants.Empty; - end To_Range; - - function To_Range (File_Provider : LSP.GPR_Files.File_Provider_Access; - Reference : Gpr_Parser.Common.Token_Reference) - return LSP.Structures.A_Range is use type Gpr_Parser.Common.Token_Reference; begin if Reference /= Gpr_Parser.Common.No_Token then diff --git a/testsuite/ada_lsp/T123-048.incremental_editing/test.json b/testsuite/ada_lsp/T123-048.incremental_editing/test.json index 6dc504d83..a587dd9fb 100644 --- a/testsuite/ada_lsp/T123-048.incremental_editing/test.json +++ b/testsuite/ada_lsp/T123-048.incremental_editing/test.json @@ -6,9 +6,7 @@ }, { "start": { - "cmd": [ - "${ALS}" - ] + "cmd": ["${ALS}"] } }, { @@ -27,10 +25,7 @@ "textDocument": { "completion": { "completionItem": { - "documentationFormat": [ - "markdown", - "plaintext" - ], + "documentationFormat": ["markdown", "plaintext"], "commitCharactersSupport": true, "preselectSupport": true, "deprecatedSupport": true, @@ -38,31 +33,8 @@ }, "completionItemKind": { "valueSet": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25 + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 ] }, "contextSupport": true, @@ -74,10 +46,7 @@ }, "signatureHelp": { "signatureInformation": { - "documentationFormat": [ - "markdown", - "plaintext" - ], + "documentationFormat": ["markdown", "plaintext"], "parameterInformation": { "labelOffsetSupport": true } @@ -85,10 +54,7 @@ "dynamicRegistration": true }, "hover": { - "contentFormat": [ - "markdown", - "plaintext" - ], + "contentFormat": ["markdown", "plaintext"], "dynamicRegistration": true }, "declaration": { @@ -129,32 +95,8 @@ "documentSymbol": { "symbolKind": { "valueSet": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] }, "hierarchicalDocumentSymbolSupport": true, @@ -213,43 +155,15 @@ "symbol": { "symbolKind": { "valueSet": [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10, - 11, - 12, - 13, - 14, - 15, - 16, - 17, - 18, - 19, - 20, - 21, - 22, - 23, - 24, - 25, - 26 + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ] }, "dynamicRegistration": true }, "workspaceEdit": { "failureHandling": "textOnlyTransactional", - "resourceOperations": [ - "create", - "rename", - "delete" - ], + "resourceOperations": ["create", "rename", "delete"], "documentChanges": true } } @@ -282,12 +196,7 @@ "textDocumentSync": 2, "declarationProvider": true, "completionProvider": { - "triggerCharacters": [ - ".", - ",", - "'", - "(" - ], + "triggerCharacters": [".", ",", "'", "("], "resolveProvider": true }, "documentSymbolProvider": true @@ -330,7 +239,9 @@ "wait": [] } }, - {"comment": "--------------------------- open a file -------------------------"}, + { + "comment": "--------------------------- open a file -------------------------" + }, { "send": { "request": { @@ -348,7 +259,9 @@ "wait": [] } }, - {"comment": "--------------------------- query a tooltip to verify -------------------------"}, + { + "comment": "--------------------------- query a tooltip to verify -------------------------" + }, { "send": { "request": { @@ -385,7 +298,9 @@ ] } }, - {"comment": "--------------------------- insert a space in the middle of a function name -------------------------"}, + { + "comment": "--------------------------- insert a space in the middle of a function name -------------------------" + }, { "send": { "request": { @@ -414,48 +329,12 @@ "jsonrpc": "2.0", "method": "textDocument/didChange" }, - "wait": [ - { - "params": { - "uri": "$URI{main.adb}", - "diagnostics": [ - { - "range": { - "start": { - "line": 2, - "character": 16 - }, - "end": { - "line": 2, - "character": 24 - } - }, - "source": "libadalang", - "message": "Missing ';'" - }, - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "severity": 4, - "source": "project", - "message": "Unique project in root directory was found and loaded, but it wasn't explicitly configured." - } - ] - }, - "method": "textDocument/publishDiagnostics" - } - ] + "wait": [] } }, - {"comment": "--------------------------- hover should be empty -------------------------"}, + { + "comment": "--------------------------- hover should be empty -------------------------" + }, { "send": { "request": { @@ -480,7 +359,9 @@ ] } }, - {"comment": "--------------------------- undo the change -------------------------"}, + { + "comment": "--------------------------- undo the change -------------------------" + }, { "send": { "request": { @@ -509,34 +390,12 @@ "jsonrpc": "2.0", "method": "textDocument/didChange" }, - "wait": [ - { - "params": { - "uri": "$URI{main.adb}", - "diagnostics": [ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "severity": 4, - "source": "project", - "message": "Unique project in root directory was found and loaded, but it wasn't explicitly configured." - } - ] - }, - "method": "textDocument/publishDiagnostics" - } - ] + "wait": [] } }, - {"comment": "--------------------------- verify that the hover is good again -------------------------"}, + { + "comment": "--------------------------- verify that the hover is good again -------------------------" + }, { "send": { "request": { diff --git a/testsuite/ada_lsp/T723-027.signatureHelp.overloaded/test.json b/testsuite/ada_lsp/T723-027.signatureHelp.overloaded/test.json index 50ba0c535..38106b6df 100644 --- a/testsuite/ada_lsp/T723-027.signatureHelp.overloaded/test.json +++ b/testsuite/ada_lsp/T723-027.signatureHelp.overloaded/test.json @@ -4,14 +4,12 @@ "Test signatureHelp for an overloaded name at the end of the test ", "one signature should be filtered out" ] - }, + }, { "start": { - "cmd": [ - "${ALS}" - ] + "cmd": ["${ALS}"] } - }, + }, { "send": { "request": { @@ -28,52 +26,49 @@ "id": 1, "method": "initialize" }, - "wait": [{ + "wait": [ + { "id": 1, "result": { "capabilities": { "textDocumentSync": 2, "signatureHelpProvider": { - "triggerCharacters": [ - ",", - "(" - ], - "retriggerCharacters": [ - "\b" - ] + "triggerCharacters": [",", "("], + "retriggerCharacters": ["\b"] } } } - }] + } + ] } }, { "send": { "request": { - "jsonrpc": "2.0", + "jsonrpc": "2.0", "method": "initialized" - }, + }, "wait": [] } - }, + }, { "send": { "request": { "params": { "settings": { "ada": { - "projectFile": "$URI{test.gpr}", + "projectFile": "$URI{default.gpr}", "scenarioVariables": {}, "defaultCharset": "ISO-8859-1" } } - }, - "jsonrpc": "2.0", + }, + "jsonrpc": "2.0", "method": "workspace/didChangeConfiguration" - }, + }, "wait": [] } - }, + }, { "send": { "request": { diff --git a/testsuite/ada_lsp/project_config.missing_file/test.json b/testsuite/ada_lsp/project_config.missing_file/test.json index ff63a7e5e..f0cc9615e 100644 --- a/testsuite/ada_lsp/project_config.missing_file/test.json +++ b/testsuite/ada_lsp/project_config.missing_file/test.json @@ -1,113 +1,146 @@ [ - { - "comment":[ - "This test check language server is able to report errors", - "when loading a project with missing files." - ] - }, { - "start": { - "cmd": ["${ALS}"] - } - }, { - "send": { - "request": {"jsonrpc":"2.0","id":0,"method":"initialize","params":{ - "processId":1, - "rootUri":"$URI{.}", - "capabilities":{}} - }, - "wait":[{ - "id": 0, - "result":{ - "capabilities":{ - "textDocumentSync": 2, - "definitionProvider":true - } - } - }] - } - }, { - "send": { - "request": { - "jsonrpc":"2.0", - "method":"workspace/didChangeConfiguration", - "params":{ - "settings":{ - "ada":{ - "projectFile": "prj1.gpr" - } - } - } - }, - "wait":[ - { - "jsonrpc": "2.0", - "method": "window/showMessage", - "params": { - "type": 1, - "message": "" - } - } - ] - } - }, { - "send": { - "request": { - "jsonrpc":"2.0", - "method":"textDocument/didOpen", - "params":{ - "textDocument": { - "uri": "$URI{main.adb}", - "languageId": "ada", - "version": 1, - "text": "procedure Main is\nbegin\n null;\nend Main;" - } - } - }, - "wait":[ - { - "jsonrpc": "2.0", - "method": "textDocument/publishDiagnostics", - "params": { - "uri":"$URI{main.adb}", - "diagnostics":[ - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line":0, - "character":0 - } - }, - "severity": 1, - "source": "project", - "message": "Project file has error and can't be loaded." - } - ] - } - } - ] - } - }, { - "send": { - "request": { - "jsonrpc":"2.0", - "id": "shutdown", - "method":"shutdown", - "params":null - }, - "wait":[{ "id": "shutdown", "result": null }] - } - }, { - "send": { - "request": {"jsonrpc":"2.0", "method":"exit"}, - "wait":[] - } - }, { - "stop": { - "exit_code": 0 - } - } + { + "comment": [ + "This test check language server is able to report errors", + "when loading a project with missing files." + ] + }, + { + "start": { + "cmd": ["${ALS}"] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": 0, + "method": "initialize", + "params": { + "processId": 1, + "rootUri": "$URI{.}", + "capabilities": {} + } + }, + "wait": [ + { + "id": 0, + "result": { + "capabilities": { + "textDocumentSync": 2, + "definitionProvider": true + } + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "workspace/didChangeConfiguration", + "params": { + "settings": { + "ada": { + "projectFile": "prj1.gpr" + } + } + } + }, + "wait": [] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "$URI{main.adb}", + "languageId": "ada", + "version": 1, + "text": "procedure Main is\nbegin\n null;\nend Main;" + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "method": "textDocument/publishDiagnostics", + "params": { + "uri": "$URI{main.adb}", + "diagnostics": [ + { + "range": { + "start": { "line": 0, "character": 0 }, + "end": { "line": 0, "character": 0 } + }, + "severity": 1, + "source": "project", + "message": "Project Problems", + "relatedInformation": [ + { + "location": { + "uri": "$URI{prj1.gpr}", + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + } + }, + "message": "Project file has errors and can't be loaded." + }, + { + "location": { + "uri": "$URI{prj1.gpr}", + "range": { + "start": { + "line": 1, + "character": 7 + }, + "end": { + "line": 1, + "character": 7 + } + } + }, + "message": "source file \"missing.ads\" not found" + } + ] + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "shutdown", + "method": "shutdown", + "params": null + }, + "wait": [{ "id": "shutdown", "result": null }] + } + }, + { + "send": { + "request": { "jsonrpc": "2.0", "method": "exit" }, + "wait": [] + } + }, + { + "stop": { + "exit_code": 0 + } + } ] diff --git a/testsuite/ada_lsp/project_config.multiple_project_diagnostics/a.gpr b/testsuite/ada_lsp/project_config.multiple_project_diagnostics/a.gpr new file mode 100644 index 000000000..77580cb9e --- /dev/null +++ b/testsuite/ada_lsp/project_config.multiple_project_diagnostics/a.gpr @@ -0,0 +1,2 @@ +project A is +end A; diff --git a/testsuite/ada_lsp/project_config.multiple_project_diagnostics/b.gpr b/testsuite/ada_lsp/project_config.multiple_project_diagnostics/b.gpr new file mode 100644 index 000000000..a97f22fac --- /dev/null +++ b/testsuite/ada_lsp/project_config.multiple_project_diagnostics/b.gpr @@ -0,0 +1,2 @@ +project B is +end B; \ No newline at end of file diff --git a/testsuite/ada_lsp/project_config.multiple_project_diagnostics/main.adb b/testsuite/ada_lsp/project_config.multiple_project_diagnostics/main.adb new file mode 100644 index 000000000..e0d8401fa --- /dev/null +++ b/testsuite/ada_lsp/project_config.multiple_project_diagnostics/main.adb @@ -0,0 +1,4 @@ +procedure Main is +begin + null; +end Main; diff --git a/testsuite/ada_lsp/project_config.multiple_project_diagnostics/test.json b/testsuite/ada_lsp/project_config.multiple_project_diagnostics/test.json new file mode 100644 index 000000000..e966530d3 --- /dev/null +++ b/testsuite/ada_lsp/project_config.multiple_project_diagnostics/test.json @@ -0,0 +1,231 @@ +[ + { + "comment": [ + "Test the project diagnostics when we have several .gpr files in the ", + "root directory, without having set the 'ada.projectFile' setting.", + "It also checks that we propose a quickfix to set 'ada.projectFile'." + ] + }, + { + "start": { + "cmd": ["${ALS}"] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": 1, + "method": "initialize", + "params": { + "rootUri": "$URI{.}", + "capabilities": {} + } + }, + "wait": [ + { + "id": 1, + "result": { + "capabilities": { + "executeCommandProvider": { + "commands": ["", "als-refactor-add-parameters"] + } + } + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "initialized", + "params": {} + }, + "wait": [] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "$URI{main.adb}", + "languageId": "ada", + "version": 1, + "text": "procedure Main is\nbegin\n null;\nend Main;\n" + } + } + }, + "wait": [] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": 2, + "method": "workspace/executeCommand", + "params": { + "command": "als-source-dirs" + } + }, + "wait": [ + { + "method": "textDocument/publishDiagnostics", + "params": { + "uri": "$URI{main.adb}", + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "severity": 1, + "source": "project", + "message": "No project was loaded, because more than one project file has been found in the root directory. Please change configuration to point a correct project file." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": 6, + "method": "textDocument/codeAction", + "params": { + "textDocument": { + "uri": "$URI{main.adb}" + }, + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "context": { + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "message": "No project was loaded, because more than one project file has been found in the root directory. Please change configuration to point a correct project file.", + "severity": 1, + "source": "project" + } + ], + "triggerKind": 2 + } + } + }, + "wait": [] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": 13, + "method": "textDocument/codeAction", + "params": { + "textDocument": { + "uri": "$URI{main.adb}" + }, + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "context": { + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "message": "No project was loaded, because more than one project file has been found in the root directory. Please change configuration to point a correct project file.", + "severity": 1, + "source": "project" + } + ], + "triggerKind": 2 + } + } + }, + "wait": [ + { + "id": 13, + "result": [ + { + "title": "Open settings for ada.projectFile", + "kind": "quickfix", + "diagnostics": [ + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "severity": 1, + "source": "project", + "message": "No project was loaded, because more than one project file has been found in the root directory. Please change configuration to point a correct project file." + } + ], + "isPreferred": true, + "command": { + "title": "Open settings for ada.projectFile", + "command": "workbench.action.openSettings", + "arguments": "ada.projectFile" + } + } + ] + } + ] + } + }, + { + "stop": { + "exit_code": 0 + } + } +] diff --git a/testsuite/ada_lsp/project_config.multiple_project_diagnostics/test.yaml b/testsuite/ada_lsp/project_config.multiple_project_diagnostics/test.yaml new file mode 100644 index 000000000..523c27b84 --- /dev/null +++ b/testsuite/ada_lsp/project_config.multiple_project_diagnostics/test.yaml @@ -0,0 +1 @@ +title: 'project_config.multiple_project_diagnostics' diff --git a/testsuite/ada_lsp/refactoring_diagnostics/test.json b/testsuite/ada_lsp/refactoring_diagnostics/test.json index b8ad5a7bd..d3b5c6864 100644 --- a/testsuite/ada_lsp/refactoring_diagnostics/test.json +++ b/testsuite/ada_lsp/refactoring_diagnostics/test.json @@ -8,9 +8,7 @@ }, { "start": { - "cmd": [ - "${ALS}" - ] + "cmd": ["${ALS}"] } }, { @@ -27,9 +25,7 @@ "applyEdit": true, "workspaceEdit": { "documentChanges": true, - "resourceOperations": [ - "rename" - ] + "resourceOperations": ["rename"] } }, "textDocument": { @@ -38,15 +34,9 @@ "dynamicRegistration": true, "completionItem": { "snippetSupport": false, - "documentationFormat": [ - "plaintext", - "markdown" - ], + "documentationFormat": ["plaintext", "markdown"], "resolveSupport": { - "properties": [ - "detail", - "documentation" - ] + "properties": ["detail", "documentation"] } } } @@ -60,10 +50,7 @@ "result": { "capabilities": { "executeCommandProvider": { - "commands": [ - "", - "als-refactor-add-parameters" - ] + "commands": ["", "als-refactor-add-parameters"] } } } @@ -149,74 +136,92 @@ } }, "wait": [ - { - "jsonrpc": "2.0", - "method": "textDocument/publishDiagnostics", - "params": { - "uri": "$URI{test.ads}", - "diagnostics": [ - { - "range": { - "start": { - "line": 6, - "character": 3 - }, - "end": { - "line": 6, - "character": 11 - } - }, - "source": "libadalang", - "message": "Missing ';'" - }, - { - "range": { - "start": { - "line": 0, - "character": 0 - }, - "end": { - "line": 0, - "character": 0 - } - }, - "severity": 4, - "source": "project", - "message": "Unique project in root directory was found and loaded, but it wasn't explicitly configured." - }, - { - "range": { - "start": { - "line": 12, - "character": 3 - }, - "end": { - "line": 14, - "character": 16 - } - }, - "severity": 1, - "source": "Ada", - "message": "Failed to execute the Add Parameter refactoring.", - "relatedInformation": [ { - "location": { - "uri": "$URI{test.ads}", - "range": { - "start": { - "line": 12, - "character": 3 - }, - "end": { - "line": 14, - "character": 16 - } - } - }, - "message": "Can't change the controlling parameter of a primitive" - } - ] - } + "jsonrpc": "2.0", + "method": "textDocument/publishDiagnostics", + "params": { + "uri": "$URI{test.ads}", + "diagnostics": [ + { + "range": { + "start": { + "line": 6, + "character": 3 + }, + "end": { + "line": 6, + "character": 11 + } + }, + "source": "libadalang", + "message": "Missing ';'" + }, + { + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + }, + "severity": 4, + "source": "project", + "message": "Project Problems", + "relatedInformation": [ + { + "location": { + "uri": "$URI{default.gpr}", + "range": { + "start": { + "line": 0, + "character": 0 + }, + "end": { + "line": 0, + "character": 0 + } + } + }, + "message": "Unique project in root directory was found and loaded, but it wasn't explicitly configured." + } + ] + }, + { + "range": { + "start": { + "line": 12, + "character": 3 + }, + "end": { + "line": 14, + "character": 16 + } + }, + "severity": 1, + "source": "Ada", + "message": "Failed to execute the Add Parameter refactoring.", + "relatedInformation": [ + { + "location": { + "uri": "$URI{test.ads}", + "range": { + "start": { + "line": 12, + "character": 3 + }, + "end": { + "line": 14, + "character": 16 + } + } + }, + "message": "Can't change the controlling parameter of a primitive" + } + ] + } ] } },