Skip to content

Commit 3b0dc54

Browse files
BoulangerAnthonyLeonardoGracio
authored andcommitted
Fix "With" parent node range and name
Properly set the node range to the first and last "with clause". Adapt tests. Close eng/ide/gnatstudio#143 Depends-On eng/ide/gnatstudio!308
1 parent 614d5b1 commit 3b0dc54

File tree

6 files changed

+42
-29
lines changed

6 files changed

+42
-29
lines changed

source/ada/lsp-ada_handlers-symbols.adb

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -324,18 +324,31 @@ package body LSP.Ada_Handlers.Symbols is
324324
Package_Deps_Item : LSP.Structures.DocumentSymbol;
325325
begin
326326
if First_Item.kind = Namespace then
327-
Package_Deps_Item :=
328-
(name => VSS.Strings.To_Virtual_String
329-
("With clauses"),
330-
detail => VSS.Strings.Empty_Virtual_String,
331-
kind => Namespace,
332-
deprecated => (Is_Set => False),
333-
tags => LSP.Constants.Empty,
334-
a_range => First_Item.a_range,
335-
selectionRange => First_Item.a_range,
336-
children => Children,
337-
others => <>);
338-
Vector.Append (Package_Deps_Item);
327+
declare
328+
Last_Item : constant LSP.Structures.DocumentSymbol :=
329+
LSP.Structures.Get_DocumentSymbol_Constant_Reference
330+
(Children, Children.Length);
331+
With_Range : constant LSP.Structures.A_Range :=
332+
(First_Item.a_range.start, Last_Item.a_range.an_end);
333+
With_Selection : constant LSP.Structures.A_Range :=
334+
(First_Item.a_range.start,
335+
(First_Item.a_range.start.line,
336+
First_Item.a_range.start.character + 4));
337+
begin
338+
Package_Deps_Item :=
339+
(name =>
340+
VSS.Strings.To_Virtual_String ("With clauses"),
341+
detail =>
342+
VSS.Strings.Empty_Virtual_String,
343+
kind => Namespace,
344+
deprecated => (Is_Set => False),
345+
tags => LSP.Constants.Empty,
346+
a_range => With_Range,
347+
selectionRange => With_Selection,
348+
children => Children,
349+
others => <>);
350+
Vector.Append (Package_Deps_Item);
351+
end;
339352
else
340353
for J in 1 .. Children.Length loop
341354
Vector.Append (Children (J));

testsuite/ada_lsp/SA21-029.documentSymbol.with/test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
},
110110
"end": {
111111
"line": 0,
112-
"character": 17
112+
"character": 4
113113
}
114114
},
115115
"children": [

testsuite/ada_lsp/UA28-007.Did_Change_Watched_Files_0/test.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@
493493
"character": 0
494494
},
495495
"end": {
496-
"line": 0,
496+
"line": 1,
497497
"character": 9
498498
}
499499
},
@@ -504,7 +504,7 @@
504504
},
505505
"end": {
506506
"line": 0,
507-
"character": 9
507+
"character": 4
508508
}
509509
},
510510
"children": [
@@ -644,7 +644,7 @@
644644
},
645645
"end": {
646646
"line": 0,
647-
"character": 9
647+
"character": 4
648648
}
649649
},
650650
"children": [

testsuite/ada_lsp/UA28-007.Did_Create_Files_0/test.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@
452452
"character": 0
453453
},
454454
"end": {
455-
"line": 0,
455+
"line": 1,
456456
"character": 9
457457
}
458458
},
@@ -463,7 +463,7 @@
463463
},
464464
"end": {
465465
"line": 0,
466-
"character": 9
466+
"character": 4
467467
}
468468
},
469469
"children": [
@@ -687,7 +687,7 @@
687687
},
688688
"end": {
689689
"line": 0,
690-
"character": 9
690+
"character": 4
691691
}
692692
},
693693
"children": [
@@ -804,7 +804,7 @@
804804
"character": 0
805805
},
806806
"end": {
807-
"line": 0,
807+
"line": 1,
808808
"character": 9
809809
}
810810
},
@@ -815,7 +815,7 @@
815815
},
816816
"end": {
817817
"line": 0,
818-
"character": 9
818+
"character": 4
819819
}
820820
},
821821
"children": [
@@ -974,7 +974,7 @@
974974
},
975975
"end": {
976976
"line": 0,
977-
"character": 9
977+
"character": 4
978978
}
979979
},
980980
"children": [

testsuite/ada_lsp/UA28-007.Did_Delete_Files_0/test.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@
451451
"character": 0
452452
},
453453
"end": {
454-
"line": 0,
454+
"line": 1,
455455
"character": 9
456456
}
457457
},
@@ -462,7 +462,7 @@
462462
},
463463
"end": {
464464
"line": 0,
465-
"character": 9
465+
"character": 4
466466
}
467467
},
468468
"children": [
@@ -638,7 +638,7 @@
638638
},
639639
"end": {
640640
"line": 0,
641-
"character": 9
641+
"character": 4
642642
}
643643
},
644644
"children": [
@@ -788,7 +788,7 @@
788788
"character": 0
789789
},
790790
"end": {
791-
"line": 0,
791+
"line": 1,
792792
"character": 9
793793
}
794794
},
@@ -799,7 +799,7 @@
799799
},
800800
"end": {
801801
"line": 0,
802-
"character": 9
802+
"character": 4
803803
}
804804
},
805805
"children": [

testsuite/ada_lsp/UA28-007.Did_Rename_Files_0/test.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@
888888
},
889889
"end": {
890890
"line": 0,
891-
"character": 9
891+
"character": 4
892892
}
893893
},
894894
"children": [
@@ -1016,7 +1016,7 @@
10161016
},
10171017
"end": {
10181018
"line": 0,
1019-
"character": 9
1019+
"character": 4
10201020
}
10211021
},
10221022
"children": [

0 commit comments

Comments
 (0)