Skip to content

Commit 960c5b3

Browse files
committed
Merge branch 'topic/json-streams' into 'master'
Sync with changes in VSS JSON API. See merge request eng/ide/ada_language_server!1227
2 parents 1bd2095 + 14b9949 commit 960c5b3

File tree

7 files changed

+139
-187
lines changed

7 files changed

+139
-187
lines changed

source/client/lsp-clients.adb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2018-2021, AdaCore --
4+
-- Copyright (C) 2018-2023, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -16,6 +16,7 @@
1616
------------------------------------------------------------------------------
1717

1818
with VSS.JSON.Pull_Readers.Simple;
19+
with VSS.JSON.Streams;
1920
with VSS.Stream_Element_Vectors.Conversions;
2021
with VSS.Strings.Conversions;
2122
with VSS.Text_Streams.Memory_UTF8_Input;
@@ -632,7 +633,7 @@ package body LSP.Clients is
632633
Token : out LSP.Types.LSP_Number_Or_String;
633634
Is_Error : in out Boolean)
634635
is
635-
use all type VSS.JSON.Pull_Readers.JSON_Event_Kind;
636+
use all type VSS.JSON.Streams.JSON_Stream_Element_Kind;
636637

637638
R : aliased VSS.JSON.Pull_Readers.Simple.JSON_Simple_Pull_Reader;
638639
JS : aliased LSP.JSON_Streams.JSON_Stream (False, R'Access);
@@ -653,7 +654,7 @@ package body LSP.Clients is
653654
R.Read_Next;
654655

655656
if Key = "id" then
656-
case R.Event_Kind is
657+
case R.Element_Kind is
657658
when String_Value =>
658659
Id :=
659660
(Is_Number => False,
@@ -695,7 +696,7 @@ package body LSP.Clients is
695696
R.Read_Next;
696697

697698
if Key = "token" then
698-
case R.Event_Kind is
699+
case R.Element_Kind is
699700
when String_Value =>
700701
Token :=
701702
(Is_Number => False,

source/protocol/lsp-json_streams.adb

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2018-2021, AdaCore --
4+
-- Copyright (C) 2018-2023, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -15,6 +15,8 @@
1515
-- of the license. --
1616
------------------------------------------------------------------------------
1717

18+
with VSS.JSON.Streams;
19+
1820
package body LSP.JSON_Streams is
1921

2022
procedure Write_Key (Self : in out Write_Stream);
@@ -94,18 +96,19 @@ package body LSP.JSON_Streams is
9496

9597
procedure Skip_Value (Self : in out JSON_Stream'Class) is
9698
begin
97-
case Self.R.Event_Kind is
98-
when VSS.JSON.Pull_Readers.No_Token |
99-
VSS.JSON.Pull_Readers.Invalid |
100-
VSS.JSON.Pull_Readers.Start_Document |
101-
VSS.JSON.Pull_Readers.End_Document |
102-
VSS.JSON.Pull_Readers.End_Array |
103-
VSS.JSON.Pull_Readers.End_Object |
104-
VSS.JSON.Pull_Readers.Key_Name =>
99+
case Self.R.Element_Kind is
100+
when VSS.JSON.Streams.None |
101+
VSS.JSON.Streams.Invalid |
102+
VSS.JSON.Streams.Start_Document |
103+
VSS.JSON.Streams.End_Document |
104+
VSS.JSON.Streams.Comment |
105+
VSS.JSON.Streams.End_Array |
106+
VSS.JSON.Streams.End_Object |
107+
VSS.JSON.Streams.Key_Name =>
105108

106109
raise Program_Error;
107110

108-
when VSS.JSON.Pull_Readers.Start_Array =>
111+
when VSS.JSON.Streams.Start_Array =>
109112

110113
Self.R.Read_Next;
111114

@@ -115,7 +118,7 @@ package body LSP.JSON_Streams is
115118

116119
Self.R.Read_Next;
117120

118-
when VSS.JSON.Pull_Readers.Start_Object =>
121+
when VSS.JSON.Streams.Start_Object =>
119122

120123
Self.R.Read_Next;
121124

@@ -128,10 +131,10 @@ package body LSP.JSON_Streams is
128131

129132
Self.R.Read_Next;
130133

131-
when VSS.JSON.Pull_Readers.String_Value
132-
| VSS.JSON.Pull_Readers.Number_Value
133-
| VSS.JSON.Pull_Readers.Boolean_Value
134-
| VSS.JSON.Pull_Readers.Null_Value =>
134+
when VSS.JSON.Streams.String_Value
135+
| VSS.JSON.Streams.Number_Value
136+
| VSS.JSON.Streams.Boolean_Value
137+
| VSS.JSON.Streams.Null_Value =>
135138

136139
Self.R.Read_Next;
137140

source/protocol/lsp-messages.adb

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
------------------------------------------------------------------------------
22
-- Language Server Protocol --
33
-- --
4-
-- Copyright (C) 2018-2021, AdaCore --
4+
-- Copyright (C) 2018-2023, AdaCore --
55
-- --
66
-- This is free software; you can redistribute it and/or modify it under --
77
-- terms of the GNU General Public License as published by the Free Soft- --
@@ -21,9 +21,9 @@ with Ada.Tags.Generic_Dispatching_Constructor;
2121

2222
with Interfaces;
2323

24-
with VSS.JSON.Pull_Readers;
25-
with VSS.Strings.Conversions;
2624
with VSS.JSON.Pull_Readers.Look_Ahead;
25+
with VSS.JSON.Streams;
26+
with VSS.Strings.Conversions;
2727

2828
with LSP.JSON_Streams;
2929
with LSP.Message_IO;
@@ -2892,13 +2892,13 @@ package body LSP.Messages is
28922892
JS : LSP.JSON_Streams.JSON_Stream'Class renames
28932893
LSP.JSON_Streams.JSON_Stream'Class (S.all);
28942894
begin
2895-
case JS.R.Event_Kind is
2896-
when VSS.JSON.Pull_Readers.String_Value =>
2895+
case JS.R.Element_Kind is
2896+
when VSS.JSON.Streams.String_Value =>
28972897
V := (Is_String => True,
28982898
value => JS.R.String_Value);
28992899

29002900
JS.R.Read_Next;
2901-
when VSS.JSON.Pull_Readers.Start_Object =>
2901+
when VSS.JSON.Streams.Start_Object =>
29022902
V := (Is_String => False, others => <>);
29032903

29042904
JS.R.Read_Next;
@@ -2991,20 +2991,20 @@ package body LSP.Messages is
29912991
JS : LSP.JSON_Streams.JSON_Stream'Class renames
29922992
LSP.JSON_Streams.JSON_Stream'Class (S.all);
29932993
begin
2994-
case JS.R.Event_Kind is
2995-
when VSS.JSON.Pull_Readers.String_Value =>
2994+
case JS.R.Element_Kind is
2995+
when VSS.JSON.Streams.String_Value =>
29962996

29972997
V := (Is_MarkupContent => False,
29982998
Vector => <>);
29992999
V.Vector.Append
30003000
(MarkedString'(Is_String => True,
30013001
value => JS.R.String_Value));
30023002
JS.R.Read_Next;
3003-
when VSS.JSON.Pull_Readers.Start_Array =>
3003+
when VSS.JSON.Streams.Start_Array =>
30043004
V := (Is_MarkupContent => False,
30053005
Vector => <>);
30063006
MarkedString_Vector'Read (S, V.Vector);
3007-
when VSS.JSON.Pull_Readers.Start_Object =>
3007+
when VSS.JSON.Streams.Start_Object =>
30083008
Read_Object (JS);
30093009
when others =>
30103010
JS.Skip_Value;
@@ -3022,14 +3022,14 @@ package body LSP.Messages is
30223022
JS : LSP.JSON_Streams.JSON_Stream'Class renames
30233023
LSP.JSON_Streams.JSON_Stream'Class (S.all);
30243024
begin
3025-
case JS.R.Event_Kind is
3026-
when VSS.JSON.Pull_Readers.Null_Value =>
3025+
case JS.R.Element_Kind is
3026+
when VSS.JSON.Streams.Null_Value =>
30273027
V := (False, False);
30283028
JS.R.Read_Next;
3029-
when VSS.JSON.Pull_Readers.Start_Object =>
3029+
when VSS.JSON.Streams.Start_Object =>
30303030
V := (True, False, others => <>);
30313031
TextDocumentSyncOptions'Read (S, V.Options);
3032-
when VSS.JSON.Pull_Readers.Number_Value =>
3032+
when VSS.JSON.Streams.Number_Value =>
30333033
V := (True, True, others => <>);
30343034
TextDocumentSyncKind'Read (S, V.Value);
30353035
when others =>
@@ -3048,12 +3048,12 @@ package body LSP.Messages is
30483048
JS : LSP.JSON_Streams.JSON_Stream'Class renames
30493049
LSP.JSON_Streams.JSON_Stream'Class (S.all);
30503050
begin
3051-
case JS.R.Event_Kind is
3052-
when VSS.JSON.Pull_Readers.String_Value =>
3051+
case JS.R.Element_Kind is
3052+
when VSS.JSON.Streams.String_Value =>
30533053
V := (Is_String => True,
30543054
String => JS.R.String_Value);
30553055
JS.R.Read_Next;
3056-
when VSS.JSON.Pull_Readers.Start_Array =>
3056+
when VSS.JSON.Streams.Start_Array =>
30573057
JS.R.Read_Next;
30583058
UTF_16_Index'Read (S, V.From);
30593059
UTF_16_Index'Read (S, V.Till);
@@ -3075,12 +3075,12 @@ package body LSP.Messages is
30753075
JS : LSP.JSON_Streams.JSON_Stream'Class renames
30763076
LSP.JSON_Streams.JSON_Stream'Class (S.all);
30773077
begin
3078-
case JS.R.Event_Kind is
3079-
when VSS.JSON.Pull_Readers.Boolean_Value =>
3078+
case JS.R.Element_Kind is
3079+
when VSS.JSON.Streams.Boolean_Value =>
30803080
V := (Is_Boolean => True,
30813081
Bool => JS.R.Boolean_Value);
30823082
JS.R.Read_Next;
3083-
when VSS.JSON.Pull_Readers.Start_Object =>
3083+
when VSS.JSON.Streams.Start_Object =>
30843084
V := (Is_Boolean => False,
30853085
Options => (Is_Set => True, Value => <>));
30863086

@@ -3103,13 +3103,13 @@ package body LSP.Messages is
31033103
JS : LSP.JSON_Streams.JSON_Stream'Class renames
31043104
LSP.JSON_Streams.JSON_Stream'Class (S.all);
31053105
begin
3106-
case JS.R.Event_Kind is
3107-
when VSS.JSON.Pull_Readers.String_Value =>
3106+
case JS.R.Element_Kind is
3107+
when VSS.JSON.Streams.String_Value =>
31083108
V := (Is_String => True,
31093109
String => JS.R.String_Value);
31103110
JS.R.Read_Next;
31113111

3112-
when VSS.JSON.Pull_Readers.Start_Object =>
3112+
when VSS.JSON.Streams.Start_Object =>
31133113
V := (Is_String => False, Content => <>);
31143114
MarkupContent'Read (S, V.Content);
31153115
when others =>
@@ -3344,8 +3344,8 @@ package body LSP.Messages is
33443344
Result : Integer;
33453345
Mask : Integer := 4;
33463346
begin
3347-
case JS.R.Event_Kind is
3348-
when VSS.JSON.Pull_Readers.Number_Value =>
3347+
case JS.R.Element_Kind is
3348+
when VSS.JSON.Streams.Number_Value =>
33493349
Result := Integer (JS.R.Number_Value.Integer_Value);
33503350

33513351
for J in reverse WatchKind loop

0 commit comments

Comments
 (0)