Skip to content

Commit

Permalink
Improve context awareness of completion (#1386)
Browse files Browse the repository at this point in the history
- Only relevant type completions should be suggested when in
  type context (such as -spec, -type, and type defintion inside -record).
- Don't include args in completion When pointer is right before (
  • Loading branch information
plux authored Oct 4, 2022
1 parent 96b7adb commit bd7e901
Show file tree
Hide file tree
Showing 4 changed files with 538 additions and 94 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-module(code_navigation_extra).

-export([ do/1, do_2/0, 'DO_LOUDER'/0 ]).
-export([ do/1, do_2/0, 'DO_LOUDER'/0, function_a/2 ]).

do(_Config) ->
do_4(1, foo).
Expand All @@ -21,3 +21,8 @@ do_4(_, _) ->

'DO_LOUDER'() ->
'Code.Navigation.Elixirish':do('Atom').

function_a(Arg1, Arg2) ->
funct(),
code_navigation:().
code_navigation:funct().
15 changes: 14 additions & 1 deletion apps/els_lsp/priv/code_navigation/src/code_navigation_types.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

-type type_a() :: atom().

-export_type([ type_a/0 ]).
-export_type([ type_a/0, type_b/0, user_type_c/0 ]).

-opaque opaque_type_a() :: atom().

Expand All @@ -13,3 +13,16 @@
-include("transitive.hrl").

-type user_type_b() :: type_b().
-type user_type_c() :: user_type_b().
-record(record_a,
{field_a = an_atom :: user_type_a()}).

-type user_type_c() :: #{
key_a := user_type_a()
}.

-spec function_a(A :: user_type_a()) -> B :: user_type_b().
function_a(type_a) ->
type_b.

-type user_type_d() :: type() | code_navigation:().
Loading

0 comments on commit bd7e901

Please sign in to comment.