15
15
-- of the license. --
16
16
-- ----------------------------------------------------------------------------
17
17
18
- with Ada.Characters.Wide_Wide_Latin_1 ;
18
+ with GNATCOLL.Traces ;
19
19
20
20
with GPR2.Message ;
21
21
22
- with VSS.Strings.Cursors.Iterators.Characters ;
23
-
22
+ with VSS.Characters.Latin ;
24
23
with VSS.Strings.Character_Iterators ;
24
+ with VSS.Strings.Conversions ;
25
25
with VSS.Strings.Line_Iterators ;
26
26
with VSS.Unicode ;
27
27
@@ -39,7 +39,7 @@ package body LSP.GPR_Documents is
39
39
40
40
procedure Span_To_Markers
41
41
(Self : Document'Class;
42
- Span : LSP.Messages.Span ;
42
+ Span : LSP.Structures.A_Range ;
43
43
From : out VSS.Strings.Markers.Character_Marker;
44
44
To : out VSS.Strings.Markers.Character_Marker);
45
45
@@ -48,7 +48,7 @@ package body LSP.GPR_Documents is
48
48
49
49
procedure Recompute_Markers
50
50
(Self : in out Document'Class;
51
- Low_Line : LSP.Types.Line_Number ;
51
+ Low_Line : Natural ;
52
52
Start_Marker : VSS.Strings.Markers.Character_Marker;
53
53
End_Marker : VSS.Strings.Markers.Character_Marker);
54
54
-- Recompute line-to-marker index starting from Start_Marker till
@@ -62,27 +62,26 @@ package body LSP.GPR_Documents is
62
62
63
63
procedure Apply_Changes
64
64
(Self : aliased in out Document;
65
- Version : LSP.Types.LSP_Number ;
66
- Vector : LSP.Messages .TextDocumentContentChangeEvent_Vector)
65
+ Version : Integer ;
66
+ Vector : LSP.Structures .TextDocumentContentChangeEvent_Vector)
67
67
is
68
- URI : constant String := Types.To_UTF_8_String (Self.URI);
69
- use LSP.Types;
68
+ URI : constant String :=
69
+ VSS.Strings.Conversions.To_UTF_8_String (Self.URI);
70
+
70
71
begin
71
72
Document_Changes_Trace.Trace (" Applying changes for document " & URI);
72
73
73
74
Self.Version := Version;
74
75
75
76
for Change of Vector loop
76
- if Change.span .Is_Set then
77
+ if Change.a_range .Is_Set then
77
78
-- We're replacing a range
78
79
79
80
declare
80
- Low_Line : LSP.Types.Line_Number :=
81
- Change.span.Value.first.line;
82
- High_Line : LSP.Types.Line_Number :=
83
- Change.span.Value.last.line;
84
- Delete_High : LSP.Types.Line_Number := High_Line;
85
- Start_Index : LSP.Types.Line_Number;
81
+ Low_Line : Natural := Change.a_range.Value.start.line;
82
+ High_Line : Natural := Change.a_range.Value.an_end.line;
83
+ Delete_High : Natural := High_Line;
84
+ Start_Index : Natural;
86
85
87
86
First_Marker : VSS.Strings.Markers.Character_Marker;
88
87
Last_Marker : VSS.Strings.Markers.Character_Marker;
@@ -93,7 +92,7 @@ package body LSP.GPR_Documents is
93
92
-- Do text replacement
94
93
95
94
Self.Span_To_Markers
96
- (Change.span .Value, First_Marker, Last_Marker);
95
+ (Change.a_range .Value, First_Marker, Last_Marker);
97
96
Self.Text.Replace (First_Marker, Last_Marker, Change.text);
98
97
99
98
-- Markers inside modified range of lines need to be
@@ -150,9 +149,11 @@ package body LSP.GPR_Documents is
150
149
Self.Text := Change.text;
151
150
152
151
-- We're setting the whole text: compute the indexes now.
152
+
153
153
Self.Recompute_Indexes;
154
154
end if ;
155
155
end loop ;
156
+
156
157
Document_Changes_Trace.Trace
157
158
(" Done applying changes for document " & URI);
158
159
end Apply_Changes ;
@@ -243,10 +244,9 @@ package body LSP.GPR_Documents is
243
244
244
245
function Get_Source_Location
245
246
(Self : Document'Class;
246
- Position : LSP.Messages .Position)
247
+ Position : LSP.Structures .Position)
247
248
return Langkit_Support.Slocs.Source_Location
248
249
is
249
- use type LSP.Types.Line_Number;
250
250
use type VSS.Unicode.UTF16_Code_Unit_Offset;
251
251
use type VSS.Strings.Character_Index;
252
252
@@ -258,16 +258,19 @@ package body LSP.GPR_Documents is
258
258
259
259
Line_First_Character : constant VSS.Strings.Character_Index :=
260
260
Iterator.Character_Index;
261
+
261
262
begin
262
- while Iterator.First_UTF16_Offset - Line_Offset <= Position.character
263
+ while Integer (Iterator.First_UTF16_Offset - Line_Offset)
264
+ <= Position.character
263
265
and then Iterator.Forward
264
266
loop
265
267
null ;
266
268
end loop ;
267
269
268
- return ((Line => Langkit_Support.Slocs.Line_Number (Position.line + 1 ),
269
- Column => Langkit_Support.Slocs.Column_Number
270
- (Iterator.Character_Index - Line_First_Character)));
270
+ return
271
+ ((Line => Langkit_Support.Slocs.Line_Number (Position.line + 1 ),
272
+ Column => Langkit_Support.Slocs.Column_Number
273
+ (Iterator.Character_Index - Line_First_Character)));
271
274
end Get_Source_Location ;
272
275
273
276
-- ---------------
@@ -276,8 +279,8 @@ package body LSP.GPR_Documents is
276
279
277
280
function Get_Text_At
278
281
(Self : Document;
279
- Start_Pos : LSP.Messages .Position;
280
- End_Pos : LSP.Messages .Position) return VSS.Strings.Virtual_String
282
+ Start_Pos : LSP.Structures .Position;
283
+ End_Pos : LSP.Structures .Position) return VSS.Strings.Virtual_String
281
284
is
282
285
First_Marker : VSS.Strings.Markers.Character_Marker;
283
286
Last_Marker : VSS.Strings.Markers.Character_Marker;
@@ -295,7 +298,7 @@ package body LSP.GPR_Documents is
295
298
296
299
function Get_Word_At
297
300
(Self : Document;
298
- Position : LSP.Messages .Position)
301
+ Position : LSP.Structures .Position)
299
302
return VSS.Strings.Virtual_String
300
303
is
301
304
Result : VSS.Strings.Virtual_String;
@@ -321,17 +324,17 @@ package body LSP.GPR_Documents is
321
324
322
325
procedure Initialize
323
326
(Self : in out Document;
324
- URI : LSP.Messages .DocumentUri;
327
+ URI : LSP.Structures .DocumentUri;
325
328
File : GPR2.Path_Name.Object;
326
329
Text : VSS.Strings.Virtual_String;
327
- Provider : LSP.GPR_Files.File_Provider_Access)
328
- is
330
+ Provider : LSP.GPR_Files.File_Provider_Access) is
329
331
begin
330
- Self.URI := URI;
331
- Self.File := File;
332
- Self.Version := 1 ;
333
- Self.Text := Text;
332
+ Self.URI := URI;
333
+ Self.File := File;
334
+ Self.Version := 1 ;
335
+ Self.Text := Text;
334
336
Self.File_Provider := Provider;
337
+
335
338
Recompute_Indexes (Self);
336
339
end Initialize ;
337
340
@@ -340,16 +343,17 @@ package body LSP.GPR_Documents is
340
343
-- -------------------
341
344
342
345
function Line_Terminator
343
- (Self : Document'Class) return VSS.Strings.Virtual_String is
346
+ (Self : Document'Class) return VSS.Strings.Virtual_String
347
+ is
348
+ use type VSS.Strings.Virtual_String;
349
+
344
350
begin
345
351
if Self.Line_Terminator.Is_Empty then
346
352
-- Document has no line terminator yet, return LF as most used
347
353
--
348
354
-- Should it be platform specific? CRLF for Windows, CR for Mac?
349
355
350
- return
351
- VSS.Strings.To_Virtual_String
352
- ((1 => Ada.Characters.Wide_Wide_Latin_1.LF));
356
+ return 1 * VSS.Characters.Latin.Line_Feed;
353
357
354
358
else
355
359
return Self.Line_Terminator;
@@ -466,11 +470,10 @@ package body LSP.GPR_Documents is
466
470
467
471
procedure Recompute_Markers
468
472
(Self : in out Document'Class;
469
- Low_Line : LSP.Types.Line_Number ;
473
+ Low_Line : Natural ;
470
474
Start_Marker : VSS.Strings.Markers.Character_Marker;
471
475
End_Marker : VSS.Strings.Markers.Character_Marker)
472
476
is
473
- use type LSP.Types.Line_Number;
474
477
use type VSS.Strings.Character_Count;
475
478
476
479
M : VSS.Strings.Markers.Character_Marker;
@@ -479,7 +482,7 @@ package body LSP.GPR_Documents is
479
482
(Position => Start_Marker,
480
483
Terminators => LSP_New_Line_Function_Set,
481
484
Keep_Terminator => True);
482
- Line : LSP.Types.Line_Number := Low_Line;
485
+ Line : Natural := Low_Line;
483
486
484
487
begin
485
488
if J.Has_Element then
@@ -508,34 +511,34 @@ package body LSP.GPR_Documents is
508
511
509
512
procedure Span_To_Markers
510
513
(Self : Document'Class;
511
- Span : LSP.Messages.Span ;
514
+ Span : LSP.Structures.A_Range ;
512
515
From : out VSS.Strings.Markers.Character_Marker;
513
516
To : out VSS.Strings.Markers.Character_Marker)
514
517
is
515
518
use type VSS.Unicode.UTF16_Code_Unit_Offset;
516
519
517
520
J1 : VSS.Strings.Character_Iterators.Character_Iterator :=
518
- Self.Text.At_Character (Self.Line_To_Marker (Span.first .line));
521
+ Self.Text.At_Character (Self.Line_To_Marker (Span.start .line));
519
522
U1 : constant VSS.Unicode.UTF16_Code_Unit_Offset :=
520
523
J1.First_UTF16_Offset;
521
524
522
525
J2 : VSS.Strings.Character_Iterators.Character_Iterator :=
523
- Self.Text.At_Character (Self.Line_To_Marker (Span.last .line));
526
+ Self.Text.At_Character (Self.Line_To_Marker (Span.an_end .line));
524
527
U2 : constant VSS.Unicode.UTF16_Code_Unit_Offset :=
525
528
J2.First_UTF16_Offset;
526
529
527
530
Dummy : Boolean;
528
531
529
532
begin
530
- while Span.first .character /= J1.First_UTF16_Offset - U1
533
+ while Span.start .character /= Integer ( J1.First_UTF16_Offset - U1)
531
534
and then J1.Forward
532
535
loop
533
536
null ;
534
537
end loop ;
535
538
536
539
From := J1.Marker;
537
540
538
- while Span.last .character /= J2.First_UTF16_Offset - U2
541
+ while Span.an_end .character /= Integer ( J2.First_UTF16_Offset - U2)
539
542
and then J2.Forward
540
543
loop
541
544
null ;
@@ -560,7 +563,7 @@ package body LSP.GPR_Documents is
560
563
-- ------------------------
561
564
562
565
function Versioned_Identifier
563
- (Self : Document) return LSP.Messages .VersionedTextDocumentIdentifier is
566
+ (Self : Document) return LSP.Structures .VersionedTextDocumentIdentifier is
564
567
begin
565
568
return (uri => Self.URI,
566
569
version => Self.Version);
0 commit comments