Skip to content

Commit b4dbb4c

Browse files
committed
Change code after lsp_gen update for supportsCustomValues
Refs #1170
1 parent a46e980 commit b4dbb4c

9 files changed

+44
-77
lines changed

source/ada/lsp-ada_client_capabilities.adb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
-- of the license. --
1616
------------------------------------------------------------------------------
1717

18+
pragma Ada_2022;
19+
1820
with VSS.Characters.Latin;
1921
with VSS.JSON.Streams;
2022
with VSS.String_Vectors;
@@ -242,17 +244,20 @@ package body LSP.Ada_Client_Capabilities is
242244
is
243245
use type VSS.Strings.Virtual_String;
244246

247+
function Supported_Code_Action_Kinds
248+
return LSP.Structures.CodeActionKind_Vectors.Vector is
249+
[LSP.Enumerations.QuickFix,
250+
LSP.Enumerations.RefactorRewrite];
251+
245252
function Full_codeActionProvider
246253
return LSP.Structures.Boolean_Or_CodeActionOptions_Optional is
247254
(Is_Set => True,
248255
Value =>
249256
(Is_Boolean => False,
250257
CodeActionOptions =>
251258
(workDoneProgress => LSP.Constants.False,
252-
codeActionKinds =>
253-
(LSP.Enumerations.QuickFix => True,
254-
LSP.Enumerations.RefactorRewrite => True,
255-
others => False),
259+
codeActionKinds => (Supported_Code_Action_Kinds
260+
with null record),
256261
resolveProvider => LSP.Constants.False)));
257262

258263
begin

source/ada/lsp-ada_handlers-formatting.adb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ with GNATCOLL.Traces;
2020
with Pp.Command_Lines;
2121
with Utils.Command_Lines;
2222

23-
with LSP.Constants;
23+
with LSP.Enumerations;
2424

2525
package body LSP.Ada_Handlers.Formatting is
2626

