Skip to content

Commit abb3e3f

Browse files
committed
Simplify the foldingRanges fix
Refs #1276
1 parent 03a19f5 commit abb3e3f

File tree

1 file changed

+5
-50
lines changed

1 file changed

+5
-50
lines changed

source/ada/lsp-ada_documents.adb

Lines changed: 5 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -830,13 +830,6 @@ package body LSP.Ada_Documents is
830830
procedure Store_Span (Span : LSP.Structures.A_Range);
831831
-- Include Span to the result .
832832

833-
function Traverse_Node
834-
(Node : Ada_Node;
835-
Visit : access function (Node : Ada_Node'Class) return Visit_Status)
836-
return Visit_Status;
837-
-- The same as Libadalang.Analysis.Traverse, but without raising
838-
-- exception on a null node.
839-
840833
-----------
841834
-- Parse --
842835
-----------
@@ -1014,53 +1007,15 @@ package body LSP.Ada_Documents is
10141007
end if;
10151008
end Store_Span;
10161009

1017-
-------------------
1018-
-- Traverse_Node --
1019-
-------------------
1020-
1021-
function Traverse_Node
1022-
(Node : Ada_Node;
1023-
Visit : access function (Node : Ada_Node'Class) return Visit_Status)
1024-
return Visit_Status
1025-
is
1026-
Status : Visit_Status := Into;
1027-
begin
1028-
if not Node.Is_Null then
1029-
Status := Visit (Node);
1030-
-- Skip processing the child nodes if the returned status is Over
1031-
-- or Stop. In the former case the previous call to Visit has
1032-
-- taken care of processing the needed childs, and in the latter
1033-
-- case we must immediately stop processing the tree.
1034-
if Status = Into then
1035-
for I in 1 .. Children_Count (Node) loop
1036-
declare
1037-
Cur_Child : constant Ada_Node :=
1038-
Child (Node, I);
1039-
begin
1040-
if not Cur_Child.Is_Null then
1041-
Status := Traverse_Node (Cur_Child, Visit);
1042-
exit when Status /= Into;
1043-
end if;
1044-
end;
1045-
end loop;
1046-
end if;
1047-
end if;
1048-
1049-
if Status = Stop then
1050-
return Stop;
1051-
-- At this stage the Over status has no sense and we just continue
1052-
-- processing the tree.
1053-
else
1054-
return Into;
1055-
end if;
1056-
end Traverse_Node;
1057-
10581010
Token : Token_Reference;
10591011
Span : LSP.Structures.A_Range;
1060-
Ignore : constant Visit_Status :=
1061-
Traverse_Node (Self.Unit (Context).Root, Parse'Access);
1012+
Root : constant Ada_Node'Class := Self.Unit (Context).Root;
10621013

10631014
begin
1015+
if not Root.Is_Null then
1016+
Traverse (Root, Parse'Access);
1017+
end if;
1018+
10641019
if not Comments then
10651020
-- do not process comments
10661021
return;

0 commit comments

Comments
 (0)