From 5d3b60942335a84431762e9aa2df50b7f21622a2 Mon Sep 17 00:00:00 2001 From: Philippe Gil Date: Thu, 18 Apr 2024 16:08:20 +0200 Subject: [PATCH] Improve hover feature - if GPR loaded then dispplay variables & attributes value in tooltips - take into account attribute index for references & tooltips - display documentation for package & attribute references Closes eng/ide/ada_language_server#1323 --- source/gpr/lsp-gpr_documentation.adb | 95 +- source/gpr/lsp-gpr_documentation.ads | 9 +- source/gpr/lsp-gpr_documents.adb | 162 +++ source/gpr/lsp-gpr_documents.ads | 24 + source/gpr/lsp-gpr_files-references.adb | 106 +- source/gpr/lsp-gpr_files-references.ads | 32 + source/gpr/lsp-gpr_files.adb | 137 ++- source/gpr/lsp-gpr_files.ads | 31 +- source/gpr/lsp-gpr_handlers.adb | 8 +- testsuite/gpr_lsp/hover/prj1.gpr | 16 +- testsuite/gpr_lsp/hover/prj2.gpr | 4 - testsuite/gpr_lsp/hover/prj3.gpr | 15 + testsuite/gpr_lsp/hover/test.json | 1278 +++++++++++++++-------- 13 files changed, 1436 insertions(+), 481 deletions(-) delete mode 100644 testsuite/gpr_lsp/hover/prj2.gpr create mode 100644 testsuite/gpr_lsp/hover/prj3.gpr diff --git a/source/gpr/lsp-gpr_documentation.adb b/source/gpr/lsp-gpr_documentation.adb index 0a75ba5bb..a91529dc0 100644 --- a/source/gpr/lsp-gpr_documentation.adb +++ b/source/gpr/lsp-gpr_documentation.adb @@ -16,12 +16,16 @@ ------------------------------------------------------------------------------ with Ada.Characters.Conversions; +with Ada.Characters.Latin_1; +with GPR2.Project.Attribute; +with GPR2.Project.Variable; with Gpr_Parser.Common; with GPR2.Project.Registry.Attribute.Description; with GPR2.Project.Registry.Pack.Description; +with LSP.GPR_Files.References; with LSP.Text_Documents.Langkit_Documents; with VSS.Strings.Conversions; @@ -29,12 +33,19 @@ with VSS.Strings.Conversions; package body LSP.GPR_Documentation is procedure Get_Tooltip_Text - (Self : LSP.GPR_Files.File; - Position : LSP.Structures.Position; - Tooltip_Text : out VSS.Strings.Virtual_String) is + (Self : LSP.GPR_Files.File_Access; + URI : LSP.Structures.DocumentUri; + Document_Provider : LSP.GPR_Documents.Document_Provider_Access; + Position : LSP.Structures.Position; + Tooltip_Text : out VSS.Strings.Virtual_String) is use Gpr_Parser.Common; package LKD renames LSP.Text_Documents.Langkit_Documents; + package FR renames LSP.GPR_Files.References; + + procedure Append_Value (Reference : FR.Reference); + -- If gpr parsed without error append to 'Tooltip_Text' + -- current variable/attribute value. Location : constant Gpr_Parser.Slocs.Source_Location := LSP.GPR_Files.To_Langkit_Location @@ -49,12 +60,67 @@ package body LSP.GPR_Documentation is use GPR2.Project.Registry.Pack.Description; use GPR2; use Ada.Characters.Conversions; + + ------------------ + -- Append_Value -- + ------------------ + + procedure Append_Value (Reference : FR.Reference) is + begin + if Reference.Is_Variable_Reference + or else Reference.Is_Attribute_Reference + then + declare + Document : constant LSP.GPR_Documents.Document_Access := + Document_Provider.Get_Open_Document (URI); + use type LSP.GPR_Documents.Document_Access; + begin + if Document /= null and then not Document.Has_Errors + then + if Reference.Is_Variable_Reference then + declare + Variable : constant GPR2.Project.Variable.Object := + Document.Get_Variable + (Root_File => Self, + Reference => Reference); + begin + if Variable.Is_Defined then + Tooltip_Text.Append + (VSS.Strings.Conversions.To_Virtual_String + (GPR2.Project.Variable.Image (Variable))); + end if; + end; + elsif Reference.Is_Attribute_Reference then + declare + Attribute : constant GPR2.Project.Attribute.Object := + Document.Get_Attribute + (Root_File => Self, + Reference => Reference); + begin + if Attribute.Is_Defined then + Tooltip_Text.Append + (VSS.Strings.Conversions.To_Virtual_String + (GPR2.Project.Attribute.Image (Attribute) + & Ada.Characters.Latin_1.CR)); + end if; + end; + end if; + end if; + end; + end if; + end Append_Value; + begin Tooltip_Text.Clear; if Token /= No_Token and then Token.Data.Kind = Gpr_Identifier then declare + Reference : constant FR.Reference := + FR.Identifier_Reference + (File => Self, + Current_Package => Self.Get_Package (Position), + Token => Token); Previous : constant Token_Reference := Token.Previous (Exclude_Trivia => True); begin @@ -67,6 +133,7 @@ package body LSP.GPR_Documentation is (Self.Get_Package (Position)))); when Gpr_For => + Append_Value (Reference); Tooltip_Text.Append (VSS.Strings.Conversions.To_Virtual_String (Get_Attribute_Description (( @@ -74,7 +141,27 @@ package body LSP.GPR_Documentation is +(Optional_Name_Type (To_String (Token.Text))))))); when others => - null; + Append_Value (Reference); + if Reference.Is_Package_Reference then + Tooltip_Text.Append + (VSS.Strings.Conversions.To_Virtual_String + (Get_Package_Description + (Reference.Referenced_Package))); + else + declare + Attribute : constant FR.Attribute_Definition := + Reference.Referenced_Attribute; + + use type FR.Attribute_Definition; + begin + if Attribute /= FR.No_Attribute_Definition then + Tooltip_Text.Append + (VSS.Strings.Conversions.To_Virtual_String + (Get_Attribute_Description + (Attribute.Name))); + end if; + end; + end if; end case; end if; end; diff --git a/source/gpr/lsp-gpr_documentation.ads b/source/gpr/lsp-gpr_documentation.ads index e957d272a..d2bef4188 100644 --- a/source/gpr/lsp-gpr_documentation.ads +++ b/source/gpr/lsp-gpr_documentation.ads @@ -17,6 +17,7 @@ -- Subprogram to obtain documentation for packages & attributes. +with LSP.GPR_Documents; with LSP.GPR_Files; with LSP.Structures; @@ -25,9 +26,11 @@ with VSS.Strings; package LSP.GPR_Documentation is procedure Get_Tooltip_Text - (Self : LSP.GPR_Files.File; - Position : LSP.Structures.Position; - Tooltip_Text : out VSS.Strings.Virtual_String); + (Self : LSP.GPR_Files.File_Access; + URI : LSP.Structures.DocumentUri; + Document_Provider : LSP.GPR_Documents.Document_Provider_Access; + Position : LSP.Structures.Position; + Tooltip_Text : out VSS.Strings.Virtual_String); -- Get all the information needed to produce tooltips (hover and completion -- requests) diff --git a/source/gpr/lsp-gpr_documents.adb b/source/gpr/lsp-gpr_documents.adb index bb011c327..d1c6b6871 100644 --- a/source/gpr/lsp-gpr_documents.adb +++ b/source/gpr/lsp-gpr_documents.adb @@ -18,8 +18,11 @@ with Ada.Exceptions; with GPR2.Message; +with GPR2.Project.View; with GPR2.Source_Reference; +with VSS.Strings.Conversions; + package body LSP.GPR_Documents is ------------- @@ -113,6 +116,17 @@ package body LSP.GPR_Documents is return Self.Has_Messages; end Has_Diagnostics; + ---------------- + -- Has_Errors -- + ---------------- + + function Has_Errors + (Self : Document) + return Boolean is + begin + return Self.Tree.Log_Messages.Has_Error; + end Has_Errors; + ---------------- -- Initialize -- ---------------- @@ -206,4 +220,152 @@ package body LSP.GPR_Documents is Self.Published_Files_With_Diags := Files; end Update_Files_With_Diags; + ------------------ + -- Get_Variable -- + ------------------ + + function Get_Variable + (Self : Document'Class; + Root_File : LSP.GPR_Files.File_Access; + Reference : LSP.GPR_Files.References.Reference) + return GPR2.Project.Variable.Object is + + function Variable + (View : GPR2.Project.View.Object) return GPR2.Project.Variable.Object; + + function Variable + (View : GPR2.Project.View.Object) return GPR2.Project.Variable.Object + is + Pack : constant GPR2.Package_Id := + LSP.GPR_Files.References.Referenced_Package (Reference); + Name : constant GPR2.Name_Type := + GPR2.Name_Type + (VSS.Strings.Conversions.To_UTF_8_String + (LSP.GPR_Files.Image + (LSP.GPR_Files.References.Referenced_Variable + (Reference)))); + + use type GPR2.Package_Id; + begin + if Pack = GPR2.Project_Level_Scope then + if View.Has_Variables (Name) then + return View.Variable (Name); + end if; + else + if View.Has_Variables (Pack, Name) then + return View.Variable (Pack, Name); + end if; + end if; + return GPR2.Project.Variable.Undefined; + end Variable; + + begin + if LSP.GPR_Files.References.Is_Variable_Reference (Reference) + and then not Self.Tree.Log_Messages.Has_Error + then + declare + File : constant LSP.GPR_Files.File_Access := + LSP.GPR_Files.References.Referenced_File + (File => Root_File, + Reference => Reference); + Path : constant GPR2.Path_Name.Object := + LSP.GPR_Files.Path (File.all); + Root : constant GPR2.Project.View.Object := Self.Tree.Root_Project; + begin + if Root.Path_Name = Path then + return Variable (Root); + end if; + if Root.Is_Extended then + declare + Extending : constant GPR2.Project.View.Object := + Root.Extending; + begin + if Extending.Path_Name = Path then + return Variable (Extending); + end if; + end; + end if; + for Import of Root.Imports loop + if Import.Path_Name = Path then + return Variable (Import); + end if; + end loop; + end; + end if; + return GPR2.Project.Variable.Undefined; + end Get_Variable; + + ------------------- + -- Get_Attribute -- + ------------------- + + function Get_Attribute + (Self : Document'Class; + Root_File : LSP.GPR_Files.File_Access; + Reference : LSP.GPR_Files.References.Reference) + return GPR2.Project.Attribute.Object is + + function Attribute + (View : GPR2.Project.View.Object) return GPR2.Project.Attribute.Object; + + Attr_Def : constant LSP.GPR_Files.References.Attribute_Definition := + LSP.GPR_Files.References.Referenced_Attribute (Reference); + + --------------- + -- Attribute -- + --------------- + + function Attribute + (View : GPR2.Project.View.Object) return GPR2.Project.Attribute.Object + is + Result : GPR2.Project.Attribute.Object; + begin + if View.Check_Attribute + (Name => Attr_Def.Name, + Index => Attr_Def.Index, + At_Pos => Attr_Def.At_Pos, + Result => Result) + then + return Result; + else + return GPR2.Project.Attribute.Undefined; + end if; + end Attribute; + + begin + if LSP.GPR_Files.References.Is_Attribute_Reference (Reference) + and then not Self.Tree.Log_Messages.Has_Error + then + declare + File : constant LSP.GPR_Files.File_Access := + LSP.GPR_Files.References.Referenced_File + (File => Root_File, + Reference => Reference); + Path : constant GPR2.Path_Name.Object := + LSP.GPR_Files.Path (File.all); + Root : constant GPR2.Project.View.Object := Self.Tree.Root_Project; + begin + if Root.Path_Name = Path then + return Attribute (Root); + end if; + if Root.Is_Extended then + declare + Extending : constant GPR2.Project.View.Object := + Root.Extending; + begin + if Extending.Path_Name = Path then + return Attribute (Extending); + end if; + end; + end if; + for Import of Root.Imports loop + if Import.Path_Name = Path then + return Attribute (Import); + end if; + end loop; + end; + end if; + return GPR2.Project.Attribute.Undefined; + end Get_Attribute; + end LSP.GPR_Documents; diff --git a/source/gpr/lsp-gpr_documents.ads b/source/gpr/lsp-gpr_documents.ads index e70cf8eee..11d13da91 100644 --- a/source/gpr/lsp-gpr_documents.ads +++ b/source/gpr/lsp-gpr_documents.ads @@ -31,9 +31,12 @@ with GPR2.Log; with GPR2.Path_Name; with GPR2.Path_Name.Set; with GPR2.Project.Tree; +with GPR2.Project.Attribute; +with GPR2.Project.Variable; with LSP.Text_Documents; with LSP.GPR_Files; +with LSP.GPR_Files.References; with LSP.Structures; with LSP.Tracers; @@ -91,6 +94,11 @@ package LSP.GPR_Documents is function Has_Diagnostics (Self : Document) return Boolean; + -- Returns True when messages found during document parsing. + + function Has_Errors + (Self : Document) + return Boolean; -- Returns True when errors found during document parsing. ----------------------- @@ -125,6 +133,22 @@ package LSP.GPR_Documents is procedure Update_Files_With_Diags (Self : in out Document'Class; Files : GPR2.Path_Name.Set.Object); + function Get_Variable + (Self : Document'Class; + Root_File : LSP.GPR_Files.File_Access; + Reference : LSP.GPR_Files.References.Reference) + return GPR2.Project.Variable.Object; + -- if Document contains a valid Tree & Reference is a variable reference + -- returns corresponding value otherwise returns 'Undefined' + + function Get_Attribute + (Self : Document'Class; + Root_File : LSP.GPR_Files.File_Access; + Reference : LSP.GPR_Files.References.Reference) + return GPR2.Project.Attribute.Object; + -- if Document contains a valid Tree & Reference is an attribute reference + -- returns corresponding value otherwise returns 'Undefined' + private type Name_Information is record diff --git a/source/gpr/lsp-gpr_files-references.adb b/source/gpr/lsp-gpr_files-references.adb index e456179e0..f345458f4 100644 --- a/source/gpr/lsp-gpr_files-references.adb +++ b/source/gpr/lsp-gpr_files-references.adb @@ -21,6 +21,8 @@ with Ada.Containers.Vectors; with LSP.Text_Documents.Langkit_Documents; +with VSS.Strings.Conversions; + package body LSP.GPR_Files.References is use type GPC.Token_Kind; @@ -298,18 +300,34 @@ package body LSP.GPR_Files.References is Project => Referenced_Project.Name, In_Type_Reference => False, Pack => Referenced_Package); + else + return (Kind => Package_Ref, + Token => Token, + Project => Referenced_Project.Name, + In_Type_Reference => False, + Pack => Referenced_Package); end if; end; end if; return No_Reference; end if; + if Previous_Token_Kind = GPC.Gpr_For then + Tick_Found := True; + Referenced_Package := Current_Package; + end if; + if Identifiers.Length = 1 then if Tick_Found then declare Attribute : constant GPR2.Attribute_Id := +Optional_Name_Type (To_String (Identifiers.First_Element)); + Index : constant Index_Type := + LSP.GPR_Files.Index + (Self => File.all, + Attribute_Token => Identifiers.First_Element, + Current_Package => Referenced_Package); begin if Referenced_Package /= GPR2.Project_Level_Scope then declare @@ -326,6 +344,19 @@ package body LSP.GPR_Files.References is A := D.Attributes.Find (Attribute); if LSP.GPR_Files.Attribute_Maps.Has_Element (A) then M := LSP.GPR_Files.Attribute_Maps.Element (A); + C := M.Find (Index); + if LSP.GPR_Files.Attribute_Index_Maps.Has_Element (C) + then + return (Kind => Attribute_Ref, + Token => LSP.GPR_Files. + Attribute_Index_Maps.Element (C).Token, + Project => + Referenced_Project.Name, + Pack => Referenced_Package, + Attribute => Attribute, + Index => Index, + In_Type_Reference => False); + end if; C := M.First; if LSP.GPR_Files.Attribute_Index_Maps.Has_Element (C) then @@ -336,7 +367,7 @@ package body LSP.GPR_Files.References is Referenced_Project.Name, Pack => Referenced_Package, Attribute => Attribute, - Index => No_Index, + Index => Index, In_Type_Reference => False); end if; end if; @@ -352,6 +383,17 @@ package body LSP.GPR_Files.References is Project_Level_Scope_Defs.Attributes.Find (Attribute); if LSP.GPR_Files.Attribute_Maps.Has_Element (A) then M := LSP.GPR_Files.Attribute_Maps.Element (A); + C := M.Find (Index); + if C.Has_Element then + return (Kind => Attribute_Ref, + Token => C.Element.Token, + Project => + Referenced_Project.Name, + Pack => Referenced_Package, + Attribute => Attribute, + Index => Index, + In_Type_Reference => False); + end if; C := M.First; if C.Has_Element then return (Kind => Attribute_Ref, @@ -360,12 +402,20 @@ package body LSP.GPR_Files.References is Referenced_Project.Name, Pack => Referenced_Package, Attribute => Attribute, - Index => No_Index, + Index => Index, In_Type_Reference => False); end if; end if; end; end if; + return (Kind => Attribute_Ref, + Token => Token, + Project => + Referenced_Project.Name, + Pack => Referenced_Package, + Attribute => Attribute, + Index => Index, + In_Type_Reference => False); end; else declare @@ -488,6 +538,13 @@ package body LSP.GPR_Files.References is end if; end; end if; + else + return (Kind => Variable_Ref, + Token => Identifiers.First_Element, + Project => File.Name, + Pack => Current_Package, + Variable => Variable, + In_Type_Reference => False); end if; end; end if; @@ -713,4 +770,49 @@ package body LSP.GPR_Files.References is return File; end Get_Referenced_File; + -------------------------- + -- Referenced_Attribute -- + -------------------------- + + function Referenced_Attribute + (Reference : LSP.GPR_Files.References.Reference) + return Attribute_Definition is + begin + if Is_Attribute_Reference (Reference) then + declare + Name : constant GPR2.Q_Attribute_Id := + (Reference.Pack, Reference.Attribute); + Attr_Def : Attribute_Definition; + begin + Attr_Def.Name := Name; + Attr_Def.At_Pos := Reference.Index.At_Pos; + if Reference.Index.Is_Others then + Attr_Def.Index := GPR2.Project.Attribute_Index.I_Others; + elsif Reference.Index /= No_Index then + declare + Value : constant GPR2.Value_Type := + VSS.Strings.Conversions.To_UTF_8_String + (Reference.Index.Text); + Case_Sensitive : constant Boolean := + (if PRA.Exists (Name) + then PRA.Is_Case_Sensitive + (Index_Value => Value, + Index_Type => + PRA.Get (Name).Index_Type) + else False); + begin + Attr_Def.Index := GPR2.Project.Attribute_Index.Create + (Value => Value, + Case_Sensitive => Case_Sensitive); + end; + + end if; + + return Attr_Def; + end; + else + return No_Attribute_Definition; + end if; + end Referenced_Attribute; + end LSP.GPR_Files.References; diff --git a/source/gpr/lsp-gpr_files-references.ads b/source/gpr/lsp-gpr_files-references.ads index 80bfc95d5..b5de058ed 100644 --- a/source/gpr/lsp-gpr_files-references.ads +++ b/source/gpr/lsp-gpr_files-references.ads @@ -19,6 +19,8 @@ with Gpr_Parser.Common; +with GPR2.Project.Attribute_Index; + package LSP.GPR_Files.References is type Reference is private; @@ -50,6 +52,10 @@ package LSP.GPR_Files.References is (Reference : LSP.GPR_Files.References.Reference) return GPR2.Package_Id; + function Referenced_Variable + (Reference : LSP.GPR_Files.References.Reference) + return LSP.GPR_Files.Variable_Id; + function Has_Project (Reference : LSP.GPR_Files.References.Reference) return Boolean; @@ -82,6 +88,25 @@ package LSP.GPR_Files.References is Reference : LSP.GPR_Files.References.Reference) return LSP.GPR_Files.File_Access; + type Attribute_Definition is record + Name : GPR2.Q_Attribute_Id; + Index : GPR2.Project.Attribute_Index.Object; + At_Pos : GPR2.Unit_Index; + end record; + -- contains all information required to access a project attribute. + + No_Attribute_Definition : constant Attribute_Definition := + ((GPR2.Project_Level_Scope, + +"No_Attribute_Definition"), + GPR2.Project.Attribute_Index.Undefined, + GPR2.No_Index); + + function Referenced_Attribute + (Reference : LSP.GPR_Files.References.Reference) + return Attribute_Definition; + -- if Reference is a valid attribute reference returns all GPR2 + -- informations needed to access attribute value. + private package GPC renames Gpr_Parser.Common; @@ -152,4 +177,11 @@ private then Reference.In_Type_Reference else False); + function Referenced_Variable + (Reference : LSP.GPR_Files.References.Reference) + return LSP.GPR_Files.Variable_Id is + (if Reference.Kind = Variable_Ref + then Reference.Variable + else No_Variable); + end LSP.GPR_Files.References; diff --git a/source/gpr/lsp-gpr_files.adb b/source/gpr/lsp-gpr_files.adb index 98e2329a2..741da425c 100644 --- a/source/gpr/lsp-gpr_files.adb +++ b/source/gpr/lsp-gpr_files.adb @@ -84,6 +84,16 @@ package body LSP.GPR_Files is function Image (Index : Index_Type) return VSS.Strings.Virtual_String; -- convert a GPR2 index to a LSP string + function Next_Token + (File : LSP.GPR_Files.File; + Ref : GPC.Token_Reference) return GPC.Token_Reference; + -- go to next token if any or stay at last + + function Previous_Token + (File : LSP.GPR_Files.File; + Ref : GPC.Token_Reference) return GPC.Token_Reference; + -- go to previous token if any or stay at first + ------------ -- New_Id -- ------------ @@ -314,11 +324,13 @@ package body LSP.GPR_Files is -- close current package if we are in a package. function Next_Token - (Ref : GPC.Token_Reference) return GPC.Token_Reference; + (Ref : GPC.Token_Reference) return GPC.Token_Reference is + (Next_Token (File, Ref)); -- go to next token if any or stay at last function Previous_Token - (Ref : GPC.Token_Reference) return GPC.Token_Reference; + (Ref : GPC.Token_Reference) return GPC.Token_Reference is + (Previous_Token (File, Ref)); -- go to previous token if any or stay at first function Get_Parent return Symbol; @@ -552,37 +564,6 @@ package body LSP.GPR_Files is end case; end Add_Symbol; - ---------------- - -- Next_Token -- - ---------------- - - function Next_Token - (Ref : GPC.Token_Reference) return GPC.Token_Reference is - Result : constant GPC.Token_Reference := Next (Ref, True); - begin - if Result = GPC.No_Token then - return File.Unit.Last_Token; - else - return Result; - end if; - end Next_Token; - - -------------------- - -- Previous_Token -- - -------------------- - - function Previous_Token - (Ref : GPC.Token_Reference) return GPC.Token_Reference - is - Result : constant GPC.Token_Reference := Previous (Ref, True); - begin - if Result = GPC.No_Token then - return File.Unit.First_Token; - else - return Result; - end if; - end Previous_Token; - --------------------------- -- Close_Current_Package -- --------------------------- @@ -1597,4 +1578,94 @@ package body LSP.GPR_Files is return Projects; end Projects; + ---------------- + -- Next_Token -- + ---------------- + + function Next_Token + (File : LSP.GPR_Files.File; + Ref : GPC.Token_Reference) return GPC.Token_Reference is + Result : constant GPC.Token_Reference := Next (Ref, True); + begin + if Result = GPC.No_Token then + return File.Unit.Last_Token; + else + return Result; + end if; + end Next_Token; + + -------------------- + -- Previous_Token -- + -------------------- + + function Previous_Token + (File : LSP.GPR_Files.File; + Ref : GPC.Token_Reference) return GPC.Token_Reference + is + Result : constant GPC.Token_Reference := Previous (Ref, True); + begin + if Result = GPC.No_Token then + return File.Unit.First_Token; + else + return Result; + end if; + end Previous_Token; + + ----------- + -- Index -- + ----------- + + function Index + (Self : LSP.GPR_Files.File; + Attribute_Token : Gpr_Parser.Common.Token_Reference; + Current_Package : GPR2.Package_Id) + return Index_Type is + begin + if Attribute_Token /= GPC.No_Token + and then Attribute_Token.Data.Kind = GPC.Gpr_Identifier + then + declare + Attribute : constant GPR2.Q_Attribute_Id := + (Current_Package, + +To_Optional_Name_Type (Attribute_Token)); + Left_Par : constant GPC.Token_Reference := + Next_Token (Self, Attribute_Token); + Index : constant GPC.Token_Reference := + Next_Token (Self, Left_Par); + At_Token : constant GPC.Token_Reference := + Next_Token (Self, Index); + Pos_Token : constant GPC.Token_Reference := + Next_Token (Self, At_Token); + begin + if GPR2.Project.Registry.Attribute.Exists (Attribute) then + if Left_Par.Data.Kind = GPC.Gpr_Par_Open then + case Index.Data.Kind is + when GPC.Gpr_Others => + return Others_Index; + when GPC.Gpr_String => + declare + At_Pos : Unit_Index := GPR2.No_Index; + begin + if At_Token.Data.Kind = GPC.Gpr_At + and then Pos_Token.Data.Kind = GPC.Gpr_Number + then + At_Pos := Unit_Index'Value + (To_String (Pos_Token)); + end if; + return Create + (Text => To_Unbounded_String + (Remove_Quote (To_String (Index))), + Q_Attribute => Attribute, + At_Pos => At_Pos); + end; + when others => + null; + end case; + end if; + end if; + end; + end if; + return No_Index; + end Index; + end LSP.GPR_Files; diff --git a/source/gpr/lsp-gpr_files.ads b/source/gpr/lsp-gpr_files.ads index d1c343078..735e96d0d 100644 --- a/source/gpr/lsp-gpr_files.ads +++ b/source/gpr/lsp-gpr_files.ads @@ -230,6 +230,11 @@ package LSP.GPR_Files is return VSS.Strings.Virtual_String; -- Self file' name + function Path + (Self : LSP.GPR_Files.File) + return GPR2.Path_Name.Object; + -- Self file' path + function Types (Self : LSP.GPR_Files.File) return VSS.String_Vectors.Virtual_String_Vector; @@ -246,6 +251,16 @@ package LSP.GPR_Files is return VSS.String_Vectors.Virtual_String_Vector; -- Self file's non limited imported projects & extended projects. + type Variable_Id is private; + -- Used to describe variable's names + + No_Variable : constant Variable_Id; + -- Used when there is no variable attached + + function "+" (Name : String) return Variable_Id; + function Image (Id : Variable_Id) return VSS.Strings.Virtual_String; + -- Variable_Id/String conversions + private type Source_Position is record @@ -346,10 +361,6 @@ private No_Variable : constant Variable_Id := 0; -- Used when there is no variable attached - function "+" (Name : String) return Variable_Id; - function Image (Id : Variable_Id) return VSS.Strings.Virtual_String; - -- Variable_Id/String conversions - type Project_Id is new Natural with Default_Value => 0; -- Used to describe project's names @@ -410,6 +421,14 @@ private True); -- 'others' Index type value. ex: for Switches (others) use ("-g"); + function Index + (Self : LSP.GPR_Files.File; + Attribute_Token : Gpr_Parser.Common.Token_Reference; + Current_Package : GPR2.Package_Id) + return Index_Type; + -- return index defined after 'Attribute_Token' + -- If no index defined returns 'No_Index' + type Attribute_Definition is record Index : Index_Type; -- attribute's index. Token : Gpr_Parser.Common.Token_Reference; -- token returned by gpr lexer @@ -700,4 +719,8 @@ private (Self : LSP.GPR_Files.File) return VSS.Strings.Virtual_String is (Image (Self.Name)); + function Path + (Self : LSP.GPR_Files.File) + return GPR2.Path_Name.Object is (Self.Path); + end LSP.GPR_Files; diff --git a/source/gpr/lsp-gpr_handlers.adb b/source/gpr/lsp-gpr_handlers.adb index 92e1dbcd8..b9cd84538 100644 --- a/source/gpr/lsp-gpr_handlers.adb +++ b/source/gpr/lsp-gpr_handlers.adb @@ -296,9 +296,11 @@ package body LSP.GPR_Handlers is begin LSP.GPR_Documentation.Get_Tooltip_Text - (Self => File.all, - Position => Value.position, - Tooltip_Text => Tooltip_Text); + (Self => File, + URI => Value.textDocument.uri, + Document_Provider => Self'Unchecked_Access, + Position => Value.position, + Tooltip_Text => Tooltip_Text); if Tooltip_Text.Is_Empty then return; diff --git a/testsuite/gpr_lsp/hover/prj1.gpr b/testsuite/gpr_lsp/hover/prj1.gpr index 80b3de97c..dc00f65b9 100644 --- a/testsuite/gpr_lsp/hover/prj1.gpr +++ b/testsuite/gpr_lsp/hover/prj1.gpr @@ -1,9 +1,9 @@ -project Prj1 is -for Source_Dirs use ("src"); -package Compiler is -for Switches ("Ada") use (); -end Compiler; -package IDE is -for Artifacts_Dir use ""; -end IDE; +project Prj1 is +for Source_Dirs use ("src"); +package Compiler is +for Switches ("Ada") use (); +end Compiler; +package IDE is +for Artifacts_Dir use ""; +end IDE; end Prj1; \ No newline at end of file diff --git a/testsuite/gpr_lsp/hover/prj2.gpr b/testsuite/gpr_lsp/hover/prj2.gpr deleted file mode 100644 index 4ef75e4e3..000000000 --- a/testsuite/gpr_lsp/hover/prj2.gpr +++ /dev/null @@ -1,4 +0,0 @@ -project Prj2 is -for Source_Dirs use ("src"); --- The list of source directories of the project. -end Prj2; \ No newline at end of file diff --git a/testsuite/gpr_lsp/hover/prj3.gpr b/testsuite/gpr_lsp/hover/prj3.gpr new file mode 100644 index 000000000..2befd90a7 --- /dev/null +++ b/testsuite/gpr_lsp/hover/prj3.gpr @@ -0,0 +1,15 @@ +project Prj3 is + type T is ("project.Var value "); + Var : T := "project.Var value "; + package Builder is + Var := "project.Builder.Var value "; + for Global_Configuration_Pragmas use "project.Builder'Global_Configuration_Pragmas value "; + end Builder; + Var1 := Var & project.Var & project.Builder.Var & project'Name & Prj3'Name & Prj3.Builder'Global_Configuration_Pragmas; + package Compiler is + for Switches ("main.adb") use ("value1"); + for Switches ("main.adb" at 1) use ("value2"); + for Switches (others) use ("value3"); + Var := Compiler'Switches ("main.adb") & Compiler'Switches (others); + end Compiler; +end Prj3; diff --git a/testsuite/gpr_lsp/hover/test.json b/testsuite/gpr_lsp/hover/test.json index 54c08e1b9..7e2195bab 100644 --- a/testsuite/gpr_lsp/hover/test.json +++ b/testsuite/gpr_lsp/hover/test.json @@ -1,427 +1,865 @@ [ - { - "comment":[ - "test textDocument/hover request works" + { + "comment": [ + "test textDocument/hover request works" + ] + }, + { + "start": { + "cmd": [ + "${ALS}", + "--language-gpr" ] - }, - { - "start":{ - "cmd":[ - "${ALS}", - "--language-gpr" - ] - } - }, - { - "send":{ - "request":{ - "jsonrpc":"2.0", - "id":"init", - "method":"initialize", - "params":{ - "processId":441587, - "rootUri":"$URI{.}", - "capabilities":{ - "workspace":{ - "applyEdit":true, - "workspaceEdit":{ - - }, - "didChangeConfiguration":{ - - }, - "didChangeWatchedFiles":{ - - }, - "executeCommand":{ - - } - }, - "textDocument":{ - "synchronization":{ - - }, - "completion":{ - "dynamicRegistration":true, - "completionItem":{ - "snippetSupport":true, - "documentationFormat":[ - "plaintext", - "markdown" - ] - } - }, - "hover":{ - - }, - "signatureHelp":{ - - }, - "declaration":{ - - }, - "definition":{ - - }, - "typeDefinition":{ - - }, - "implementation":{ - - }, - "references":{ - - }, - "documentHighlight":{ - - }, - "documentSymbol":{ - "hierarchicalDocumentSymbolSupport":true - }, - "codeLens":{ - - }, - "colorProvider":{ - - }, - "formatting":{ - "dynamicRegistration":false - }, - "rangeFormatting":{ - "dynamicRegistration":false - }, - "onTypeFormatting":{ - "dynamicRegistration":false - }, - "foldingRange":{ - "lineFoldingOnly":true - }, - "selectionRange":{ - - }, - "linkedEditingRange":{ - - }, - "callHierarchy":{ - - }, - "moniker":{ - - } - } - } - } - }, - "wait":[ - { - "jsonrpc":"2.0", - "id":"init", - "result":{ - "capabilities":{ - "textDocumentSync":{ - "openClose":true, - "change":1 - } - } - } - } - ] - } - }, - { - "send":{ - "request":{ - "jsonrpc":"2.0", - "method":"initialized" - }, - "wait":[ - - ] - } - }, - { - "send":{ - "request":{ - "jsonrpc":"2.0", - "method":"textDocument/didOpen", - "params":{ - "textDocument":{ - "uri":"$URI{prj1.gpr}", - "languageId":"Gpr", - "version":1, - "text":"project Prj1 is\nfor Source_Dirs use (\"src\");\npackage Compiler is\nfor Switches (\"Ada\") use ();\nend Compiler;\npackage IDE is\nfor Artifacts_Dir use \"\";\nend IDE;\nend Prj1;" - } - } - }, - "wait":[ - - ] - } - }, - { - "send":{ - "request":{ - "params":{ - "position":{ - "line":2, - "character":15 - }, - "textDocument":{ - "uri":"$URI{prj1.gpr}" - } - }, - "jsonrpc":"2.0", - "id":1, - "method":"textDocument/hover" - }, - "wait":[ - { - "id":1, - "result":{ - "contents":[ - { - "language": "plaintext", - "value": "This package specifies the compilation options used by the compiler for each language." - } - ] - } - } - ] - } - }, - { - "send":{ - "request":{ - "params":{ - "position":{ - "line":4, - "character":4 - }, - "textDocument":{ - "uri":"$URI{prj1.gpr}" - } - }, - "jsonrpc":"2.0", - "id":2, - "method":"textDocument/hover" - }, - "wait":[ - { - "id":2, - "result":{ - "contents":[ - { - "language": "plaintext", - "value": "This package specifies the compilation options used by the compiler for each language." - } - ] - } - } - ] - } - }, - { - "send":{ - "request":{ - "params":{ - "position":{ - "line":5, - "character":4 - }, - "textDocument":{ - "uri":"$URI{prj1.gpr}" - } - }, - "jsonrpc":"2.0", - "id":3, - "method":"textDocument/hover" - }, - "wait":[ - { - "id":3, - "result": null - } - ] - } - }, - { - "send":{ - "request":{ - "params":{ - "position":{ - "line":1, - "character":4 - }, - "textDocument":{ - "uri":"$URI{prj2.gpr}" - } - }, - "jsonrpc":"2.0", - "id":4, - "method":"textDocument/hover" - }, - "wait":[ - { - "id":4, - "result":{ - "contents":[ - { - "language": "plaintext", - "value": "The list of source directories of the project." - } - ] - } - } - ] - } - }, - { - "send":{ - "request":{ - "params":{ - "position":{ - "line":3, - "character":11 - }, - "textDocument":{ - "uri":"$URI{prj1.gpr}" - } - }, - "jsonrpc":"2.0", - "id":5, - "method":"textDocument/hover" - }, - "wait":[ - { - "id":5, - "result":{ - "contents":[ - { - "language": "plaintext", - "value": "Index is a source file name or a language name. Value is the list of switches to be used when invoking the compiler for the source or for its language." - } - ] - } - } - ] - } - }, - { - "send":{ - "request":{ - "params":{ - "position":{ - "line":2, - "character":0 - }, - "textDocument":{ - "uri":"$URI{prj2.gpr}" - } - }, - "jsonrpc":"2.0", - "id":6, - "method":"textDocument/hover" - }, - "wait":[ - { - "id":6, - "result": null - } - ] - } - }, - { - "send":{ - "request":{ - "params":{ - "position":{ - "line":5, - "character":8 - }, - "textDocument":{ - "uri":"$URI{prj1.gpr}" - } - }, - "jsonrpc":"2.0", - "id":7, - "method":"textDocument/hover" - }, - "wait":[ - { - "id":7, - "result":{ - "contents":[ - { - "language": "plaintext", - "value": "This package specifies the options used by 'gnatstudio' IDE." - } - ] - } - } - ] - } - }, - { - "send":{ - "request":{ - "params":{ - "position":{ - "line":6, - "character":9 - }, - "textDocument":{ - "uri":"$URI{prj1.gpr}" - } + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "id": "init", + "method": "initialize", + "params": { + "processId": 441587, + "rootUri": "$URI{.}", + "capabilities": { + "workspace": { + "applyEdit": true, + "workspaceEdit": {}, + "didChangeConfiguration": {}, + "didChangeWatchedFiles": {}, + "executeCommand": {} }, - "jsonrpc":"2.0", - "id":8, - "method":"textDocument/hover" - }, - "wait":[ - { - "id":8, - "result":{ - "contents":[ - { - "language": "plaintext", - "value": "The directory in which the files generated by 'gnatstudio' for this project (cross-references database, locations etc.) are stored by default. Defaults to Object_Dir if not specified." - } + "textDocument": { + "synchronization": {}, + "completion": { + "dynamicRegistration": true, + "completionItem": { + "snippetSupport": true, + "documentationFormat": [ + "plaintext", + "markdown" ] - } + } + }, + "hover": {}, + "signatureHelp": {}, + "declaration": {}, + "definition": {}, + "typeDefinition": {}, + "implementation": {}, + "references": {}, + "documentHighlight": {}, + "documentSymbol": { + "hierarchicalDocumentSymbolSupport": true + }, + "codeLens": {}, + "colorProvider": {}, + "formatting": { + "dynamicRegistration": false + }, + "rangeFormatting": { + "dynamicRegistration": false + }, + "onTypeFormatting": { + "dynamicRegistration": false + }, + "foldingRange": { + "lineFoldingOnly": true + }, + "selectionRange": {}, + "linkedEditingRange": {}, + "callHierarchy": {}, + "moniker": {} } - ] - } - }, - { - "send":{ - "request":{ - "jsonrpc":"2.0", - "id":"shutdown", - "method":"shutdown", - "params":null - }, - "wait":[ - { - "id":"shutdown", - "result":null + } + } + }, + "wait": [ + { + "jsonrpc": "2.0", + "id": "init", + "result": { + "capabilities": { + "textDocumentSync": { + "openClose": true, + "change": 1 + } } - ] - } - }, - { - "send":{ - "request":{ - "jsonrpc":"2.0", - "method":"exit" - }, - "wait":[ - - ] - } - }, - { - "stop":{ - "exit_code":0 - } - } + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "initialized" + }, + "wait": [] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "$URI{prj1.gpr}", + "languageId": "Gpr", + "version": 1, + "text": "project Prj1 is\nfor Source_Dirs use (\"src\");\npackage Compiler is\nfor Switches (\"Ada\") use ();\nend Compiler;\npackage IDE is\nfor Artifacts_Dir use \"\";\nend IDE;\nend Prj1;" + } + } + }, + "wait": [] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 2, + "character": 15 + }, + "textDocument": { + "uri": "$URI{prj1.gpr}" + } + }, + "jsonrpc": "2.0", + "id": 1, + "method": "textDocument/hover" + }, + "wait": [ + { + "id": 1, + "result": { + "contents": [ + { + "language": "plaintext", + "value": "This package specifies the compilation options used by the compiler for each language." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 4, + "character": 4 + }, + "textDocument": { + "uri": "$URI{prj1.gpr}" + } + }, + "jsonrpc": "2.0", + "id": 2, + "method": "textDocument/hover" + }, + "wait": [ + { + "id": 2, + "result": { + "contents": [ + { + "language": "plaintext", + "value": "This package specifies the compilation options used by the compiler for each language." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 5, + "character": 4 + }, + "textDocument": { + "uri": "$URI{prj1.gpr}" + } + }, + "jsonrpc": "2.0", + "id": 3, + "method": "textDocument/hover" + }, + "wait": [ + { + "id": 3, + "result": null + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 1, + "character": 4 + }, + "textDocument": { + "uri": "$URI{prj1.gpr}" + } + }, + "jsonrpc": "2.0", + "id": 4, + "method": "textDocument/hover" + }, + "wait": [ + { + "id": 4, + "result": { + "contents": [ + { + "language": "plaintext", + "value": "for Source_Dirs use (\"src\");\rThe list of source directories of the project." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 3, + "character": 11 + }, + "textDocument": { + "uri": "$URI{prj1.gpr}" + } + }, + "jsonrpc": "2.0", + "id": 5, + "method": "textDocument/hover" + }, + "wait": [ + { + "id": 5, + "result": { + "contents": [ + { + "language": "plaintext", + "value": "for Switches (\"Ada\") use ();\rIndex is a source file name or a language name. Value is the list of switches to be used when invoking the compiler for the source or for its language." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 5, + "character": 8 + }, + "textDocument": { + "uri": "$URI{prj1.gpr}" + } + }, + "jsonrpc": "2.0", + "id": 7, + "method": "textDocument/hover" + }, + "wait": [ + { + "id": 7, + "result": { + "contents": [ + { + "language": "plaintext", + "value": "This package specifies the options used by 'gnatstudio' IDE." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 6, + "character": 9 + }, + "textDocument": { + "uri": "$URI{prj1.gpr}" + } + }, + "jsonrpc": "2.0", + "id": 8, + "method": "textDocument/hover" + }, + "wait": [ + { + "id": 8, + "result": { + "contents": [ + { + "language": "plaintext", + "value": "for Artifacts_Dir use \"\";\rThe directory in which the files generated by 'gnatstudio' for this project (cross-references database, locations etc.) are stored by default. Defaults to Object_Dir if not specified." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "jsonrpc": "2.0", + "method": "textDocument/didOpen", + "params": { + "textDocument": { + "uri": "$URI{prj3.gpr}", + "languageId": "Gpr", + "version": 1, + "text": "project Prj3 is\n type T is (\"project.Var value \");\n Var : T := \"project.Var value \";\n package Builder is\n Var := \"project.Builder.Var value \";\n for Global_Configuration_Pragmas use \"project.Builder'Global_Configuration_Pragmas value \";\n end Builder;\n Var1 := Var & project.Var & project.Builder.Var & project'Name & Prj3'Name & Prj3.Builder'Global_Configuration_Pragmas;\n package Compiler is\n for Switches (\"main.adb\") use (\"value1\");\n for Switches (\"main.adb\" at 1) use (\"value2\");\n for Switches (others) use (\"value3\");\n Var := Compiler'Switches (\"main.adb\") & Compiler'Switches (others);\n end Compiler;\nend Prj3;\n" + } + } + }, + "wait": [] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 2, + "character": 3 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": 9, + "method": "textDocument/hover" + }, + "wait": [ + { + "id": 9, + "result": { + "contents": [ + { + "language": "plaintext", + "value": "Var : T := \"project.Var value \";" + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 4, + "character": 5 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "4,5", + "method": "textDocument/hover" + }, + "wait": [ + { + "id": "4,5", + "result": { + "contents": [ + { + "language": "plaintext", + "value": "Var := \"project.Builder.Var value \";" + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 7, + "character": 11 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "7,11", + "method": "textDocument/hover" + }, + "wait": [ + { + "id": "7,11", + "result": { + "contents": [ + { + "language": "plaintext", + "value": "Var : T := \"project.Var value \";" + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 7, + "character": 19 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "7,19", + "method": "textDocument/hover" + }, + "wait": [ + { + "id": "7,19", + "result": null + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 7, + "character": 25 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "7,25", + "method": "textDocument/hover" + }, + "wait": [ + { + "id": "7,25", + "result": { + "contents": [ + { + "language": "plaintext", + "value": "Var : T := \"project.Var value \";" + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 7, + "character": 40 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "7,40", + "method": "textDocument/hover" + }, + "wait": [ + { + "id": "7,40", + "result": { + "contents": [ + { + "language": "plaintext", + "value": "This package specifies the compilation options used when building an executable or a library for a project. Most of the options should be set in one of Compiler, Binder or Linker packages, but there are some general options that should be defined in this package." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 7, + "character": 48 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "7,48", + "method": "textDocument/hover" + }, + "wait": [ + { + "id": "7,48", + "result": { + "contents": [ + { + "language": "plaintext", + "value": "Var := \"project.Builder.Var value \";" + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 7, + "character": 63 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "7,63", + "method": "textDocument/hover" + }, + "wait": [ + { + "id": "7,63", + "result": { + "contents": [ + { + "language": "plaintext", + "value": "for Name use \"prj3\";\rThe name of the project." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 7, + "character": 74 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "7,74", + "method": "textDocument/hover" + }, + "wait": [ + { + "id": "7,74", + "result": { + "contents": [ + { + "language": "plaintext", + "value": "for Name use \"prj3\";\rThe name of the project." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 7, + "character": 89 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "7,89", + "method": "textDocument/hover" + }, + "wait": [ + { + "id": "7,89", + "result": { + "contents": [ + { + "language": "plaintext", + "value": "This package specifies the compilation options used when building an executable or a library for a project. Most of the options should be set in one of Compiler, Binder or Linker packages, but there are some general options that should be defined in this package." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 9, + "character": 13 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "9,13", + "method": "textDocument/hover" + }, + "wait": [ + { + "id": "9,13", + "result": { + "contents": [ + { + "language": "plaintext", + "value": "for Switches (\"main.adb\") use (\"value1\");\rIndex is a source file name or a language name. Value is the list of switches to be used when invoking the compiler for the source or for its language." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 10, + "character": 13 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "10,13", + "method": "textDocument/hover" + }, + "wait": [ + { + "id": "10,13", + "result": { + "contents": [ + { + "language": "plaintext", + "value": "for Switches (\"main.adb\") use (\"value2\");\rIndex is a source file name or a language name. Value is the list of switches to be used when invoking the compiler for the source or for its language." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 11, + "character": 11 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "11,11", + "method": "textDocument/hover" + }, + "wait": [ + { + "id": "11,11", + "result": { + "contents": [ + { + "language": "plaintext", + "value": "for Switches (others) use (\"value3\");\rIndex is a source file name or a language name. Value is the list of switches to be used when invoking the compiler for the source or for its language." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 12, + "character": 15 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "12,15", + "method": "textDocument/hover" + }, + "wait": [ + { + "id": "12,15", + "result": { + "contents": [ + { + "language": "plaintext", + "value": "This package specifies the compilation options used by the compiler for each language." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 12, + "character": 24 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "12,24", + "method": "textDocument/hover" + }, + "wait": [ + { + "id": "12,24", + "result": { + "contents": [ + { + "language": "plaintext", + "value": "for Switches (\"main.adb\") use (\"value1\");\rIndex is a source file name or a language name. Value is the list of switches to be used when invoking the compiler for the source or for its language." + } + ] + } + } + ] + } + }, + { + "send": { + "request": { + "params": { + "position": { + "line": 12, + "character": 58 + }, + "textDocument": { + "uri": "$URI{prj3.gpr}" + } + }, + "jsonrpc": "2.0", + "id": "12,58", + "method": "textDocument/hover" + }, + "wait": [ + { + "id": "12,58", + "result": { + "contents": [ + { + "language": "plaintext", + "value": "for Switches (others) use (\"value3\");\rIndex is a source file name or a language name. Value is the list of switches to be used when invoking the compiler for the source or for its language." + } + ] + } + } + ] + } + }, + { + "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 + } + } ] \ No newline at end of file