Skip to content

Commit b7f77b2

Browse files
committed
Replace Previous_Non_Trivia by equivalent from LAL API
1 parent 59ee6b3 commit b7f77b2

File tree

3 files changed

+4
-31
lines changed

3 files changed

+4
-31
lines changed

source/ada/lsp-ada_documents.adb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,15 +1109,16 @@ package body LSP.Ada_Documents is
11091109
is
11101110
Previous : Token_Reference :=
11111111
(if Token = No_Token then No_Token
1112-
else LSP.Utils.Previous_Non_Trivia (Token));
1112+
else Libadalang.Common.Previous (Token, Exclude_Trivia => True));
11131113

11141114
begin
11151115
if Previous = No_Token then
11161116
return [];
11171117
end if;
11181118

11191119
if Kind (Data (Previous)) in Ada_Comma | Ada_Dot then
1120-
Previous := LSP.Utils.Previous_Non_Trivia (Previous);
1120+
Previous :=
1121+
Libadalang.Common.Previous (Previous, Exclude_Trivia => True);
11211122
end if;
11221123

11231124
declare

source/ada/lsp-utils.adb

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
with Ada.Strings.Unbounded;
1919
with System;
2020

21+
with Libadalang.Common;
2122
with Libadalang.Lexer;
2223
with Libadalang.Sources;
2324
with Langkit_Support.Diagnostics;
@@ -475,28 +476,6 @@ package body LSP.Utils is
475476
Column_Number_Formatters.Image (Node.Sloc_Range.Start_Column));
476477
end Node_Location_Image;
477478

478-
-------------------------
479-
-- Previous_Non_Trivia --
480-
-------------------------
481-
482-
function Previous_Non_Trivia
483-
(Token : Libadalang.Common.Token_Reference)
484-
return Libadalang.Common.Token_Reference
485-
is
486-
use Libadalang.Common;
487-
488-
begin
489-
return
490-
Result : Token_Reference :=
491-
(if Token = No_Token then No_Token else Previous (Token))
492-
do
493-
while Result /= No_Token and then Libadalang.Common.Is_Trivia (Result)
494-
loop
495-
Result := Previous (Result);
496-
end loop;
497-
end return;
498-
end Previous_Non_Trivia;
499-
500479
-------------------
501480
-- Span_To_Slice --
502481
-------------------

source/ada/lsp-utils.ads

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ with LSP.Structures;
2929
with Langkit_Support.Slocs;
3030

3131
with Libadalang.Analysis;
32-
with Libadalang.Common;
3332

3433
with Pp.Scanner;
3534

@@ -108,12 +107,6 @@ package LSP.Utils is
108107
return VSS.Strings.Virtual_String;
109108
-- Return a string representation of the given value.
110109

111-
function Previous_Non_Trivia
112-
(Token : Libadalang.Common.Token_Reference)
113-
return Libadalang.Common.Token_Reference;
114-
-- Gets the previous Token_Reference relative to Token that is not a
115-
-- whitespace nor a comment.
116-
117110
function To_Range
118111
(Sloc : GPR2.Source_Reference.Object) return LSP.Structures.A_Range;
119112
-- Convert a GPR2 source location into a LSP range.

0 commit comments

Comments
 (0)