@@ -54,7 +54,7 @@ package body LSP.Ada_Handlers.Formatting is
5454
if Document.Has_Diagnostics (Context) then
5555
Success := False;
5656
Error :=
57-
(code => LSP.Constants.InternalError,
57+
(code => LSP.Enumerations.InternalError,
5858
message => "Incorrect code can't be formatted");
5959

6060
return;
@@ -75,7 +75,7 @@ package body LSP.Ada_Handlers.Formatting is
7575

7676
if not Success then
7777
Error :=
78-
(code => LSP.Constants.InternalError,
78+
(code => LSP.Enumerations.InternalError,
7979
message => Messages.Join (' '));
8080
Messages.Clear;
8181
end if;
@@ -101,7 +101,7 @@ package body LSP.Ada_Handlers.Formatting is
101101
if Document.Has_Diagnostics (Context) then
102102
Success := False;
103103
Error :=
104-
(code => LSP.Constants.InternalError,
104+
(code => LSP.Enumerations.InternalError,
105105
message => "Syntactically incorrect code can't be formatted");
106106

107107
return;
@@ -122,7 +122,7 @@ package body LSP.Ada_Handlers.Formatting is
122122

123123
if not Success then
124124
Error :=
125-
(code => LSP.Constants.InternalError,
125+
(code => LSP.Enumerations.InternalError,
126126
message => Messages.Join (' '));
127127
end if;
128128
end Range_Format;

source/ada/lsp-ada_handlers-named_parameters_commands.adb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ with Libadalang.Analysis;
2525
with Libadalang.Common;
2626

2727
with LSP.Ada_Contexts;
28-
with LSP.Constants;
2928
with LSP.Enumerations;
3029
with LSP.Servers;
3130
with LSP.Structures.LSPAny_Vectors; use LSP.Structures.LSPAny_Vectors;
@@ -243,7 +242,7 @@ package body LSP.Ada_Handlers.Named_Parameters_Commands is
243242
Error :=
244243
(Is_Set => True,
245244
Value =>
246-
(code => LSP.Constants.InvalidRequest,
245+
(code => LSP.Enumerations.InvalidRequest,
247246
message => "This is not a valid position to name parameters."));
248247
return;
249248
end if;
@@ -260,7 +259,7 @@ package body LSP.Ada_Handlers.Named_Parameters_Commands is
260259
Error :=
261260
(Is_Set => True,
262261
Value =>
263-
(code => LSP.Constants.InvalidRequest,
262+
(code => LSP.Enumerations.InvalidRequest,
264263
message =>
265264
"Could not resolve this call expression precisely."));
266265
return;
@@ -291,7 +290,7 @@ package body LSP.Ada_Handlers.Named_Parameters_Commands is
291290
Error :=
292291
(Is_Set => True,
293292
Value =>
294-
(code => LSP.Constants.UnknownErrorCode,
293+
(code => LSP.Enumerations.UnknownErrorCode,
295294
message => VSS.Strings.Conversions.To_Virtual_String
296295
(Ada.Exceptions.Exception_Information (E))));
297296
end Execute;

source/ada/lsp-ada_handlers-refactor.adb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ package body LSP.Ada_Handlers.Refactor is
9898
Error :=
9999
(Is_Set => True,
100100
Value =>
101-
(code => LSP.Constants.UnknownErrorCode,
101+
(code => LSP.Enumerations.UnknownErrorCode,
102102
message => VSS.Strings.Conversions.To_Virtual_String
103103
(Error_Msg)));
104104

@@ -165,7 +165,7 @@ package body LSP.Ada_Handlers.Refactor is
165165
Error :=
166166
(Is_Set => True,
167167
Value =>
168-
(code => LSP.Constants.UnknownErrorCode,
168+
(code => LSP.Enumerations.UnknownErrorCode,
169169
message => VSS.Strings.Conversions.To_Virtual_String
170170
(Error_Msg)));
171171
end Execute;

source/ada/lsp-ada_handlers.adb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ package body LSP.Ada_Handlers is
505505
-- We need at least one rule in order to validate the input
506506

507507
Self.Sender.On_Error_Response
508-
(Id, (LSP.Constants.InvalidParams, "Rule list is empty"));
508+
(Id, (LSP.Enumerations.InvalidParams, "Rule list is empty"));
509509

510510
return;
511511
elsif Value.input.Is_Empty then
@@ -525,7 +525,8 @@ package body LSP.Ada_Handlers is
525525
when Constraint_Error =>
526526
Self.Sender.On_Error_Response
527527
(Id,
528-
(LSP.Constants.InvalidParams, Invalid_Rule_Error_Message));
528+
(LSP.Enumerations.InvalidParams,
529+
Invalid_Rule_Error_Message));
529530

530531
return;
531532
end;
@@ -2819,7 +2820,7 @@ package body LSP.Ada_Handlers is
28192820

28202821
if Tag = Ada.Tags.No_Tag then
28212822
Self.Sender.On_Error_Response
2822-
(Id, (code => LSP.Constants.InternalError,
2823+
(Id, (code => LSP.Enumerations.InternalError,
28232824
message => "Unknown command"));
28242825
return;
28252826
end if;
@@ -2884,7 +2885,7 @@ package body LSP.Ada_Handlers is
28842885

28852886
else
28862887
Self.Sender.On_Error_Response
2887-
(Id, (code => LSP.Constants.InternalError,
2888+
(Id, (code => LSP.Enumerations.InternalError,
28882889
message => "Document is not opened"));
28892890
end if;
28902891
end On_FoldingRange_Request;
@@ -4061,7 +4062,7 @@ package body LSP.Ada_Handlers is
40614062
if not Self.Implemented then
40624063
Self.Sender.On_Error_Response
40634064
(Value.Id,
4064-
(code => LSP.Constants.MethodNotFound,
4065+
(code => LSP.Enumerations.MethodNotFound,
40654066
message => "Not implemented"));
40664067
end if;
40674068

@@ -4079,7 +4080,7 @@ package body LSP.Ada_Handlers is
40794080

40804081
Self.Sender.On_Error_Response
40814082
(Value.Id,
4082-
(code => LSP.Constants.InternalError,
4083+
(code => LSP.Enumerations.InternalError,
40834084
message => Message));
40844085

40854086
end;

source/lsp_3.17/lsp-constants.ads

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -141,50 +141,10 @@ package LSP.Constants is
141141
function Error return LSP.Structures.DiagnosticSeverity_Optional
142142
is (Is_Set => True, Value => LSP.Enumerations.Error);
143143

144-
ErrorCodes_Map : constant array (LSP.Enumerations.ErrorCodes) of Integer :=
145-
[LSP.Enumerations.ParseError => -32700,
146-
LSP.Enumerations.InvalidRequest => -32600,
147-
LSP.Enumerations.MethodNotFound => -32601,
148-
LSP.Enumerations.InvalidParams => -32602,
149-
LSP.Enumerations.InternalError => -32603,
150-
LSP.Enumerations.jsonrpcReservedErrorRangeStart => -32099,
151-
LSP.Enumerations.serverErrorStart => -32099,
152-
LSP.Enumerations.ServerNotInitialized => -32002,
153-
LSP.Enumerations.UnknownErrorCode => -32001,
154-
LSP.Enumerations.jsonrpcReservedErrorRangeEnd => -32000,
155-
LSP.Enumerations.serverErrorEnd => -32000];
156-
157-
LSPErrorCodes_Map : constant array
158-
(LSP.Enumerations.LSPErrorCodes) of Integer :=
159-
[LSP.Enumerations.lspReservedErrorRangeStart => -32899,
160-
LSP.Enumerations.RequestFailed => -32803,
161-
LSP.Enumerations.ServerCancelled => -32802,
162-
LSP.Enumerations.ContentModified => -32801,
163-
LSP.Enumerations.RequestCancelled => -32800,
164-
LSP.Enumerations.lspReservedErrorRangeEnd => -32800];
165-
166-
function InternalError return Integer
167-
is (ErrorCodes_Map (LSP.Enumerations.InternalError));
168-
169-
function MethodNotFound return Integer
170-
is (ErrorCodes_Map (LSP.Enumerations.MethodNotFound));
171-
172-
function InvalidRequest return Integer
173-
is (ErrorCodes_Map (LSP.Enumerations.InvalidRequest));
174-
175-
function UnknownErrorCode return Integer
176-
is (ErrorCodes_Map (LSP.Enumerations.UnknownErrorCode));
177-
178-
function ServerNotInitialized return Integer
179-
is (ErrorCodes_Map (LSP.Enumerations.ServerNotInitialized));
180-
181-
function InvalidParams return Integer
182-
is (ErrorCodes_Map (LSP.Enumerations.InvalidParams));
183-
184-
function RequestFailed return Integer
185-
is (LSPErrorCodes_Map (LSP.Enumerations.RequestFailed));
186-
187-
function RequestCancelled return Integer
188-
is (LSPErrorCodes_Map (LSP.Enumerations.RequestCancelled));
144+
function RequestFailed return LSP.Enumerations.ErrorCodes is
145+
(LSP.Enumerations.ErrorCodes (LSP.Enumerations.RequestFailed));
146+
147+
function RequestCancelled return LSP.Enumerations.ErrorCodes is
148+
(LSP.Enumerations.ErrorCodes (LSP.Enumerations.RequestCancelled));
189149

190150
end LSP.Constants;

source/lsp_3.17/lsp-errors.ads

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66

77
with VSS.Strings;
88

9+
with LSP.Enumerations;
10+
911
package LSP.Errors is
1012
pragma Preelaborate;
1113

1214
type ResponseError is record
13-
code : Integer;
15+
code : LSP.Enumerations.ErrorCodes;
1416
-- A number indicating the error type that occurred.
1517
message : VSS.Strings.Virtual_String;
1618
-- A string providing a short description of the error.

source/server/lsp-lifecycle_checkers.adb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
-- of the license. --
1616
------------------------------------------------------------------------------
1717

18-
with LSP.Constants;
18+
with LSP.Enumerations;
1919

2020
package body LSP.Lifecycle_Checkers is
2121

@@ -45,7 +45,7 @@ package body LSP.Lifecycle_Checkers is
4545
Client.On_Error_Response
4646
(Id => Self.Request_Id.Value,
4747
Value =>
48-
(code => LSP.Constants.ServerNotInitialized,
48+
(code => LSP.Enumerations.ServerNotInitialized,
4949
message => "No initialize request has been received"));
5050
end if;
5151
end Check_Message;

source/server/lsp-servers.adb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ with VSS.Text_Streams.Memory_UTF8_Input;
2929
with VSS.Text_Streams.Memory_UTF8_Output;
3030

3131
with LSP.Client_Message_Writers;
32-
with LSP.Constants;
32+
with LSP.Enumerations;
3333
with LSP.Errors;
3434
with LSP.Known_Requests;
3535
with LSP.Lifecycle_Checkers;
@@ -62,8 +62,8 @@ package body LSP.Servers is
6262
Message : VSS.Strings.Virtual_String;
6363
Request : VSS.Stream_Element_Vectors.Stream_Element_Vector;
6464
Request_Id : LSP.Structures.Integer_Or_Virtual_String;
65-
Code : Integer :=
66-
LSP.Constants.InternalError);
65+
Code : LSP.Enumerations.ErrorCodes :=
66+
LSP.Enumerations.InternalError);
6767
-- Send a response representing the exception to the client. This
6868
-- should be called whenever an exception occurred while processing
6969
-- a request.
@@ -412,7 +412,7 @@ package body LSP.Servers is
412412
Self.Tracer.Trace (Vector);
413413
Self.On_Error_Response
414414
(Request_Id,
415-
(code => LSP.Constants.InvalidParams,
415+
(code => LSP.Enumerations.InvalidParams,
416416
message => "Unable to decode request."));
417417

418418
return;
@@ -423,7 +423,7 @@ package body LSP.Servers is
423423
(Self, UR, "Unknown method.",
424424
Vector,
425425
Request_Id,
426-
LSP.Constants.MethodNotFound);
426+
LSP.Enumerations.MethodNotFound);
427427
return;
428428

429429
when E : others =>
@@ -433,7 +433,7 @@ package body LSP.Servers is
433433
(Self, E, "Request decoding fails:",
434434
Vector,
435435
Request_Id,
436-
LSP.Constants.InvalidParams);
436+
LSP.Enumerations.InvalidParams);
437437
return;
438438
end;
439439

@@ -600,8 +600,8 @@ package body LSP.Servers is
600600
Message : VSS.Strings.Virtual_String;
601601
Request : VSS.Stream_Element_Vectors.Stream_Element_Vector;
602602
Request_Id : LSP.Structures.Integer_Or_Virtual_String;
603-
Code : Integer :=
604-
LSP.Constants.InternalError) is
603+
Code : LSP.Enumerations.ErrorCodes :=
604+
LSP.Enumerations.InternalError) is
605605
begin
606606
Self.Tracer.Trace_Exception (E, Message);
607607
Self.Tracer.Trace (Request);

0 commit comments

Comments
 (0)