Skip to content

Commit 1090225

Browse files
author
mergerepo
committed
Merge remote branch 'origin/master' into edge
(no-precommit-check no-tn-check)
2 parents 6dbe48a + 2fc9fa8 commit 1090225

File tree

120 files changed

+489
-165
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+489
-165
lines changed

scripts/generate.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,8 @@
257257
'CodeAction_Response'),
258258
('textDocument/completion', 'Completion', 'TextDocumentPositionParams',
259259
'Completion_Response'),
260+
('completionItem/resolve', 'CompletionItemResolve', 'CompletionItem',
261+
'CompletionItemResolve_Response'),
260262
('textDocument/definition', 'Definition', 'DefinitionParams',
261263
'Location_Link_Response'),
262264
('textDocument/declaration', 'Declaration', 'DeclarationParams',

source/ada/lsp-ada_completions.adb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ package body LSP.Ada_Completions is
4343
(Context : LSP.Ada_Contexts.Context;
4444
Names : Completion_Maps.Map;
4545
Named_Notation_Threshold : Natural;
46+
Compute_Doc_And_Details : Boolean;
4647
Result : in out LSP.Messages.CompletionItem_Vector)
4748
is
4849
function Hash (Value : VSS.Strings.Virtual_String)
@@ -91,6 +92,7 @@ package body LSP.Ada_Completions is
9192
BD => Name.P_Basic_Decl,
9293
Label => Label,
9394
Use_Snippets => Info.Use_Snippets,
95+
Compute_Doc_And_Details => Compute_Doc_And_Details,
9496
Named_Notation_Threshold => Named_Notation_Threshold,
9597
Is_Dot_Call => Info.Is_Dot_Call,
9698
Is_Visible => Info.Is_Visible,
@@ -102,11 +104,11 @@ package body LSP.Ada_Completions is
102104
end loop;
103105
end Write_Completions;
104106

105-
-------------------
106-
-- Write_Symbols --
107-
-------------------
107+
---------------------------
108+
-- Generic_Write_Symbols --
109+
---------------------------
108110

109-
procedure Write_Symbols
111+
procedure Generic_Write_Symbols
110112
(Names : Completion_Maps.Map;
111113
Result : in out LSP.Messages.Symbol_Vector) is
112114
begin
@@ -139,6 +141,6 @@ package body LSP.Ada_Completions is
139141
exit when Has_Been_Canceled;
140142
end;
141143
end loop;
142-
end Write_Symbols;
144+
end Generic_Write_Symbols;
143145

144146
end LSP.Ada_Completions;

source/ada/lsp-ada_completions.ads

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,19 @@ package LSP.Ada_Completions is
8888
(Context : LSP.Ada_Contexts.Context;
8989
Names : Completion_Maps.Map;
9090
Named_Notation_Threshold : Natural;
91+
Compute_Doc_And_Details : Boolean;
9192
Result : in out LSP.Messages.CompletionItem_Vector);
93+
-- Convert all the completion Names into LSP completion items' results.
94+
-- Named_Notation_Threshold defines the number of parameters/components at
95+
-- which point named notation is used for subprogram/aggregate completion
96+
-- snippets.
97+
-- If Compute_Doc_And_Details is True, the 'detail' and 'documentation'
98+
-- fields for all the resulting completion items will be computed
99+
-- immediately, which might take time.
92100

93101
generic
94102
with function Has_Been_Canceled return Boolean;
95-
procedure Write_Symbols
103+
procedure Generic_Write_Symbols
96104
(Names : Completion_Maps.Map;
97105
Result : in out LSP.Messages.Symbol_Vector);
98106

source/ada/lsp-ada_contexts.ads

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ package LSP.Ada_Contexts is
232232
(Self : Context;
233233
Pattern : LSP.Search.Search_Pattern'Class;
234234
Only_Public : Boolean;
235-
Callback : not null access procedure
235+
Callback : not null access procedure
236236
(File : GNATCOLL.VFS.Virtual_File;
237237
Name : Libadalang.Analysis.Defining_Name;
238238
Stop : in out Boolean));

source/ada/lsp-ada_documents.adb

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ with Langkit_Support.Symbols;
3030
with Langkit_Support.Text;
3131
with Libadalang.Analysis; use Libadalang.Analysis;
3232
with Libadalang.Sources;
33-
with Libadalang.Doc_Utils;
3433
with Libadalang.Iterators;
3534

3635
with VSS.String_Vectors;
@@ -1764,6 +1763,7 @@ package body LSP.Ada_Documents is
17641763
BD : Libadalang.Analysis.Basic_Decl;
17651764
Label : VSS.Strings.Virtual_String;
17661765
Use_Snippets : Boolean;
1766+
Compute_Doc_And_Details : Boolean;
17671767
Named_Notation_Threshold : Natural;
17681768
Is_Dot_Call : Boolean;
17691769
Is_Visible : Boolean;
@@ -1776,8 +1776,6 @@ package body LSP.Ada_Documents is
17761776

17771777
Item : CompletionItem;
17781778
Subp_Spec_Node : Base_Subp_Spec;
1779-
Doc_Text : VSS.Strings.Virtual_String;
1780-
Loc_Text : VSS.Strings.Virtual_String;
17811779
Min_Width : constant Natural := Completions_Count'Img'Length - 1;
17821780

17831781
function Get_Sort_text (Base_Label : LSP_String) return LSP_String;
@@ -1815,9 +1813,6 @@ package body LSP.Ada_Documents is
18151813
Item.label := Label;
18161814
Item.kind := (True, To_Completion_Kind
18171815
(LSP.Lal_Utils.Get_Decl_Kind (BD)));
1818-
Item.detail := (True,
1819-
LSP.Types.To_LSP_String
1820-
(LSP.Lal_Utils.Compute_Completion_Detail (BD)));
18211816

18221817
declare
18231818
Base_Label : constant LSP_String := LSP.Types.To_LSP_String
@@ -1836,41 +1831,39 @@ package body LSP.Ada_Documents is
18361831
end if;
18371832
end;
18381833

1839-
-- Property_Errors can occur when calling
1840-
-- Get_Documentation on unsupported docstrings, so
1841-
-- add an exception handler to catch them and recover.
1842-
1843-
begin
1844-
Doc_Text :=
1845-
VSS.Strings.To_Virtual_String
1846-
(Libadalang.Doc_Utils.Get_Documentation
1847-
(BD).Doc.To_String);
1848-
1849-
-- Append the declaration's location.
1850-
-- In addition, append the project's name if we are dealing with an
1851-
-- aggregate project.
1852-
1853-
Loc_Text.Append (LSP.Lal_Utils.Node_Location_Image (BD));
1854-
1855-
if not Doc_Text.Is_Empty then
1856-
Loc_Text.Append
1857-
(VSS.Strings.To_Virtual_String
1858-
((1 .. 2 => Ada.Characters.Wide_Wide_Latin_1.LF)));
1859-
1860-
Loc_Text.Append (Doc_Text);
1861-
end if;
1862-
1863-
Item.documentation :=
1864-
(Is_Set => True,
1865-
Value => String_Or_MarkupContent'
1866-
(Is_String => True,
1867-
String => Loc_Text));
1868-
1869-
exception
1870-
when E : Libadalang.Common.Property_Error =>
1871-
LSP.Common.Log (Context.Trace, E);
1872-
Item.documentation := (others => <>);
1873-
end;
1834+
-- Compute the 'documentation' and 'detail' fields immediately if
1835+
-- requested (i.e: when the client does not support lazy computation
1836+
-- for these fields).
1837+
if Compute_Doc_And_Details then
1838+
Item.detail :=
1839+
(True,
1840+
LSP.Types.To_LSP_String
1841+
(LSP.Lal_Utils.Compute_Completion_Detail (BD)));
1842+
1843+
-- Property_Errors can occur when calling
1844+
-- Get_Documentation on unsupported docstrings, so
1845+
-- add an exception handler to catch them and recover.
1846+
begin
1847+
Item.documentation :=
1848+
(Is_Set => True,
1849+
Value => String_Or_MarkupContent'
1850+
(Is_String => True,
1851+
String => LSP.Lal_Utils.Compute_Completion_Doc (BD)));
1852+
1853+
exception
1854+
when E : Libadalang.Common.Property_Error =>
1855+
LSP.Common.Log (Context.Trace, E);
1856+
Item.documentation := (others => <>);
1857+
end;
1858+
else
1859+
-- Set node's location to the 'data' field of the completion item, so
1860+
-- that we can retrieve it in the completionItem/resolve handler.
1861+
Item.data :=
1862+
(True,
1863+
(uri => File_To_URI (BD.Unit.Get_Filename),
1864+
span => LSP.Lal_Utils.To_Span (BD.Sloc_Range),
1865+
others => <>));
1866+
end if;
18741867

18751868
-- Return immediately if we should not use snippets (e.g: completion for
18761869
-- invisible symbols).
@@ -2018,6 +2011,7 @@ package body LSP.Ada_Documents is
20182011
Pattern : LSP.Search.Search_Pattern'Class;
20192012
Limit : Ada.Containers.Count_Type;
20202013
Only_Public : Boolean;
2014+
Canceled : access function return Boolean;
20212015
Result : in out LSP.Ada_Completions.Completion_Maps.Map)
20222016
is
20232017
use type LSP.Messages.Search_Kind;
@@ -2121,19 +2115,23 @@ package body LSP.Ada_Documents is
21212115
then
21222116
Insert (Item);
21232117
end if;
2118+
2119+
exit when Canceled.all;
21242120
end loop;
21252121

