Skip to content

Commit a073940

Browse files
committed
Correctly handle functions with default args
Make workspace navigation work correctly for default arg functions Correctly generate specs for all arity variants
1 parent f2c27c5 commit a073940

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

apps/language_server/lib/language_server/source_file.ex

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
defmodule ElixirLS.LanguageServer.SourceFile do
22
import ElixirLS.LanguageServer.Protocol
3+
require ElixirSense.Core.Introspection, as: Introspection
34
require Logger
45

56
defstruct [:text, :version, :language_id, dirty?: false]
@@ -163,10 +164,16 @@ defmodule ElixirLS.LanguageServer.SourceFile do
163164
nil
164165

165166
docs ->
166-
# TODO handle default arguments
167167
Enum.find_value(docs, fn
168-
{{^fun, ^arity}, line, _, _, _, _metadata} -> line
169-
_ -> nil
168+
{{^fun, a}, line, _, _, _, metadata} ->
169+
default_args = Map.get(metadata, :defaults, 0)
170+
171+
if Introspection.matches_arity_with_defaults?(a, default_args, arity) do
172+
line
173+
end
174+
175+
_ ->
176+
nil
170177
end)
171178
end
172179
end

0 commit comments

Comments
 (0)