From 8e122bf62006115074389d7e2c8906ea1d0d526a Mon Sep 17 00:00:00 2001 From: Lukasz Samson Date: Wed, 26 Jul 2023 17:40:43 +0200 Subject: [PATCH] resolve TODOs --- lib/elixir_sense.ex | 8 +++----- lib/elixir_sense/core/introspection.ex | 1 - lib/elixir_sense/core/metadata.ex | 13 ------------- lib/elixir_sense/providers/implementation.ex | 2 +- 4 files changed, 4 insertions(+), 20 deletions(-) diff --git a/lib/elixir_sense.ex b/lib/elixir_sense.ex index 17f090b4..0ea92678 100644 --- a/lib/elixir_sense.ex +++ b/lib/elixir_sense.ex @@ -7,7 +7,6 @@ defmodule ElixirSense do """ alias ElixirSense.Core.Applications - alias ElixirSense.Core.Introspection alias ElixirSense.Core.Metadata alias ElixirSense.Core.ModuleStore alias ElixirSense.Core.Parser @@ -107,9 +106,9 @@ defmodule ElixirSense do :none -> nil - %{begin: {line, _col}} = context -> + context -> buffer_file_metadata = Parser.parse_string(code, true, true, line) - # TODO line from cursor or begin? + env = Metadata.get_env(buffer_file_metadata, {line, column}) |> Metadata.add_scope_vars(buffer_file_metadata, {line, column}) @@ -418,8 +417,7 @@ defmodule ElixirSense do [] %{ - begin: {begin_line, begin_col}, - end: {line, col} + begin: {begin_line, begin_col} } = context -> buffer_file_metadata = Parser.parse_string(code, true, true, line) diff --git a/lib/elixir_sense/core/introspection.ex b/lib/elixir_sense/core/introspection.ex index 267f93fd..f2fc0e53 100644 --- a/lib/elixir_sense/core/introspection.ex +++ b/lib/elixir_sense/core/introspection.ex @@ -990,7 +990,6 @@ defmodule ElixirSense.Core.Introspection do [] end - # TODO return a list here if default args in metadata? def get_spec_as_string(_module, function, arity, :macro, %{implementing: behaviour}) do TypeInfo.get_callback(behaviour, :"MACRO-#{function}", arity + 1) |> spec_to_string() end diff --git a/lib/elixir_sense/core/metadata.ex b/lib/elixir_sense/core/metadata.ex index 3c78444c..905f9a5c 100644 --- a/lib/elixir_sense/core/metadata.ex +++ b/lib/elixir_sense/core/metadata.ex @@ -226,19 +226,6 @@ defmodule ElixirSense.Core.Metadata do end end - def get_call_arity(%__MODULE__{} = metadata, line, col) do - calls = get_calls(metadata, line) - - case Enum.find(calls, fn %State.CallInfo{position: {_line, column}, func: func} -> - column + String.length(Atom.to_string(func)) == col - end) do - %{arity: arity} -> arity - _ -> nil - end - end - - # TODO check which version is better - def get_call_arity(%__MODULE__{}, _module, nil, _line, _column), do: nil def get_call_arity( diff --git a/lib/elixir_sense/providers/implementation.ex b/lib/elixir_sense/providers/implementation.ex index 29321efa..3b10b9c8 100644 --- a/lib/elixir_sense/providers/implementation.ex +++ b/lib/elixir_sense/providers/implementation.ex @@ -171,7 +171,7 @@ defmodule ElixirSense.Providers.Implementation do {{line, column}, type} = metadata.mods_funs_to_positions |> Enum.find_value(fn - {{^module, ^maybe_callback, a}, info} when is_nil(maybe_callback) -> + {{^module, ^maybe_callback, _}, info} when is_nil(maybe_callback) -> {List.last(info.positions), info.type} {{^module, ^maybe_callback, a}, info} when not is_nil(a) ->