1818-- This package provides types to support completions in Ada Language server.
1919
2020with Ada.Containers.Hashed_Maps ;
21+ with Ada.Strings.Hash_Case_Insensitive ;
2122
2223with Langkit_Support.Slocs ;
24+ with Langkit_Support.Text ;
2325with Libadalang.Analysis ;
2426with Libadalang.Common ;
2527
@@ -32,12 +34,14 @@ package LSP.Ada_Completions is
3234
3335 function Hash (Name : Libadalang.Analysis.Defining_Name)
3436 return Ada.Containers.Hash_Type is
35- (Name.As_Ada_Node.Hash);
37+ (Ada.Strings.Hash_Case_Insensitive (
38+ Langkit_Support.Text.To_UTF8 (Name.Full_Sloc_Image)));
3639
37- function Is_Equal (Left, Right : Libadalang.Analysis.Defining_Name)
38- return Boolean;
39- -- This custom Is_Equal function is here as a temporary workaround.
40- -- The ticket for the corresponding compiler bug is T806-020.
40+ function Is_Full_Sloc_Equal
41+ (Left, Right : Libadalang.Analysis.Defining_Name) return Boolean;
42+ -- Compare the two nodes using full sloc image (filename + sloc). Needed
43+ -- for completion, since LAL can return several times the same declaration
44+ -- and specially subprograms from generic instantiations.
4145
4246 type Name_Information is record
4347 Is_Dot_Call : Boolean;
@@ -59,7 +63,7 @@ package LSP.Ada_Completions is
5963 (Key_Type => Libadalang.Analysis.Defining_Name,
6064 Element_Type => Name_Information,
6165 Hash => Hash,
62- Equivalent_Keys => Is_Equal ,
66+ Equivalent_Keys => Is_Full_Sloc_Equal ,
6367 " =" => " =" );
6468
6569 type Completion_Provider is abstract tagged limited null record ;
0 commit comments