1515-- of the license. --
1616-- ----------------------------------------------------------------------------
1717
18- with Ada.Characters.Wide_Wide_Latin_1 ;
18+ with GNATCOLL.Traces ;
1919
2020with GPR2.Message ;
2121
22- with VSS.Strings.Cursors.Iterators.Characters ;
23-
22+ with VSS.Characters.Latin ;
2423with VSS.Strings.Character_Iterators ;
24+ with VSS.Strings.Conversions ;
2525with VSS.Strings.Line_Iterators ;
2626with VSS.Unicode ;
2727
@@ -39,7 +39,7 @@ package body LSP.GPR_Documents is
3939
4040 procedure Span_To_Markers
4141 (Self : Document'Class;
42- Span : LSP.Messages.Span ;
42+ Span : LSP.Structures.A_Range ;
4343 From : out VSS.Strings.Markers.Character_Marker;
4444 To : out VSS.Strings.Markers.Character_Marker);
4545
@@ -48,7 +48,7 @@ package body LSP.GPR_Documents is
4848
4949 procedure Recompute_Markers
5050 (Self : in out Document'Class;
51- Low_Line : LSP.Types.Line_Number ;
51+ Low_Line : Natural ;
5252 Start_Marker : VSS.Strings.Markers.Character_Marker;
5353 End_Marker : VSS.Strings.Markers.Character_Marker);
5454 -- Recompute line-to-marker index starting from Start_Marker till
@@ -62,27 +62,26 @@ package body LSP.GPR_Documents is
6262
6363 procedure Apply_Changes
6464 (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)
6767 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+
7071 begin
7172 Document_Changes_Trace.Trace (" Applying changes for document " & URI);
7273
7374 Self.Version := Version;
7475
7576 for Change of Vector loop
76- if Change.span .Is_Set then
77+ if Change.a_range .Is_Set then
7778 -- We're replacing a range
7879
7980 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;
8685
8786 First_Marker : VSS.Strings.Markers.Character_Marker;
8887 Last_Marker : VSS.Strings.Markers.Character_Marker;
@@ -93,7 +92,7 @@ package body LSP.GPR_Documents is
9392 -- Do text replacement
9493
9594 Self.Span_To_Markers
96- (Change.span .Value, First_Marker, Last_Marker);
95+ (Change.a_range .Value, First_Marker, Last_Marker);
9796 Self.Text.Replace (First_Marker, Last_Marker, Change.text);
9897
9998 -- Markers inside modified range of lines need to be
@@ -150,9 +149,11 @@ package body LSP.GPR_Documents is
150149 Self.Text := Change.text;
151150
152151 -- We're setting the whole text: compute the indexes now.
152+
153153 Self.Recompute_Indexes;
154154 end if ;
155155 end loop ;
156+
156157 Document_Changes_Trace.Trace
157158 (" Done applying changes for document " & URI);
158159 end Apply_Changes ;
@@ -243,10 +244,9 @@ package body LSP.GPR_Documents is
243244
244245 function Get_Source_Location
245246 (Self : Document'Class;
246- Position : LSP.Messages .Position)
247+ Position : LSP.Structures .Position)
247248 return Langkit_Support.Slocs.Source_Location
248249 is
249- use type LSP.Types.Line_Number;
250250 use type VSS.Unicode.UTF16_Code_Unit_Offset;
251251 use type VSS.Strings.Character_Index;
252252
@@ -258,16 +258,19 @@ package body LSP.GPR_Documents is
258258
259259 Line_First_Character : constant VSS.Strings.Character_Index :=
260260 Iterator.Character_Index;
261+
261262 begin
262- while Iterator.First_UTF16_Offset - Line_Offset <= Position.character
263+ while Integer (Iterator.First_UTF16_Offset - Line_Offset)
264+ <= Position.character
263265 and then Iterator.Forward
264266 loop
265267 null ;
266268 end loop ;
267269
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)));
271274 end Get_Source_Location ;
272275
273276 -- ---------------
@@ -276,8 +279,8 @@ package body LSP.GPR_Documents is
276279
277280 function Get_Text_At
278281 (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
281284 is
282285 First_Marker : VSS.Strings.Markers.Character_Marker;
283286 Last_Marker : VSS.Strings.Markers.Character_Marker;
@@ -295,7 +298,7 @@ package body LSP.GPR_Documents is
295298
296299 function Get_Word_At
297300 (Self : Document;
298- Position : LSP.Messages .Position)
301+ Position : LSP.Structures .Position)
299302 return VSS.Strings.Virtual_String
300303 is
301304 Result : VSS.Strings.Virtual_String;
@@ -321,17 +324,17 @@ package body LSP.GPR_Documents is
321324
322325 procedure Initialize
323326 (Self : in out Document;
324- URI : LSP.Messages .DocumentUri;
327+ URI : LSP.Structures .DocumentUri;
325328 File : GPR2.Path_Name.Object;
326329 Text : VSS.Strings.Virtual_String;
327- Provider : LSP.GPR_Files.File_Provider_Access)
328- is
330+ Provider : LSP.GPR_Files.File_Provider_Access) is
329331 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;
334336 Self.File_Provider := Provider;
337+
335338 Recompute_Indexes (Self);
336339 end Initialize ;
337340
@@ -340,16 +343,17 @@ package body LSP.GPR_Documents is
340343 -- -------------------
341344
342345 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+
344350 begin
345351 if Self.Line_Terminator.Is_Empty then
346352 -- Document has no line terminator yet, return LF as most used
347353 --
348354 -- Should it be platform specific? CRLF for Windows, CR for Mac?
349355
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;
353357
354358 else
355359 return Self.Line_Terminator;
@@ -466,11 +470,10 @@ package body LSP.GPR_Documents is
466470
467471 procedure Recompute_Markers
468472 (Self : in out Document'Class;
469- Low_Line : LSP.Types.Line_Number ;
473+ Low_Line : Natural ;
470474 Start_Marker : VSS.Strings.Markers.Character_Marker;
471475 End_Marker : VSS.Strings.Markers.Character_Marker)
472476 is
473- use type LSP.Types.Line_Number;
474477 use type VSS.Strings.Character_Count;
475478
476479 M : VSS.Strings.Markers.Character_Marker;
@@ -479,7 +482,7 @@ package body LSP.GPR_Documents is
479482 (Position => Start_Marker,
480483 Terminators => LSP_New_Line_Function_Set,
481484 Keep_Terminator => True);
482- Line : LSP.Types.Line_Number := Low_Line;
485+ Line : Natural := Low_Line;
483486
484487 begin
485488 if J.Has_Element then
@@ -508,34 +511,34 @@ package body LSP.GPR_Documents is
508511
509512 procedure Span_To_Markers
510513 (Self : Document'Class;
511- Span : LSP.Messages.Span ;
514+ Span : LSP.Structures.A_Range ;
512515 From : out VSS.Strings.Markers.Character_Marker;
513516 To : out VSS.Strings.Markers.Character_Marker)
514517 is
515518 use type VSS.Unicode.UTF16_Code_Unit_Offset;
516519
517520 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));
519522 U1 : constant VSS.Unicode.UTF16_Code_Unit_Offset :=
520523 J1.First_UTF16_Offset;
521524
522525 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));
524527 U2 : constant VSS.Unicode.UTF16_Code_Unit_Offset :=
525528 J2.First_UTF16_Offset;
526529
527530 Dummy : Boolean;
528531
529532 begin
530- while Span.first .character /= J1.First_UTF16_Offset - U1
533+ while Span.start .character /= Integer ( J1.First_UTF16_Offset - U1)
531534 and then J1.Forward
532535 loop
533536 null ;
534537 end loop ;
535538
536539 From := J1.Marker;
537540
538- while Span.last .character /= J2.First_UTF16_Offset - U2
541+ while Span.an_end .character /= Integer ( J2.First_UTF16_Offset - U2)
539542 and then J2.Forward
540543 loop
541544 null ;
@@ -560,7 +563,7 @@ package body LSP.GPR_Documents is
560563 -- ------------------------
561564
562565 function Versioned_Identifier
563- (Self : Document) return LSP.Messages .VersionedTextDocumentIdentifier is
566+ (Self : Document) return LSP.Structures .VersionedTextDocumentIdentifier is
564567 begin
565568 return (uri => Self.URI,
566569 version => Self.Version);
0 commit comments