Skip to content

Commit

Permalink
Merge remote branch 'origin/master' into edge
Browse files Browse the repository at this point in the history
  • Loading branch information
automatic-merge committed Feb 28, 2024
2 parents 9fbdddc + a5e57f0 commit b6ee150
Show file tree
Hide file tree
Showing 20 changed files with 2,138 additions and 278 deletions.
25 changes: 19 additions & 6 deletions source/gpr/lsp-gpr_completions.adb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
------------------------------------------------------------------------------
-- Language Server Protocol --
-- --
-- Copyright (C) 2023, AdaCore --
-- Copyright (C) 2023-2024, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
Expand All @@ -27,6 +27,7 @@ with Gpr_Parser.Common;
with Gpr_Parser_Support.Text;

with LSP.Structures.LSPAny_Vectors;
with LSP.Text_Documents.Langkit_Documents;

with VSS.String_Vectors;
with VSS.Strings.Conversions;
Expand All @@ -40,6 +41,7 @@ package body LSP.GPR_Completions is
package PRAD renames GPR2.Project.Registry.Attribute.Description;
package PRP renames GPR2.Project.Registry.Pack;
package PRPD renames GPR2.Project.Registry.Pack.Description;
package LKD renames LSP.Text_Documents.Langkit_Documents;

procedure Fill_Attribute_Completion_Response
(File : LSP.GPR_Files.File;
Expand Down Expand Up @@ -187,10 +189,19 @@ package body LSP.GPR_Completions is
(File_Provider => File_Provider,
Path => File_Provider.To_File
(Value.textDocument.uri));
Current : constant GPC.Token_Reference := File.Token (Value.position);

Location : constant Gpr_Parser.Slocs.Source_Location :=
LSP.GPR_Files.To_Langkit_Location
(LKD.To_Source_Location
(Line_Text => File.Get_Line
(LKD.To_Source_Line (Value.position.line)),
Position => Value.position));

Current : constant GPC.Token_Reference := File.Token (Location);

In_Comment : constant Boolean :=
LSP.GPR_Files.Position_Is_In_Comment
(Current, Value.position);
LSP.GPR_Files.Position_Is_In_Comment (Current, Location);

Previous : constant GPC.Token_Reference := Current.Previous (True);

function To_String
Expand All @@ -207,7 +218,8 @@ package body LSP.GPR_Completions is
and then Previous /= GPC.No_Token
then
if Previous.Data.Kind in GPC.Gpr_For | GPC.Gpr_Package then
if not LSP.GPR_Files.At_End (Previous, Value.position) then
if not LSP.GPR_Files.At_End (Previous.Data.Sloc_Range, Location)
then
case Previous.Data.Kind is

when GPC.Gpr_For =>
Expand All @@ -232,7 +244,8 @@ package body LSP.GPR_Completions is
end if;

elsif Previous.Data.Kind = GPC.Gpr_Identifier
and then LSP.GPR_Files.At_End (Previous, Value.position)
and then LSP.GPR_Files.At_End
(Previous.Data.Sloc_Range, Location)
then
declare
Before_Identifier : constant GPC.Token_Reference :=
Expand Down
16 changes: 14 additions & 2 deletions source/gpr/lsp-gpr_documentation.adb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
------------------------------------------------------------------------------
-- Language Server Protocol --
-- --
-- Copyright (C) 2023, AdaCore --
-- Copyright (C) 2023-2024, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
Expand All @@ -21,6 +21,9 @@ with Gpr_Parser.Common;

with GPR2.Project.Registry.Attribute.Description;
with GPR2.Project.Registry.Pack.Description;

with LSP.Text_Documents.Langkit_Documents;

with VSS.Strings.Conversions;

package body LSP.GPR_Documentation is
Expand All @@ -31,7 +34,16 @@ package body LSP.GPR_Documentation is
Tooltip_Text : out VSS.Strings.Virtual_String) is
use Gpr_Parser.Common;

Token : constant Token_Reference := Self.Token (Position);
package LKD renames LSP.Text_Documents.Langkit_Documents;

Location : constant Gpr_Parser.Slocs.Source_Location :=
LSP.GPR_Files.To_Langkit_Location
(LKD.To_Source_Location
(Line_Text => Self.Get_Line
(LKD.To_Source_Line (Position.line)),
Position => Position));

Token : constant Token_Reference := Self.Token (Location);

use GPR2.Project.Registry.Attribute.Description;
use GPR2.Project.Registry.Pack.Description;
Expand Down
2 changes: 1 addition & 1 deletion source/gpr/lsp-gpr_external_tools.adb
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ package body LSP.GPR_External_Tools is
if not Exists (Name) then
Add (Name, Projects);
end if;
if Get_Package_Description (Name)'Length > 0
if Get_Package_Description (Name)'Length = 0
and then Description'Length > 0
then
Set_Package_Description (Name, Description);
Expand Down
5 changes: 1 addition & 4 deletions source/gpr/lsp-gpr_file_readers.adb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
------------------------------------------------------------------------------
-- Language Server Protocol --
-- --
-- Copyright (C) 2023, AdaCore --
-- Copyright (C) 2023-2024, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
Expand Down Expand Up @@ -36,7 +36,6 @@ with VSS.Strings.Converters.Decoders;
with VSS.Strings.Conversions;

with LSP.GPR_Documents; use LSP.GPR_Documents;
with LSP.Structures;
with URIs;

with Langkit_Support.Text;
Expand Down Expand Up @@ -67,8 +66,6 @@ package body LSP.GPR_File_Readers is
-- present
-- Default flags for the text decoder.

function To_URI (Item : String) return LSP.Structures.DocumentUri;

------------
-- Create --
------------
Expand Down
5 changes: 4 additions & 1 deletion source/gpr/lsp-gpr_file_readers.ads
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
------------------------------------------------------------------------------
-- Language Server Protocol --
-- --
-- Copyright (C) 2023, AdaCore --
-- Copyright (C) 2023-2024, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
Expand All @@ -22,6 +22,7 @@ with GPR2.File_Readers;
with GPR2.Log;

with LSP.GPR_Handlers;
with LSP.Structures;

package LSP.GPR_File_Readers is

Expand All @@ -42,6 +43,8 @@ package LSP.GPR_File_Readers is
(Handler : access LSP.GPR_Handlers.Message_Handler)
return GPR2.File_Readers.File_Reader_Reference;

function To_URI (Item : String) return LSP.Structures.DocumentUri;

private

type File_Reader is new GPR2.File_Readers.File_Reader_Interface with
Expand Down
Loading

0 comments on commit b6ee150

Please sign in to comment.