diff --git a/lib/elixir_sense/core/state.ex b/lib/elixir_sense/core/state.ex index 7a0c9216..2ad3ca13 100644 --- a/lib/elixir_sense/core/state.ex +++ b/lib/elixir_sense/core/state.ex @@ -558,6 +558,15 @@ defmodule ElixirSense.Core.State do type end + overridable = current_info |> Map.get(:overridable, false) + + meta = + if overridable do + Map.put(meta, :overridable, true) + else + meta + end + info = %ModFunInfo{ positions: new_positions, end_positions: new_end_positions, @@ -566,7 +575,7 @@ defmodule ElixirSense.Core.State do doc: doc, meta: meta, generated: [Keyword.get(options, :generated, false) | current_info.generated], - overridable: current_info |> Map.get(:overridable, false) + overridable: overridable } info = @@ -592,7 +601,8 @@ defmodule ElixirSense.Core.State do defp process_option(_state, info, _, {:overridable, {true, module}}) do %ModFunInfo{ info - | overridable: {true, module} + | overridable: {true, module}, + meta: Map.put(info.meta, :overridable, true) } end @@ -921,7 +931,11 @@ defmodule ElixirSense.Core.State do defp make_def_overridable(mods_funs_to_positions, mfa, overridable_module) do update_in(mods_funs_to_positions[mfa], fn mod_fun_info = %ModFunInfo{} -> - %ModFunInfo{mod_fun_info | overridable: {true, overridable_module}} + %ModFunInfo{ + mod_fun_info + | overridable: {true, overridable_module}, + meta: Map.put(mod_fun_info.meta, :overridable, true) + } end) end diff --git a/lib/elixir_sense/providers/suggestion/reducers/callbacks.ex b/lib/elixir_sense/providers/suggestion/reducers/callbacks.ex index c97404a1..64761b69 100644 --- a/lib/elixir_sense/providers/suggestion/reducers/callbacks.ex +++ b/lib/elixir_sense/providers/suggestion/reducers/callbacks.ex @@ -41,6 +41,10 @@ defmodule ElixirSense.Providers.Suggestion.Reducers.Callbacks do for {{_, name, arity}, %State.SpecInfo{} = info} <- behaviour_callbacks, hint == "" or def_prefix?(hint, List.last(info.specs)) or Matcher.match?("#{name}", hint) do + def_info = buffer_metadata.mods_funs_to_positions[{env.module, name, arity}] + def_info_meta = if def_info, do: def_info.meta, else: %{} + meta = info.meta |> Map.merge(def_info_meta) + %{ type: :callback, subtype: info.kind, @@ -51,7 +55,7 @@ defmodule ElixirSense.Providers.Suggestion.Reducers.Callbacks do origin: mod_name, summary: Introspection.extract_summary_from_docs(info.doc), spec: List.last(info.specs), - metadata: info.meta + metadata: meta } end else @@ -99,6 +103,10 @@ defmodule ElixirSense.Providers.Suggestion.Reducers.Callbacks do end end + def_info = buffer_metadata.mods_funs_to_positions[{env.module, name, arity}] + def_info_meta = if def_info, do: def_info.meta, else: %{} + meta = metadata |> Map.merge(def_info_meta) + %{ type: :callback, subtype: kind, @@ -109,7 +117,7 @@ defmodule ElixirSense.Providers.Suggestion.Reducers.Callbacks do origin: mod_name, summary: desc, spec: spec, - metadata: metadata + metadata: meta } end end diff --git a/test/elixir_sense/core/metadata_builder_test.exs b/test/elixir_sense/core/metadata_builder_test.exs index 5b008e45..71c304b7 100644 --- a/test/elixir_sense/core/metadata_builder_test.exs +++ b/test/elixir_sense/core/metadata_builder_test.exs @@ -5831,6 +5831,18 @@ defmodule ElixirSense.Core.MetadataBuilderTest do assert %{meta: %{optional: true}} = state.specs[{Some, :some, 1}] end + + test "overridable" do + state = + """ + defmodule Some do + use ElixirSenseExample.OverridableFunctions + end + """ + |> string_to_state + + assert %{meta: %{overridable: true}} = state.mods_funs_to_positions[{Some, :test, 2}] + end end defp string_to_state(string) do diff --git a/test/elixir_sense/suggestions_test.exs b/test/elixir_sense/suggestions_test.exs index ee5d50cf..30e905b8 100644 --- a/test/elixir_sense/suggestions_test.exs +++ b/test/elixir_sense/suggestions_test.exs @@ -717,12 +717,12 @@ defmodule ElixirSense.SuggestionsTest do summary: "", type: :callback, subtype: :callback, - metadata: %{optional: false} + metadata: %{optional: false, overridable: true} }, %{ args: "any", arity: 1, - metadata: %{optional: false}, + metadata: %{optional: false, overridable: true}, name: "bar", origin: "ElixirSenseExample.OverridableBehaviour", spec: "@macrocallback bar(any()) :: Macro.t()", @@ -749,7 +749,7 @@ defmodule ElixirSense.SuggestionsTest do %{ args: "var", arity: 1, - metadata: %{}, + metadata: %{overridable: true}, name: "required", origin: "ElixirSenseExample.OverridableFunctions", spec: "", @@ -760,7 +760,7 @@ defmodule ElixirSense.SuggestionsTest do %{ args: "x, y", arity: 2, - metadata: %{since: "1.2.3"}, + metadata: %{since: "1.2.3", overridable: true}, name: "test", origin: "ElixirSenseExample.OverridableFunctions", spec: "@spec test(number, number) :: number",