21262122
elsif Pattern.Match (Symbol_Maps.Key (Cursor)) then
21272123
-- Symbol_Cache is case insensitive so if the key is matched
21282124
-- this means that all elements are also matched the pattern
21292125
for Item of Self.Symbol_Cache (Cursor) loop
21302126
Insert (Item);
2127+
2128+
exit when Canceled.all;
21312129
end loop;
21322130

21332131
else
21342132
-- Symbol_Cache is ordered so we will not find any
21352133
-- matches more
2136-
exit when Use_Celling;
2134+
exit when Use_Celling or else Canceled.all;
21372135
end if;
21382136

21392137
Symbol_Maps.Next (Cursor);

source/ada/lsp-ada_documents.ads

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ package LSP.Ada_Documents is
147147
Pattern : LSP.Search.Search_Pattern'Class;
148148
Limit : Ada.Containers.Count_Type;
149149
Only_Public : Boolean;
150+
Canceled : access function return Boolean;
150151
Result : in out LSP.Ada_Completions.Completion_Maps.Map);
151152
-- See Contexts.Get_Any_Symbol
152153

@@ -234,6 +235,7 @@ package LSP.Ada_Documents is
234235
BD : Libadalang.Analysis.Basic_Decl;
235236
Label : VSS.Strings.Virtual_String;
236237
Use_Snippets : Boolean;
238+
Compute_Doc_And_Details : Boolean;
237239
Named_Notation_Threshold : Natural;
238240
Is_Dot_Call : Boolean;
239241
Is_Visible : Boolean;

source/ada/lsp-ada_handlers-invisibles.adb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ package body LSP.Ada_Handlers.Invisibles is
8282
then Libadalang.Common.Previous (Token, True)
8383
else Token);
8484

85+
function Dummy_Canceled return Boolean is (False);
86+
8587
begin
8688
if Libadalang.Common.Kind (Dot_Token) = Ada_Dot then
8789
-- Don't provide completion after a dot
@@ -140,6 +142,7 @@ package body LSP.Ada_Handlers.Invisibles is
140142
Pattern,
141143
Limit,
142144
True,
145+
Dummy_Canceled'Access,
143146
Names);
144147
end loop;
145148
end;

0 commit comments

Comments
 (0)