Skip to content

Commit 8acaaa3

Browse files
author
mergerepo
committed
Merge remote branch 'origin/master' into edge
(no-precommit-check no-tn-check)
2 parents bab8507 + 9bc738e commit 8acaaa3

File tree

21 files changed

+56
-41
lines changed

21 files changed

+56
-41
lines changed

.github/workflows/build-binaries.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ fi
1313
export GPR_PROJECT_PATH=$prefix/share/gpr:\
1414
$PWD/subprojects/VSS/gnat:\
1515
$PWD/subprojects/gnatdoc/gnat:\
16-
$PWD/subprojects/gpr-unit-provider:\
1716
$PWD/subprojects/libadalang-tools/src:\
1817
$PWD/subprojects/spawn/gnat:\
1918
$PWD/subprojects/stubs

.github/workflows/build-binaries.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,6 @@ jobs:
8686
with:
8787
repository: AdaCore/gnatdoc
8888
path: subprojects/gnatdoc
89-
- name: Get gpr-unit-provider
90-
uses: actions/checkout@v2
91-
with:
92-
repository: AdaCore/gpr-unit-provider
93-
path: subprojects/gpr-unit-provider
9489
- uses: actions/cache@v2
9590
with:
9691
path: ./cached_gnat

Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ LIBRARY_TYPE?=relocatable
2525

2626
# Build mode (dev or prod)
2727
BUILD_MODE=dev
28-
GPR_UNIT_PROVIDER_BUILD=debug
2928

3029
# Whether to enable coverage (empty for no, any other value for yes)
3130
COVERAGE=
@@ -51,8 +50,7 @@ else
5150
EXE=
5251
endif
5352

54-
LIBRARY_FLAGS=-XGPR_UNIT_PROVIDER_BUILD=$(GPR_UNIT_PROVIDER_BUILD) \
55-
-XBUILD_MODE=$(BUILD_MODE) \
53+
LIBRARY_FLAGS=-XBUILD_MODE=$(BUILD_MODE) \
5654
-XOS=$(OS) \
5755
-XLIBRARY_TYPE=$(LIBRARY_TYPE) \
5856
-XXMLADA_BUILD=$(LIBRARY_TYPE) \

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ To build the language server you need:
7777
* The [VSS](https://github.com/AdaCore/VSS) library
7878
* The [gnatdoc](https://github.com/AdaCore/gnatdoc) library
7979
* The [gpr](https://github.com/AdaCore/gpr) library
80-
* The [gpr-unit-provider](https://github.com/AdaCore/gpr-unit-provider) library
8180
* The a process [spawn](https://github.com/AdaCore/spawn) library
8281

8382
Project files of the libraries must be available via the `GPR_PROJECT_PATH`

gnat/lsp_server.gpr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
------------------------------------------------------------------------------
1717

1818
with "gpr2.gpr";
19-
with "gpr_unit_provider.gpr";
2019
with "libadalang";
2120
with "lal_tools.gpr";
2221
with "ada_libfswatch.gpr";

source/ada/lsp-ada_completions-names.adb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ package body LSP.Ada_Completions.Names is
128128
(Is_Dot_Call => False,
129129
Is_Visible => True,
130130
Use_Snippets => Use_Snippets,
131-
Pos => 1));
131+
Pos => 1,
132+
Weight => 0));
132133
return;
133134
end if;
134135
end if;
@@ -174,7 +175,8 @@ package body LSP.Ada_Completions.Names is
174175
(Is_Dot_Call (Item),
175176
Is_Visible (Item),
176177
Use_Snippets,
177-
Completion_Count));
178+
Completion_Count,
179+
Weight (Item)));
178180
end if;
179181
end loop;
180182
end if;

source/ada/lsp-ada_completions.adb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ package body LSP.Ada_Completions is
9999
Is_Dot_Call => Info.Is_Dot_Call,
100100
Is_Visible => Info.Is_Visible,
101101
Pos => Info.Pos,
102+
Weight => Info.Weight,
102103
Completions_Count => Length));
103104
end if;
104105
end;

source/ada/lsp-ada_completions.ads

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ package LSP.Ada_Completions is
4343
-- for completion, since LAL can return several times the same declaration
4444
-- and specially subprograms from generic instantiations.
4545

