Skip to content

Commit 8bf3374

Browse files
committed
Merge branch 'topic/th_fix' into 'master'
Filter indirect children out of `type_hierarchy/subtypes` Closes #1623 See merge request eng/ide/ada_language_server!2003
2 parents 5ea7d67 + 639f897 commit 8bf3374

File tree

3 files changed

+17
-43
lines changed

3 files changed

+17
-43
lines changed

source/ada/lsp-ada_type_hierarchy_subtypes.adb

+13-1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,16 @@ package body LSP.Ada_Type_Hierarchy_Subtypes is
6262
in out LSP.Client_Message_Receivers.Client_Message_Receiver'Class;
6363
Status : out LSP.Server_Jobs.Execution_Status);
6464

65+
use type Libadalang.Analysis.Basic_Decl;
66+
67+
function Is_Derived_From
68+
(Child : Libadalang.Analysis.Type_Decl;
69+
Parent : Libadalang.Analysis.Basic_Decl) return Boolean
70+
is
71+
(for some Item of Child.P_Base_Types => Item.P_Canonical_Part = Parent);
72+
--
73+
-- Check if Child id a direct childr of Parent.
74+
6575
----------------
6676
-- Create_Job --
6777
----------------
@@ -142,7 +152,9 @@ package body LSP.Ada_Type_Hierarchy_Subtypes is
142152

143153
Loc := Self.Parent.Context.To_LSP_Location (Name.P_Basic_Decl);
144154

145-
if not Self.Filter.Contains (Loc) then
155+
if not Self.Filter.Contains (Loc)
156+
and Is_Derived_From (Tipe, Self.Decl.P_Canonical_Part)
157+
then
146158
Item :=
147159
(name => VSS.Strings.To_Virtual_String
148160
(Name.Text),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
with Other;
2+
package Grand_Children is
3+
type Grand_Child is new Other.Circle with null record;
4+
end Grand_Children;

testsuite/ada_lsp/type_hierarchy/test.json

-42
Original file line numberDiff line numberDiff line change
@@ -142,20 +142,6 @@
142142
"end": { "line": 7, "character": 12 }
143143
}
144144
},
145-
{
146-
"name": "Abstract_Shape",
147-
"kind": 5,
148-
"detail": "at base_types.ads (3:9)",
149-
"uri": "$URI{base_types.ads}",
150-
"range": {
151-
"start": { "line": 2, "character": 3 },
152-
"end": { "line": 2, "character": 23 }
153-
},
154-
"selectionRange": {
155-
"start": { "line": 2, "character": 8 },
156-
"end": { "line": 2, "character": 22 }
157-
}
158-
},
159145
{
160146
"name": "Circle",
161147
"kind": 5,
@@ -252,20 +238,6 @@
252238
"end": { "line": 3, "character": 24 }
253239
}
254240
},
255-
{
256-
"name": "Private_Type",
257-
"kind": 5,
258-
"detail": "at base_types.ads (9:9)",
259-
"uri": "$URI{base_types.ads}",
260-
"range": {
261-
"start": { "line": 8, "character": 3 },
262-
"end": { "line": 8, "character": 32 }
263-
},
264-
"selectionRange": {
265-
"start": { "line": 8, "character": 8 },
266-
"end": { "line": 8, "character": 20 }
267-
}
268-
},
269241
{
270242
"name": "New_Private_Type",
271243
"kind": 5,
@@ -540,20 +512,6 @@
540512
"end": { "line": 3, "character": 24 }
541513
}
542514
},
543-
{
544-
"name": "Private_Type",
545-
"kind": 5,
546-
"detail": "at base_types.ads (9:9)",
547-
"uri": "$URI{base_types.ads}",
548-
"range": {
549-
"start": { "line": 8, "character": 3 },
550-
"end": { "line": 8, "character": 32 }
551-
},
552-
"selectionRange": {
553-
"start": { "line": 8, "character": 8 },
554-
"end": { "line": 8, "character": 20 }
555-
}
556-
},
557515
{
558516
"name": "New_Private_Type",
559517
"kind": 5,

0 commit comments

Comments
 (0)