@@ -11,7 +11,6 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.Reducers.Params do
11
11
alias ElixirSense.Core.Introspection
12
12
alias ElixirSense.Core.Metadata
13
13
alias ElixirSense.Core.Source
14
- alias ElixirSense.Core.TypeInfo
15
14
alias ElixirLS.Utils.Matcher
16
15
17
16
@ type param_option :: % {
@@ -51,75 +50,48 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.Reducers.Params do
51
50
cursor_context . cursor_position ,
52
51
not elixir_prefix
53
52
) do
54
- list = for opt <- ElixirSense.Core.Options . get_param_options ( mod , fun , npar + 1 , env , buffer_metadata ) do
55
- case opt do
56
- { name , type } ->
57
- # match on atom:
58
- if Matcher . match? ( to_string ( name ) <> ":" , hint ) do
59
- expanded_spec = Introspection . to_string_with_parens ( type )
60
- % {
61
- doc: "" ,
62
- expanded_spec: expanded_spec ,
63
- name: name |> Atom . to_string ( ) ,
64
- origin: inspect ( mod ) ,
65
- type: :param_option ,
66
- subtype: :keyword ,
67
- type_spec: expanded_spec
68
- }
69
- end
70
- name ->
71
- # match on :atom
72
- if options_so_far == [ ] and cursor_at_option == true and Matcher . match? ( inspect ( name ) , hint ) do
73
- % {
74
- doc: "" ,
75
- expanded_spec: "" ,
76
- name: name |> Atom . to_string ( ) ,
77
- origin: inspect ( mod ) ,
78
- type: :param_option ,
79
- subtype: :atom ,
80
- type_spec: ""
81
- }
82
- end
53
+ list =
54
+ for opt <-
55
+ ElixirSense.Core.Options . get_param_options ( mod , fun , npar + 1 , env , buffer_metadata ) do
56
+ case opt do
57
+ { name , type } ->
58
+ # match on atom:
59
+ if Matcher . match? ( to_string ( name ) <> ":" , hint ) do
60
+ expanded_spec = Introspection . to_string_with_parens ( type )
61
+
62
+ % {
63
+ doc: "" ,
64
+ expanded_spec: expanded_spec ,
65
+ name: name |> Atom . to_string ( ) ,
66
+ origin: inspect ( mod ) ,
67
+ type: :param_option ,
68
+ subtype: :keyword ,
69
+ type_spec: expanded_spec
70
+ }
71
+ end
72
+
73
+ name ->
74
+ # match on :atom
75
+ if options_so_far == [ ] and cursor_at_option == true and
76
+ Matcher . match? ( inspect ( name ) , hint ) do
77
+ % {
78
+ doc: "" ,
79
+ expanded_spec: "" ,
80
+ name: name |> Atom . to_string ( ) ,
81
+ origin: inspect ( mod ) ,
82
+ type: :param_option ,
83
+ subtype: :atom ,
84
+ type_spec: ""
85
+ }
86
+ end
87
+ end
83
88
end
84
- end
85
- |> Enum . reject ( & is_nil / 1 )
89
+ |> Enum . reject ( & is_nil / 1 )
86
90
87
91
{ :cont , % { acc | result: acc . result ++ list } }
88
92
else
89
93
_ ->
90
94
{ :cont , acc }
91
95
end
92
96
end
93
-
94
- defp extract_options ( { :| , _ , [ { atom , type } , rest ] } , acc ) when is_atom ( atom ) do
95
- extract_options ( rest , [ { atom , type } | acc ] )
96
- end
97
-
98
- defp extract_options ( { :| , _ , [ _other , rest ] } , acc ) do
99
- extract_options ( rest , acc )
100
- end
101
-
102
- defp extract_options ( { atom , type } , acc ) when is_atom ( atom ) do
103
- [ { atom , type } | acc ]
104
- end
105
-
106
- defp extract_options ( _other , acc ) , do: acc
107
-
108
- defp options_to_suggestions ( options , original_module ) do
109
- Enum . map ( options , fn
110
- { mod , name , type } ->
111
- TypeInfo . get_type_info ( mod , type , original_module )
112
- |> Map . merge ( % { type: :param_option , name: name |> Atom . to_string ( ) } )
113
-
114
- { mod , name } ->
115
- % {
116
- doc: "" ,
117
- expanded_spec: "" ,
118
- name: name |> Atom . to_string ( ) ,
119
- origin: inspect ( mod ) ,
120
- type: :param_option ,
121
- type_spec: ""
122
- }
123
- end )
124
- end
125
97
end
0 commit comments