46+
subtype Completion_Item_Weight_Type is Integer range 0 .. 100;
47+
-- Type representing the weight returned by LAL for each completion item.
48+
-- Used to sort them accordingly on the client-side.
49+
4650
type Name_Information is record
4751
Is_Dot_Call : Boolean;
4852
-- True if we are dealing with a dotted call.
@@ -57,6 +61,9 @@ package LSP.Ada_Completions is
5761
Pos : Integer := -1;
5862
-- The position of the item in the fully computed completion list. Used
5963
-- for sorting properly the items on client-side.
64+
65+
Weight : Completion_Item_Weight_Type := 0;
66+
-- The completion item's weight. Used for sorting on the client-side.
6067
end record;
6168

6269
package Completion_Maps is new Ada.Containers.Hashed_Maps

source/ada/lsp-ada_documents.adb

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1838,6 +1838,7 @@ package body LSP.Ada_Documents is
18381838
Is_Dot_Call : Boolean;
18391839
Is_Visible : Boolean;
18401840
Pos : Integer;
1841+
Weight : Completion_Item_Weight_Type;
18411842
Completions_Count : Natural)
18421843
return LSP.Messages.CompletionItem
18431844
is
@@ -1860,14 +1861,22 @@ package body LSP.Ada_Documents is
18601861

18611862
function Get_Sort_Text
18621863
(Base_Label : VSS.Strings.Virtual_String)
1863-
return VSS.Strings.Virtual_String is
1864+
return VSS.Strings.Virtual_String
1865+
is
1866+
use VSS.Strings;
18641867
begin
18651868
return Sort_Text : VSS.Strings.Virtual_String do
1866-
if Pos /= -1 then
1867-
Sort_Text :=
1868-
VSS.Strings.Conversions.To_Virtual_String
1869-
(GNATCOLL.Utils.Image (Pos, Min_Width => Min_Width));
1870-
end if;
1869+
1870+
Sort_Text :=
1871+
VSS.Strings.Conversions.To_Virtual_String
1872+
(GNATCOLL.Utils.Image
1873+
(Value => Completion_Item_Weight_Type'Last - Weight,
1874+
Min_Width =>
1875+
Completion_Item_Weight_Type'Last'Img'Length - 1)) & "&";
1876+
1877+
Sort_Text := Sort_Text &
1878+
VSS.Strings.Conversions.To_Virtual_String
1879+
(GNATCOLL.Utils.Image (Pos, Min_Width => Min_Width));
18711880

18721881
Sort_Text.Append (Base_Label);
18731882

@@ -2146,7 +2155,8 @@ package body LSP.Ada_Documents is
21462155
(Is_Dot_Call => False,
21472156
Is_Visible => False,
21482157
Use_Snippets => False,
2149-
Pos => <>));
2158+
Pos => <>,
2159+
Weight => <>));
21502160
end if;
21512161
end Insert;
21522162

source/ada/lsp-ada_documents.ads

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ with GNATCOLL.Traces;
3333
with Pp.Command_Lines;
3434

3535
limited with LSP.Ada_Contexts;
36-
with LSP.Ada_Completions;
36+
with LSP.Ada_Completions; use LSP.Ada_Completions;
3737
with LSP.Ada_Highlighters;
3838
with LSP.Diagnostic_Sources;
3939
with LSP.Messages;
@@ -252,6 +252,7 @@ package LSP.Ada_Documents is
252252
Is_Dot_Call : Boolean;
253253
Is_Visible : Boolean;
254254
Pos : Integer;
255+
Weight : Completion_Item_Weight_Type;
255256
Completions_Count : Natural)
256257
return LSP.Messages.CompletionItem;
257258
-- Compute a completion item.
@@ -264,6 +265,8 @@ package LSP.Ada_Documents is
264265
-- named notation is used for subprogram completion snippets.
265266
-- Is_Dot_Call is used to know if we should omit the first parameter
266267
-- when computing subprogram snippets.
268+
-- Weight is used for sorting: items with an higher weight will be placed
269+
-- at the top.
267270
-- Completions_Count is the total number of completion items.
268271

269272
procedure Set_Completion_Item_Documentation

0 commit comments

Comments
 (0)