Skip to content

Commit

Permalink
Merge branch 'topic/1160' into 'master'
Browse files Browse the repository at this point in the history
Filter out SyntheticObjectDecl from completion results

Closes #1160

See merge request eng/libadalang/libadalang!1480
  • Loading branch information
thvnx committed Nov 29, 2023
2 parents 0a28732 + 6cedd51 commit 3ac4132
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
14 changes: 10 additions & 4 deletions ada/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,16 @@ def complete():
return origin.bind(
Self.origin_node,
Entity.complete_items.filter(
# This property filters out `SyntheticSubpDecl` items
# because they are of no use for completion. Additional
# filtering can be done in `complete_items`.
lambda n: n.decl.cast(T.SyntheticSubpDecl).is_null
# This property filters out `SyntheticSubpDecl` and
# `SyntheticObjectDecl` items because they are of no use for
# completion. This is not entirely true for
# `SyntheticObjectDecl` since they can be useful in type
# predicate aspects (yet not implemented since no likely
# helpful). Additional filtering can be done in
# `complete_items`.
lambda n: Not(
n.decl.is_a(T.SyntheticSubpDecl, T.SyntheticObjectDecl)
)
).to_iterator
)

Expand Down
16 changes: 4 additions & 12 deletions testsuite/tests/properties/complete/test.out
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,7 @@ Working on node <SubtypeDecl ["Drum_Unit"] disass.adb:18:4-21:4>
================================================================

Eval 'list(node.f_subtype.f_constraint.p_complete)'
Result: [<CompletionItem decl=<SyntheticObjectDecl ["Drum_Unit"] disass.adb:18:4-21:4> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<EnumLiteralDecl ["Closed"] disass.adb:4:29-4:35> is_dot_call=False is_visible=True weight=0>,
Result: [<CompletionItem decl=<EnumLiteralDecl ["Closed"] disass.adb:4:29-4:35> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<ConcreteTypeDecl ["Device"] disass.adb:3:4-3:41> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<EnumLiteralDecl ["Disk"] disass.adb:3:29-3:33> is_dot_call=False is_visible=True weight=100>,
<CompletionItem decl=<EnumLiteralDecl ["Drum"] disass.adb:3:35-3:39> is_dot_call=False is_visible=True weight=100>,
Expand Down Expand Up @@ -688,8 +687,7 @@ Working on node <Id "B" subtype_indication.adb:20:22-20:23>
===========================================================

Eval 'list(node.p_complete)'
Result: [<CompletionItem decl=<SyntheticObjectDecl ["Babar"] subtype_indication.adb:20:4-20:23> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<ObjectDecl ["A"] subtype_indication.adb:2:4-2:10> is_dot_call=False is_visible=True weight=0>,
Result: [<CompletionItem decl=<ObjectDecl ["A"] subtype_indication.adb:2:4-2:10> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<ObjectDecl ["B"] subtype_indication.adb:10:4-10:10> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<ConcreteTypeDecl ["Babar"] subtype_indication.adb:20:4-20:23> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<ConcreteTypeDecl ["Bar"] subtype_indication.adb:15:4-15:28> is_dot_call=False is_visible=True weight=100>,
Expand Down Expand Up @@ -1016,7 +1014,6 @@ Working on node <ComponentDecl ["A"] subtype_indication.adb:34:7-34:13>

Eval 'list(node.f_component_def.f_type_expr.f_name.p_complete)'
Result: [<CompletionItem decl=<ComponentDecl ["A"] subtype_indication.adb:34:7-34:13> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<SyntheticObjectDecl ["T"] subtype_indication.adb:33:4-36:15> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<ObjectDecl ["A"] subtype_indication.adb:2:4-2:10> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<ObjectDecl ["B"] subtype_indication.adb:10:4-10:10> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<ConcreteTypeDecl ["Babar"] subtype_indication.adb:20:4-20:23> is_dot_call=False is_visible=True weight=100>,
Expand Down Expand Up @@ -1083,7 +1080,6 @@ Working on node <ConcreteTypeDecl ["T"] subtype_indication.adb:38:4-38:34>

Eval 'list(node.f_discriminants.f_discr_specs[0].f_type_expr.f_name.p_complete)'
Result: [<CompletionItem decl=<DiscriminantSpec ["D"] subtype_indication.adb:38:12-38:17> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<SyntheticObjectDecl ["T"] subtype_indication.adb:38:4-38:34> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<ObjectDecl ["A"] subtype_indication.adb:2:4-2:10> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<ObjectDecl ["B"] subtype_indication.adb:10:4-10:10> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<ConcreteTypeDecl ["Babar"] subtype_indication.adb:20:4-20:23> is_dot_call=False is_visible=True weight=100>,
Expand Down Expand Up @@ -1149,12 +1145,10 @@ Working on node <DottedName test_pkg-foo.adb:8:7-10:10>
=======================================================

Eval 'list(node.p_complete)'
Result: [<CompletionItem decl=<SyntheticObjectDecl ["A"] test_pkg.ads:4:4-4:50> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<SubpDecl ["My_Method"] test_pkg.ads:6:4-6:49> is_dot_call=True is_visible=True weight=75>,
Result: [<CompletionItem decl=<SubpDecl ["My_Method"] test_pkg.ads:6:4-6:49> is_dot_call=True is_visible=True weight=75>,
<CompletionItem decl=<SubpDecl ["My_Body_Method"] test_pkg.adb:6:4-6:54> is_dot_call=True is_visible=True weight=75>,
<CompletionItem decl=<SubpBody ["My_Method"] test_pkg.adb:8:4-11:18> is_dot_call=True is_visible=True weight=75>,
<CompletionItem decl=<SubpBody ["My_Body_Method"] test_pkg.adb:13:4-18:23> is_dot_call=True is_visible=True weight=75>,
<CompletionItem decl=<SyntheticObjectDecl ["Base_Type"] base.ads:2:4-2:41> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<NullSubpDecl ["Base_Method"] base.ads:3:4-3:53> is_dot_call=True is_visible=True weight=75>]

Working on node <CallStmt testcomp.adb:7:4-9:4>
Expand Down Expand Up @@ -1182,10 +1176,8 @@ Working on node <CallStmt testcomp.adb:19:4-21:1>
=================================================

Eval 'list(node.f_call.p_complete)'
Result: [<CompletionItem decl=<SyntheticObjectDecl ["A"] test_pkg.ads:4:4-4:50> is_dot_call=False is_visible=True weight=0>,
<CompletionItem decl=<SubpDecl ["My_Method"] test_pkg.ads:6:4-6:49> is_dot_call=True is_visible=True weight=75>,
Result: [<CompletionItem decl=<SubpDecl ["My_Method"] test_pkg.ads:6:4-6:49> is_dot_call=True is_visible=True weight=75>,
<CompletionItem decl=<SubpDecl ["My_Body_Method"] test_pkg.adb:6:4-6:54> is_dot_call=True is_visible=True weight=75>,
<CompletionItem decl=<SubpBody ["My_Method"] test_pkg.adb:8:4-11:18> is_dot_call=True is_visible=True weight=75>,
<CompletionItem decl=<SubpBody ["My_Body_Method"] test_pkg.adb:13:4-18:23> is_dot_call=True is_visible=True weight=75>,
<CompletionItem decl=<SyntheticObjectDecl ["Base_Type"] base.ads:2:4-2:41> is_dot_call=False is_visible=False weight=0>,
<CompletionItem decl=<NullSubpDecl ["Base_Method"] base.ads:3:4-3:53> is_dot_call=True is_visible=True weight=75>]

0 comments on commit 3ac4132

Please sign in to comment.