Skip to content

Commit de05e4a

Browse files
committed
T826-026 Workspace_Symbols Request
Do not process too small pattern because this produces a huge response that is useless and costs a while. Corrections for requests cancelling
1 parent 689a961 commit de05e4a

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

source/ada/lsp-ada_handlers.adb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3751,14 +3751,17 @@ package body LSP.Ada_Handlers is
37513751
Request : LSP.Messages.Server_Requests.Workspace_Symbols_Request)
37523752
return LSP.Messages.Server_Responses.Symbol_Response
37533753
is
3754+
use type LSP.Messages.Search_Kind;
3755+
use type VSS.Strings.Character_Count;
3756+
37543757
procedure On_Inaccessible_Name
37553758
(File : GNATCOLL.VFS.Virtual_File;
37563759
Name : Libadalang.Analysis.Defining_Name;
37573760
Stop : in out Boolean);
37583761

37593762
Names : LSP.Ada_Completions.Completion_Maps.Map;
37603763

3761-
package Canceled is new LSP.Generic_Cancel_Check (Request, 127);
3764+
package Canceled is new LSP.Generic_Cancel_Check (Request'Access, 127);
37623765

37633766
procedure Write_Symbols is
37643767
new LSP.Ada_Completions.Generic_Write_Symbols
@@ -3803,6 +3806,16 @@ package body LSP.Ada_Handlers is
38033806
(Is_Error => False);
38043807

38053808
begin
3809+
if Pattern.Get_Kind /= LSP.Messages.Start_Word_Text
3810+
and then Pattern.Get_Canonical_Pattern.Character_Length < 2
3811+
then
3812+
-- Do not process too small pattern because
3813+
-- this produces a huge response that is useless
3814+
-- and costs a while.
3815+
3816+
return Response;
3817+
end if;
3818+
38063819
for Context of Self.Contexts.Each_Context loop
38073820
Context.Get_Any_Symbol
38083821
(Pattern => Pattern,

source/server/lsp-generic_cancel_check.ads

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
with LSP.Messages.Server_Requests;
2424

2525
generic
26-
Request : LSP.Messages.Server_Requests.Server_Request'Class;
26+
Request : access constant LSP.Messages.Server_Requests.Server_Request'Class;
2727
-- A request to check cancelation
28+
2829
Max_Skip_Count : Natural;
2930
-- How much checks to skip before make a real atomic flag check
3031

3132
package LSP.Generic_Cancel_Check is
3233

33-
function Has_Been_Canceled return Boolean
34-
with Inline;
34+
function Has_Been_Canceled return Boolean with Inline;
3535

3636
end LSP.Generic_Cancel_Check;

testsuite/ada_lsp/workspace_symbol/test.json

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,13 @@
7171
"id":"wsSymbol",
7272
"method":"workspace/symbol",
7373
"params":{
74-
"query":""
74+
"query":"Test"
7575
}
7676
},
7777
"sortReply": {"result":"name"},
7878
"wait":[{
7979
"id": "wsSymbol",
8080
"result": [
81-
{
82-
"name": "Main",
83-
"kind": 12,
84-
"location": {
85-
"uri": "$URI{main.adb}",
86-
"range": {
87-
"start": {
88-
"line": 0,
89-
"character": 10
90-
},
91-
"end": {
92-
"line": 0,
93-
"character": 14
94-
}
95-
}
96-
}
97-
},
9881
{
9982
"name": "Test1",
10083
"kind": 12,

0 commit comments

Comments
 (0)