Skip to content

Commit 2358d55

Browse files
author
mergerepo
committed
Merge remote branch 'origin/master' into edge
(no-precommit-check no-tn-check)
2 parents 960d062 + 835653c commit 2358d55

File tree

4 files changed

+52
-3
lines changed

4 files changed

+52
-3
lines changed

source/tester/tester-tests.adb

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,40 @@ package body Tester.Tests is
151151
is
152152
use type Ada.Calendar.Time;
153153

154+
procedure Check_Unique_Id (Request_Id : GNATCOLL.JSON.JSON_Value);
155+
-- Check if Request_Id is unique over all request ids
156+
157+
---------------------
158+
-- Check_Unique_Id --
159+
---------------------
160+
161+
procedure Check_Unique_Id (Request_Id : GNATCOLL.JSON.JSON_Value) is
162+
Id : VSS.Strings.Virtual_String;
163+
begin
164+
case Request_Id.Kind is
165+
when GNATCOLL.JSON.JSON_String_Type =>
166+
Id := VSS.Strings.Conversions.To_Virtual_String
167+
(String'(Request_Id.Get));
168+
when GNATCOLL.JSON.JSON_Int_Type =>
169+
Id := VSS.Strings.Conversions.To_Virtual_String
170+
(Integer'Image (Request_Id.Get));
171+
when others =>
172+
raise Program_Error with "Unexpected 'id' type!";
173+
end case;
174+
175+
if Self.Known_Ids.Contains (Id) then
176+
declare
177+
Text : Spawn.String_Vectors.UTF_8_String_Vector;
178+
begin
179+
Text.Append ("Duplicated request id:");
180+
Text.Append (VSS.Strings.Conversions.To_UTF_8_String (Id));
181+
Self.Do_Fail (Text);
182+
end;
183+
else
184+
Self.Known_Ids.Insert (Id);
185+
end if;
186+
end Check_Unique_Id;
187+
154188
Request : constant GNATCOLL.JSON.JSON_Value := Command.Get ("request");
155189
Wait : constant GNATCOLL.JSON.JSON_Array := Get (Command, "wait");
156190
Sort : constant GNATCOLL.JSON.JSON_Value := Command.Get ("sortReply");
@@ -160,6 +194,10 @@ package body Tester.Tests is
160194

161195
Timeout : constant Duration := Max_Wait * Wait_Factor (Command);
162196
begin
197+
if Request.Has_Field ("id") and Request.Has_Field ("method") then
198+
Check_Unique_Id (Request.Get ("id"));
199+
end if;
200+
163201
Self.Started := Ada.Calendar.Clock;
164202
Self.Waits := Wait;
165203
Self.Sort_Reply := Sort;

source/tester/tester-tests.ads

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
------------------------------------------------------------------------------
1717

1818
with Ada.Calendar;
19+
with Ada.Containers.Hashed_Sets;
1920
with Ada.Strings.Unbounded;
2021

2122
private with VSS.Strings;
23+
private with VSS.Strings.Hash;
2224

2325
with GNATCOLL.JSON;
2426

@@ -47,6 +49,12 @@ private
4749
entry Cancel;
4850
end Watch_Dog_Task;
4951

52+
package String_Sets is new Ada.Containers.Hashed_Sets
53+
(VSS.Strings.Virtual_String,
54+
VSS.Strings.Hash,
55+
VSS.Strings."=",
56+
VSS.Strings."=");
57+
5058
type Test is new LSP.Raw_Clients.Raw_Client with record
5159
Index : Positive := 1;
5260
Sort_Reply : GNATCOLL.JSON.JSON_Value;
@@ -58,9 +66,12 @@ private
5866
-- Task to restrict a command execution time
5967
Started : Ada.Calendar.Time;
6068
-- Command execution start/reset time
69+
Known_Ids : String_Sets.Set;
70+
-- Set of processed request ids
6171

6272
Full_Server_Output : GNATCOLL.JSON.JSON_Array;
6373
-- Complete output received from the server
74+
6475
end record;
6576

6677
overriding procedure On_Error

testsuite/ada_lsp/SC28-001.named.parameters.0/SC28-001.named.parameters.0.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@
192192
"send": {
193193
"request": {
194194
"jsonrpc": "2.0",
195-
"id": "ada-1",
195+
"id": "ada-2",
196196
"method": "textDocument/codeAction",
197197
"params": {
198198
"textDocument": {
@@ -216,7 +216,7 @@
216216
"wait": [
217217
{
218218
"jsonrpc": "2.0",
219-
"id": "ada-1",
219+
"id": "ada-2",
220220
"result": [
221221
{
222222
"title": "Name parameters in the call",

testsuite/ada_lsp/completion.aggregates.derived_private/test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@
225225
"send": {
226226
"request": {
227227
"jsonrpc": "2.0",
228-
"id": 6,
228+
"id": 7,
229229
"method": "shutdown"
230230
},
231231
"wait": []

0 commit comments

Comments
 (0)