diff --git a/lib/elixir_sense.ex b/lib/elixir_sense.ex index 45f110d9..e4a3fc02 100644 --- a/lib/elixir_sense.ex +++ b/lib/elixir_sense.ex @@ -201,7 +201,7 @@ defmodule ElixirSense do args_list: ["list", "index", "value"], arity: 3, def_arity: 3, needed_require: nil, needed_import: nil, name: "insert_at", metadata: %{}, snippet: nil, visibility: :public, - spec: "@spec insert_at(list, integer, any) :: list", summary: "Returns a list with `value` inserted at the specified `index`."}] + spec: "@spec insert_at(list(), integer(), any()) :: list()", summary: "Returns a list with `value` inserted at the specified `index`."}] """ @spec suggestions(String.t(), pos_integer, pos_integer, keyword()) :: [Suggestion.suggestion()] def suggestions(buffer, line, column, opts \\ []) do @@ -268,7 +268,7 @@ defmodule ElixirSense do %{name: "flatten", params: ["list"], documentation: "Flattens the given `list` of nested lists.", - spec: "@spec flatten(deep_list) :: list when deep_list: [any | deep_list]"}, + spec: "@spec flatten(deep_list) :: list() when deep_list: [any() | deep_list]"}, %{name: "flatten", params: ["list", "tail"], documentation: "Flattens the given `list` of nested lists.\\nThe list `tail` will be added at the end of\\nthe flattened list.", diff --git a/lib/elixir_sense/core/introspection.ex b/lib/elixir_sense/core/introspection.ex index 122d2e93..26731589 100644 --- a/lib/elixir_sense/core/introspection.ex +++ b/lib/elixir_sense/core/introspection.ex @@ -895,9 +895,7 @@ defmodule ElixirSense.Core.Introspection do "" end - formated_spec = name_str <> returns_str - - formated_spec |> String.replace("()", "") + name_str <> returns_str end def define_callback?(mod, fun, arity) do @@ -1341,7 +1339,7 @@ defmodule ElixirSense.Core.Introspection do end binary = Macro.to_string(quoted) - "@#{kind} #{binary}" |> String.replace("()", "") + "@#{kind} #{binary}" end) end diff --git a/lib/elixir_sense/core/type_info.ex b/lib/elixir_sense/core/type_info.ex index cc8d3ca1..ff897fad 100644 --- a/lib/elixir_sense/core/type_info.ex +++ b/lib/elixir_sense/core/type_info.ex @@ -166,12 +166,12 @@ defmodule ElixirSense.Core.TypeInfo do end def spec_ast_to_string(ast) do - ast |> Macro.to_string() |> String.replace("()", "") + ast |> Macro.to_string() end def type_spec_to_string({kind, type}) do binary = Typespec.type_to_quoted(type) |> Macro.to_string() - "@#{kind} #{binary}" |> String.replace("()", "") + "@#{kind} #{binary}" end def get_type_spec_as_string(module, type, arity) do @@ -700,6 +700,6 @@ defmodule ElixirSense.Core.TypeInfo do end def typespec_to_string(kind, spec) do - "@#{kind} #{spec |> Macro.to_string() |> String.replace("()", "")}" + "@#{kind} #{spec |> Macro.to_string()}" end end diff --git a/test/elixir_sense/core/introspection_test.exs b/test/elixir_sense/core/introspection_test.exs index afbb79ac..1699e20c 100644 --- a/test/elixir_sense/core/introspection_test.exs +++ b/test/elixir_sense/core/introspection_test.exs @@ -10,7 +10,7 @@ defmodule ElixirSense.Core.IntrospectionTest do type_ast = TypeInfo.get_type_ast(GenServer, :debug) assert format_spec_ast(type_ast) == """ - debug :: [:trace | :log | :statistics | {:log_to_file, Path.t}]\ + debug() :: [:trace | :log | :statistics | {:log_to_file, Path.t()}]\ """ end @@ -18,10 +18,10 @@ defmodule ElixirSense.Core.IntrospectionTest do type_ast = TypeInfo.get_type_ast(GenServer, :on_start) assert format_spec_ast(type_ast) == """ - on_start :: - {:ok, pid} | + on_start() :: + {:ok, pid()} | :ignore | - {:error, {:already_started, pid} | term}\ + {:error, {:already_started, pid()} | term()}\ """ end @@ -29,7 +29,7 @@ defmodule ElixirSense.Core.IntrospectionTest do ast = get_callback_ast(ElixirSenseExample.CallbackOpaque, :do_stuff, 2) assert format_spec_ast(ast) == """ - do_stuff(t(a), term) :: t(a) when a: any\ + do_stuff(t(a), term()) :: t(a) when a: any()\ """ end @@ -39,7 +39,7 @@ defmodule ElixirSense.Core.IntrospectionTest do |> remove_first_macro_arg() assert format_spec_ast(ast) == """ - required(atom) :: Macro.t\ + required(atom()) :: Macro.t()\ """ end @@ -47,9 +47,9 @@ defmodule ElixirSense.Core.IntrospectionTest do ast = get_callback_ast(GenServer, :code_change, 3) assert format_spec_ast(ast) == """ - code_change(old_vsn, state :: term, extra :: term) :: - {:ok, new_state :: term} | - {:error, reason :: term} when old_vsn: term | {:down, term}\ + code_change(old_vsn, state :: term(), extra :: term()) :: + {:ok, new_state :: term()} | + {:error, reason :: term()} when old_vsn: term() | {:down, term()}\ """ end @@ -59,7 +59,7 @@ defmodule ElixirSense.Core.IntrospectionTest do name: :do_stuff, arity: 2, callback: """ - @callback do_stuff(t(a), term) :: t(a) when a: any\ + @callback do_stuff(t(a), term()) :: t(a) when a: any()\ """, signature: "do_stuff(t, term)", doc: "Does stuff to opaque arg\n", @@ -73,7 +73,7 @@ defmodule ElixirSense.Core.IntrospectionTest do assert [ %{ arity: 0, - callback: "@callback callback_mode :: callback_mode_result", + callback: "@callback callback_mode() :: callback_mode_result()", doc: summary, kind: :callback, metadata: %{optional: false}, @@ -92,7 +92,7 @@ defmodule ElixirSense.Core.IntrospectionTest do %{ arity: 2, name: :blame, - callback: "@callback blame(t, stacktrace) :: {t, stacktrace}", + callback: "@callback blame(t(), stacktrace()) :: {t(), stacktrace()}", doc: "Called from `Exception.blame/3` to augment the exception struct.\n\nCan be used to collect additional information about the exception\nor do some additional expensive computation.\n", signature: "blame(t, stacktrace)", @@ -103,7 +103,7 @@ defmodule ElixirSense.Core.IntrospectionTest do arity: 1, name: :exception, doc: nil, - callback: "@callback exception(term) :: t", + callback: "@callback exception(term()) :: t()", signature: "exception(term)", metadata: %{optional: false}, kind: :callback @@ -111,7 +111,7 @@ defmodule ElixirSense.Core.IntrospectionTest do %{ arity: 1, name: :message, - callback: "@callback message(t) :: String.t", + callback: "@callback message(t()) :: String.t()", doc: nil, signature: "message(t)", metadata: %{optional: false}, @@ -128,8 +128,8 @@ defmodule ElixirSense.Core.IntrospectionTest do assert info.arity == 3 assert info.callback =~ """ - @callback code_change(old_vsn, state :: term, extra :: term) :: - {:ok, new_state :: term} | + @callback code_change(old_vsn, state :: term(), extra :: term()) :: + {:ok, new_state :: term()} | """ assert info.doc =~ "Invoked to change the state of the `GenServer`" @@ -143,7 +143,7 @@ defmodule ElixirSense.Core.IntrospectionTest do %{ description: "{:ok, new_state}", snippet: "{:ok, \"${1:new_state}$\"}", - spec: "{:ok, new_state :: term} when old_vsn: term" <> _ + spec: "{:ok, new_state :: term()} when old_vsn: term()" <> _ } | _ ] = returns @@ -153,7 +153,8 @@ defmodule ElixirSense.Core.IntrospectionTest do returns = get_returns_from_callback(ElixirSenseExample.BehaviourWithMacrocallback, :required, 1) - assert [%{description: "Macro.t", snippet: "\"${1:Macro.t}$\"", spec: "Macro.t"}] = returns + assert [%{description: "Macro.t()", snippet: "\"${1:Macro.t()}$\"", spec: "Macro.t()"}] = + returns end test "get_returns_from_callback (all types in 'when')" do @@ -163,36 +164,39 @@ defmodule ElixirSense.Core.IntrospectionTest do %{ description: "{:reply, reply, new_state}", snippet: "{:reply, \"${1:reply}$\", \"${2:new_state}$\"}", - spec: "{:reply, reply, new_state} when reply: term, new_state: term, reason: term" + spec: + "{:reply, reply, new_state} when reply: term(), new_state: term(), reason: term()" }, %{ description: - "{:reply, reply, new_state, timeout | :hibernate | {:continue, term}}", + "{:reply, reply, new_state, timeout() | :hibernate | {:continue, term()}}", snippet: - "{:reply, \"${1:reply}$\", \"${2:new_state}$\", \"${3:timeout | :hibernate | {:continue, term}}$\"}", - spec: "{:reply, reply, new_state, timeout | :hibernate | {:continue, term}}" <> _ + "{:reply, \"${1:reply}$\", \"${2:new_state}$\", \"${3:timeout() | :hibernate | {:continue, term()}}$\"}", + spec: + "{:reply, reply, new_state, timeout() | :hibernate | {:continue, term()}}" <> _ }, %{ description: "{:noreply, new_state}", snippet: "{:noreply, \"${1:new_state}$\"}", - spec: "{:noreply, new_state} when reply: term, new_state: term, reason: term" + spec: "{:noreply, new_state} when reply: term(), new_state: term(), reason: term()" }, %{ - description: "{:noreply, new_state, timeout | :hibernate | {:continue, term}}", + description: "{:noreply, new_state, timeout() | :hibernate | {:continue, term()}}", snippet: - "{:noreply, \"${1:new_state}$\", \"${2:timeout | :hibernate | {:continue, term}}$\"}", - spec: "{:noreply, new_state, timeout | :hibernate | {:continue, term}}" <> _ + "{:noreply, \"${1:new_state}$\", \"${2:timeout() | :hibernate | {:continue, term()}}$\"}", + spec: "{:noreply, new_state, timeout() | :hibernate | {:continue, term()}}" <> _ }, %{ description: "{:stop, reason, reply, new_state}", snippet: "{:stop, \"${1:reason}$\", \"${2:reply}$\", \"${3:new_state}$\"}", spec: - "{:stop, reason, reply, new_state} when reply: term, new_state: term, reason: term" + "{:stop, reason, reply, new_state} when reply: term(), new_state: term(), reason: term()" }, %{ description: "{:stop, reason, new_state}", snippet: "{:stop, \"${1:reason}$\", \"${2:new_state}$\"}", - spec: "{:stop, reason, new_state} when reply: term, new_state: term, reason: term" + spec: + "{:stop, reason, new_state} when reply: term(), new_state: term(), reason: term()" } ] = returns end @@ -204,19 +208,19 @@ defmodule ElixirSense.Core.IntrospectionTest do %{ description: "{:next_state, nextStateName, newStateData}", snippet: "{:next_state, \"${1:nextStateName}$\", \"${2:newStateData}$\"}", - spec: "{:next_state, nextStateName :: atom, newStateData :: term}" + spec: "{:next_state, nextStateName :: atom(), newStateData :: term()}" }, %{ - description: "{:next_state, nextStateName, newStateData, timeout | :hibernate}", + description: "{:next_state, nextStateName, newStateData, timeout() | :hibernate}", snippet: - "{:next_state, \"${1:nextStateName}$\", \"${2:newStateData}$\", \"${3:timeout | :hibernate}$\"}", + "{:next_state, \"${1:nextStateName}$\", \"${2:newStateData}$\", \"${3:timeout() | :hibernate}$\"}", spec: - "{:next_state, nextStateName :: atom, newStateData :: term, timeout | :hibernate}" + "{:next_state, nextStateName :: atom(), newStateData :: term(), timeout() | :hibernate}" }, %{ description: "{:stop, reason, newStateData}", snippet: "{:stop, \"${1:reason}$\", \"${2:newStateData}$\"}", - spec: "{:stop, reason :: term, newStateData :: term}" + spec: "{:stop, reason :: term(), newStateData :: term()}" } ] end diff --git a/test/elixir_sense/core/metadata_builder_test.exs b/test/elixir_sense/core/metadata_builder_test.exs index 014e2c6e..071dad8f 100644 --- a/test/elixir_sense/core/metadata_builder_test.exs +++ b/test/elixir_sense/core/metadata_builder_test.exs @@ -2933,9 +2933,9 @@ defmodule ElixirSense.Core.MetadataBuilderTest do generated: [false, false], specs: [ "@callback with_spec(t, boolean) :: number", - "@callback with_spec(t, integer) :: String.t", + "@callback with_spec(t, integer) :: String.t()", "@spec with_spec(t, boolean) :: number", - "@spec with_spec(t, integer) :: String.t" + "@spec with_spec(t, integer) :: String.t()" ] }, {Proto, :with_spec, nil} => %ElixirSense.Core.State.SpecInfo{ @@ -2947,9 +2947,9 @@ defmodule ElixirSense.Core.MetadataBuilderTest do generated: [false, false], specs: [ "@callback with_spec(t, boolean) :: number", - "@callback with_spec(t, integer) :: String.t", + "@callback with_spec(t, integer) :: String.t()", "@spec with_spec(t, boolean) :: number", - "@spec with_spec(t, integer) :: String.t" + "@spec with_spec(t, integer) :: String.t()" ] }, {Proto, :without_spec, nil} => %ElixirSense.Core.State.SpecInfo{ @@ -3817,7 +3817,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do kind: :spec, name: :private_func, positions: [{2, 3}], - specs: ["@spec private_func :: String.t"] + specs: ["@spec private_func() :: String.t()"] }, {InheritMod, :private_func, nil} => %State.SpecInfo{}, {InheritMod, :some_callback, 1} => %State.SpecInfo{ @@ -4698,7 +4698,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do positions: [{3, 3}], end_positions: [{3, 30}], generated: [false], - specs: ["@typep no_args :: integer"] + specs: ["@typep no_args() :: integer"] }, {My, :no_args, nil} => %ElixirSense.Core.State.TypeInfo{ args: [[]], @@ -4707,7 +4707,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do positions: [{3, 3}], end_positions: [{3, 30}], generated: [false], - specs: ["@typep no_args :: integer"] + specs: ["@typep no_args() :: integer"] }, {My, :overloaded, 0} => %ElixirSense.Core.State.TypeInfo{ args: [[]], @@ -4864,7 +4864,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do positions: [{5, 3}], end_positions: [nil], generated: [false], - specs: ["@macrocallback other(x) :: Macro.t when x: integer"] + specs: ["@macrocallback other(x) :: Macro.t() when x: integer"] }, {Proto, :other, nil} => %ElixirSense.Core.State.SpecInfo{ kind: :macrocallback, @@ -4873,7 +4873,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do positions: [{5, 3}], end_positions: [nil], generated: [false], - specs: ["@macrocallback other(x) :: Macro.t when x: integer"] + specs: ["@macrocallback other(x) :: Macro.t() when x: integer"] } } end @@ -4895,23 +4895,23 @@ defmodule ElixirSense.Core.MetadataBuilderTest do {Proto, :abc, 1} => %State.SpecInfo{ args: [["{%Model.User{}}"]], specs: [ - "@spec abc({%Model.User{}}) :: [%Model.UserOrder{order: Model.Order.t}, local_type]" + "@spec abc({%Model.User{}}) :: [%Model.UserOrder{order: Model.Order.t()}, local_type()]" ] }, {Proto, :abc, nil} => %State.SpecInfo{ args: [["{%Model.User{}}"]], specs: [ - "@spec abc({%Model.User{}}) :: [%Model.UserOrder{order: Model.Order.t}, local_type]" + "@spec abc({%Model.User{}}) :: [%Model.UserOrder{order: Model.Order.t()}, local_type()]" ] } } = state.specs assert %{ {Proto, :local_type, 0} => %State.TypeInfo{ - specs: ["@type local_type :: Model.User.t"] + specs: ["@type local_type() :: Model.User.t()"] }, {Proto, :local_type, nil} => %State.TypeInfo{ - specs: ["@type local_type :: Model.User.t"] + specs: ["@type local_type() :: Model.User.t()"] } } = state.types end @@ -4949,7 +4949,7 @@ defmodule ElixirSense.Core.MetadataBuilderTest do assert %{ {MyRecords, :user, 0} => %State.TypeInfo{ name: :user, - specs: ["@type user :: record(:user, name: String.t, age: integer)"] + specs: ["@type user :: record(:user, name: String.t(), age: integer)"] } } = state.types end diff --git a/test/elixir_sense/docs_test.exs b/test/elixir_sense/docs_test.exs index 67c6b0e7..663a9b83 100644 --- a/test/elixir_sense/docs_test.exs +++ b/test/elixir_sense/docs_test.exs @@ -86,7 +86,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @spec flatten(deep_list) :: list when deep_list: [any | deep_list] + @spec flatten(deep_list) :: list() when deep_list: [any() | deep_list] ``` Flattens the given `list` of nested lists. @@ -124,7 +124,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @spec flatten(list) :: list + @spec flatten(list()) :: list() ``` """ @@ -160,7 +160,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @spec flatten(list) :: list + @spec flatten(list()) :: list() ``` """ @@ -177,7 +177,7 @@ defmodule ElixirSense.DocsTest do defmodule MyLocalModule do @behaviour MyBehaviour - + @impl true def flatten(list) do [] @@ -207,7 +207,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @callback flatten(list) :: list + @callback flatten(list()) :: list() ``` """ @@ -249,7 +249,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @callback go(t) :: integer + @callback go(t) :: integer() ``` """ @@ -331,7 +331,7 @@ defmodule ElixirSense.DocsTest do defmodule MyLocalModule do @behaviour MyBehaviour - + @impl true defmacro flatten(list) do [] @@ -362,7 +362,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @macrocallback flatten(list) :: list + @macrocallback flatten(list()) :: list() ``` """ @@ -373,7 +373,7 @@ defmodule ElixirSense.DocsTest do buffer = """ defmodule MyLocalModule do @behaviour ElixirSenseExample.BehaviourWithMeta - + @impl true def flatten(list) do [] @@ -405,7 +405,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @callback flatten(list) :: list + @callback flatten(list()) :: list() ``` """ end @@ -414,7 +414,7 @@ defmodule ElixirSense.DocsTest do buffer = """ defmodule MyLocalModule do @behaviour :gen_statem - + @impl true def init(list) do [] @@ -447,7 +447,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @callback init(args :: term) ::\ + @callback init(args :: term()) ::\ """ assert docs =~ @@ -459,7 +459,7 @@ defmodule ElixirSense.DocsTest do buffer = """ defmodule MyLocalModule do @behaviour ElixirSenseExample.BehaviourWithMeta - + @impl true defmacro bar(list) do [] @@ -492,7 +492,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @macrocallback bar(integer) :: Macro.t + @macrocallback bar(integer()) :: Macro.t() ``` Docs for bar @@ -528,7 +528,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @spec flatten(list) :: list + @spec flatten(list()) :: list() ``` """ @@ -567,7 +567,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @spec flatten(list) :: list + @spec flatten(list()) :: list() ``` """ @@ -625,7 +625,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @spec flatten(list) :: list + @spec flatten(list()) :: list() ``` """ @@ -653,7 +653,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @spec flatten(deep_list) :: list when deep_list: [any | deep_list] + @spec flatten(deep_list) :: list() when deep_list: [any() | deep_list] ``` Flattens the given `list` of nested lists. @@ -682,7 +682,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @spec flatten(deepList) :: list when deepList: [term | deepList], list: [term] + @spec flatten(deepList) :: list when deepList: [term() | deepList], list: [term()] ``` """ @@ -716,7 +716,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @spec boolean or boolean :: boolean + @spec boolean() or boolean() :: boolean() ``` """ @@ -756,8 +756,8 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @spec some(integer) :: Macro.t - @spec some(b) :: Macro.t when b: float + @spec some(integer()) :: Macro.t() + @spec some(b) :: Macro.t() when b: float() ``` some macro @@ -807,7 +807,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @spec flatten(deep_list) :: list when deep_list: [any | deep_list] + @spec flatten(deep_list) :: list() when deep_list: [any() | deep_list] ``` Flattens the given `list` of nested lists. @@ -1562,7 +1562,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @callback foo :: :ok + @callback foo() :: :ok ``` Docs for foo @@ -1593,7 +1593,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @callback baz(integer) :: :ok + @callback baz(integer()) :: :ok ``` Docs for baz @@ -1624,7 +1624,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @macrocallback bar(integer) :: Macro.t + @macrocallback bar(integer()) :: Macro.t() ``` Docs for bar @@ -1653,7 +1653,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @callback init(args :: term) :: + @callback init(args :: term()) :: """ assert docs =~ "Whenever a `gen_server` process is started" @@ -1686,7 +1686,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @callback init(args :: term) :: init_result(state) + @callback init(args :: term()) :: init_result(state()) ``` """ else @@ -1718,7 +1718,7 @@ defmodule ElixirSense.DocsTest do ### Specs ``` - @spec flatten(deep_list) :: list when deep_list: [any | deep_list] + @spec flatten(deep_list) :: list() when deep_list: [any() | deep_list] ``` Flattens the given `list` of nested lists. @@ -1863,11 +1863,11 @@ defmodule ElixirSense.DocsTest do ElixirSense.docs(buffer, 3, 34) assert docs =~ "2 params version" - assert docs =~ "@spec my_func(1 | 2) :: binary" - assert docs =~ "@spec my_func(1 | 2, binary) :: binary" + assert docs =~ "@spec my_func(1 | 2) :: binary()" + assert docs =~ "@spec my_func(1 | 2, binary()) :: binary()" refute docs =~ "no params version" - refute docs =~ "@spec my_func :: binary" + refute docs =~ "@spec my_func() :: binary()" refute docs =~ "3 params version" refute docs =~ "@spec my_func(1, 2, 3) :: :ok" refute docs =~ "@spec my_func(2, 2, 3) :: :error" @@ -1984,11 +1984,11 @@ defmodule ElixirSense.DocsTest do ElixirSense.docs(buffer, 3, 19) assert docs =~ "2 params version" - assert docs =~ "@spec my_func(1 | 2) :: binary" - assert docs =~ "@spec my_func(1 | 2, binary) :: binary" + assert docs =~ "@spec my_func(1 | 2) :: binary()" + assert docs =~ "@spec my_func(1 | 2, binary()) :: binary()" refute docs =~ "no params version" - refute docs =~ "@spec my_func :: binary" + refute docs =~ "@spec my_func() :: binary()" refute docs =~ "3 params version" refute docs =~ "@spec my_func(1, 2, 3) :: :ok" refute docs =~ "@spec my_func(2, 2, 3) :: :error" diff --git a/test/elixir_sense/location_test.exs b/test/elixir_sense/location_test.exs index 035d6741..783ecb0c 100644 --- a/test/elixir_sense/location_test.exs +++ b/test/elixir_sense/location_test.exs @@ -14,19 +14,33 @@ defmodule ElixirSense.LocationTest do describe "find_mod_fun_source/3" do test "returns location of a core Elixir function" do - assert %ElixirSense.Location{type: :function, line: 26, column: 3, file: file} = - find_mod_fun_source(String, :length, 1) + if not File.exists?(String.module_info(:compile)[:source]) do + assert %ElixirSense.Location{type: :function, line: 26, column: 3, file: file} = + find_mod_fun_source(String, :length, 1) - assert String.ends_with?(file, "/mock_elixir_src/lib/elixir/lib/string.ex") + assert String.ends_with?(file, "/mock_elixir_src/lib/elixir/lib/string.ex") + else + assert %ElixirSense.Location{type: :function, file: file} = + find_mod_fun_source(String, :length, 1) + + assert file == Path.expand(String.module_info(:compile)[:source]) + end end end describe "find_type_source/3" do test "returns location of a core Elixir type" do - assert %ElixirSense.Location{type: :typespec, line: 11, column: 3, file: file} = - find_type_source(String, :t, 0) + if not File.exists?(String.module_info(:compile)[:source]) do + assert %ElixirSense.Location{type: :typespec, line: 11, column: 3, file: file} = + find_type_source(String, :t, 0) + + assert String.ends_with?(file, "/mock_elixir_src/lib/elixir/lib/string.ex") + else + assert %ElixirSense.Location{type: :typespec, file: file} = + find_type_source(String, :t, 0) - assert String.ends_with?(file, "/mock_elixir_src/lib/elixir/lib/string.ex") + assert file == Path.expand(String.module_info(:compile)[:source]) + end end end end diff --git a/test/elixir_sense/providers/suggestion/complete_test.exs b/test/elixir_sense/providers/suggestion/complete_test.exs index 6e67175e..6d1424c3 100644 --- a/test/elixir_sense/providers/suggestion/complete_test.exs +++ b/test/elixir_sense/providers/suggestion/complete_test.exs @@ -141,7 +141,7 @@ defmodule ElixirSense.Providers.Suggestion.CompleteTest do arity: 1, name: "with_default", origin: "ElixirSenseExample.BehaviourWithMacrocallback.Impl", - spec: "@spec with_default(atom, list, integer) :: Macro.t", + spec: "@spec with_default(atom(), list(), integer()) :: Macro.t()", summary: "some macro with default arg\n", type: :macro }, @@ -150,7 +150,7 @@ defmodule ElixirSense.Providers.Suggestion.CompleteTest do arity: 2, name: "with_default", origin: "ElixirSenseExample.BehaviourWithMacrocallback.Impl", - spec: "@spec with_default(atom, list, integer) :: Macro.t", + spec: "@spec with_default(atom(), list(), integer()) :: Macro.t()", summary: "some macro with default arg\n", type: :macro }, @@ -159,7 +159,7 @@ defmodule ElixirSense.Providers.Suggestion.CompleteTest do arity: 3, name: "with_default", origin: "ElixirSenseExample.BehaviourWithMacrocallback.Impl", - spec: "@spec with_default(atom, list, integer) :: Macro.t", + spec: "@spec with_default(atom(), list(), integer()) :: Macro.t()", summary: "some macro with default arg\n", type: :macro } @@ -400,7 +400,7 @@ defmodule ElixirSense.Providers.Suggestion.CompleteTest do name: "printable?", arity: 1, spec: - "@spec printable?(t, 0) :: true\n@spec printable?(t, pos_integer | :infinity) :: boolean", + "@spec printable?(t(), 0) :: true\n@spec printable?(t(), pos_integer() | :infinity) :: boolean()", summary: "Checks if a string contains only printable characters up to `character_limit`." }, @@ -408,7 +408,7 @@ defmodule ElixirSense.Providers.Suggestion.CompleteTest do name: "printable?", arity: 2, spec: - "@spec printable?(t, 0) :: true\n@spec printable?(t, pos_integer | :infinity) :: boolean", + "@spec printable?(t(), 0) :: true\n@spec printable?(t(), pos_integer() | :infinity) :: boolean()", summary: "Checks if a string contains only printable characters up to `character_limit`." } @@ -1941,7 +1941,7 @@ defmodule ElixirSense.Providers.Suggestion.CompleteTest do %{ arity: 2, name: "or", - spec: "@spec boolean or boolean :: boolean", + spec: "@spec boolean() or boolean() :: boolean()", type: :function, args: "boolean(), boolean()", origin: ":erlang", @@ -1962,7 +1962,7 @@ defmodule ElixirSense.Providers.Suggestion.CompleteTest do %{ arity: 2, name: "and", - spec: "@spec boolean and boolean :: boolean", + spec: "@spec boolean() and boolean() :: boolean()", type: :function, args: "boolean(), boolean()", origin: ":erlang", @@ -1988,7 +1988,7 @@ defmodule ElixirSense.Providers.Suggestion.CompleteTest do arity: 1, name: "whereis", origin: ":erlang", - spec: "@spec whereis(regName) :: pid | port | :undefined when regName: atom", + spec: "@spec whereis(regName) :: pid() | port() | :undefined when regName: atom()", type: :function } ] = expand(~c":erlang.where") diff --git a/test/elixir_sense/providers/suggestion_test.exs b/test/elixir_sense/providers/suggestion_test.exs index 52454346..5e98a877 100644 --- a/test/elixir_sense/providers/suggestion_test.exs +++ b/test/elixir_sense/providers/suggestion_test.exs @@ -98,7 +98,7 @@ defmodule ElixirSense.Providers.SuggestionTest do arity: 2, name: "delete_at", origin: "List", - spec: "@spec delete_at(list, integer) :: list", + spec: "@spec delete_at(list(), integer()) :: list()", summary: "Produces a new list by " <> _, type: :function } @@ -121,7 +121,7 @@ defmodule ElixirSense.Providers.SuggestionTest do arity: 2, name: "delete_at", origin: "List", - spec: "@spec delete_at(list, integer) :: list", + spec: "@spec delete_at(list(), integer()) :: list()", summary: "Produces a new list " <> _, type: :function } diff --git a/test/elixir_sense/signature_test.exs b/test/elixir_sense/signature_test.exs index 36442b82..a23aa882 100644 --- a/test/elixir_sense/signature_test.exs +++ b/test/elixir_sense/signature_test.exs @@ -258,7 +258,7 @@ defmodule ElixirSense.SignatureTest do params: [], documentation: "An integer or a float", name: "number", - spec: "@type number :: integer | float" + spec: "@type number() :: integer() | float()" } ] } @@ -281,7 +281,8 @@ defmodule ElixirSense.SignatureTest do documentation: "some macro\n", name: "some", params: ["var"], - spec: "@spec some(integer) :: Macro.t\n@spec some(b) :: Macro.t when b: float" + spec: + "@spec some(integer()) :: Macro.t()\n@spec some(b) :: Macro.t() when b: float()" } ] } @@ -325,14 +326,14 @@ defmodule ElixirSense.SignatureTest do name: "flatten", params: ["deepList"], spec: - "@spec flatten(deepList) :: list when deepList: [term | deepList], list: [term]" + "@spec flatten(deepList) :: list when deepList: [term() | deepList], list: [term()]" }, %{ documentation: summary2, name: "flatten", params: ["deepList", "tail"], spec: - "@spec flatten(deepList, tail) :: list when deepList: [term | deepList], tail: [term], list: [term]" + "@spec flatten(deepList, tail) :: list when deepList: [term() | deepList], tail: [term()], list: [term()]" } ] } = ElixirSense.signature(code, 2, 24) @@ -360,7 +361,7 @@ defmodule ElixirSense.SignatureTest do name: "flatten", params: ["list"], documentation: "Flattens the given `list` of nested lists.", - spec: "@spec flatten(deep_list) :: list when deep_list: [any | deep_list]" + spec: "@spec flatten(deep_list) :: list() when deep_list: [any() | deep_list]" }, %{ name: "flatten", @@ -389,7 +390,7 @@ defmodule ElixirSense.SignatureTest do name: "flatten", params: ["list"], documentation: "Flattens the given `list` of nested lists.", - spec: "@spec flatten(deep_list) :: list when deep_list: [any | deep_list]" + spec: "@spec flatten(deep_list) :: list() when deep_list: [any() | deep_list]" }, %{ name: "flatten", @@ -418,7 +419,7 @@ defmodule ElixirSense.SignatureTest do name: "flatten", params: ["list"], documentation: "Flattens the given `list` of nested lists.", - spec: "@spec flatten(deep_list) :: list when deep_list: [any | deep_list]" + spec: "@spec flatten(deep_list) :: list() when deep_list: [any() | deep_list]" }, %{ name: "flatten", @@ -447,7 +448,7 @@ defmodule ElixirSense.SignatureTest do "Returns and removes the value at the specified `index` in the `list`.", name: "pop_at", params: ["list", "index", "default \\\\ nil"], - spec: "@spec pop_at(list, integer, any) :: {any, list}" + spec: "@spec pop_at(list(), integer(), any()) :: {any(), list()}" } ] } @@ -469,7 +470,7 @@ defmodule ElixirSense.SignatureTest do name: "starts_with?", params: ["list", "prefix"], spec: - "@spec starts_with?([...], [...]) :: boolean\n@spec starts_with?(list, []) :: true\n@spec starts_with?([], [...]) :: false" + "@spec starts_with?([...], [...]) :: boolean()\n@spec starts_with?(list(), []) :: true\n@spec starts_with?([], [...]) :: false" } ] } @@ -509,7 +510,7 @@ defmodule ElixirSense.SignatureTest do name: "flatten", params: ["list"], documentation: "Flattens the given `list` of nested lists.", - spec: "@spec flatten(deep_list) :: list when deep_list: [any | deep_list]" + spec: "@spec flatten(deep_list) :: list() when deep_list: [any() | deep_list]" }, %{ name: "flatten", @@ -538,7 +539,7 @@ defmodule ElixirSense.SignatureTest do "Glues two documents (`doc1` and `doc2`) inserting the given\nbreak `break_string` between them.", name: "glue", params: ["doc1", "break_string \\\\ \" \"", "doc2"], - spec: "@spec glue(t, binary, t) :: t" + spec: "@spec glue(t(), binary(), t()) :: t()" } ] } @@ -559,7 +560,7 @@ defmodule ElixirSense.SignatureTest do "Glues two documents (`doc1` and `doc2`) inserting the given\nbreak `break_string` between them.", name: "glue", params: ["doc1", "break_string \\\\ \" \"", "doc2"], - spec: "@spec glue(t, binary, t) :: t" + spec: "@spec glue(t(), binary(), t()) :: t()" } ] } @@ -581,7 +582,7 @@ defmodule ElixirSense.SignatureTest do "Glues two documents (`doc1` and `doc2`) inserting the given\nbreak `break_string` between them.", name: "glue", params: ["doc1", "break_string \\\\ \" \"", "doc2"], - spec: "@spec glue(t, binary, t) :: t" + spec: "@spec glue(t(), binary(), t()) :: t()" } ] } @@ -604,7 +605,7 @@ defmodule ElixirSense.SignatureTest do "Glues two documents (`doc1` and `doc2`) inserting the given\nbreak `break_string` between them.", name: "glue", params: ["doc1", "break_string \\\\ \" \"", "doc2"], - spec: "@spec glue(t, binary, t) :: t" + spec: "@spec glue(t(), binary(), t()) :: t()" } ] } @@ -626,7 +627,7 @@ defmodule ElixirSense.SignatureTest do "Glues two documents (`doc1` and `doc2`) inserting the given\nbreak `break_string` between them.", name: "glue", params: ["doc1", "break_string \\\\ \" \"", "doc2"], - spec: "@spec glue(t, binary, t) :: t" + spec: "@spec glue(t(), binary(), t()) :: t()" } ] } @@ -685,14 +686,14 @@ defmodule ElixirSense.SignatureTest do params: ["fun", "args"], documentation: "Invokes the given anonymous function `fun` with the list of\narguments `args`.", - spec: "@spec apply((... -> any), [any]) :: any" + spec: "@spec apply((... -> any()), [any()]) :: any()" }, %{ name: "apply", params: ["module", "function_name", "args"], documentation: "Invokes the given function from `module` with the list of\narguments `args`.", - spec: "@spec apply(module, function_name :: atom, [any]) :: any" + spec: "@spec apply(module(), function_name :: atom(), [any()]) :: any()" } ] } @@ -889,7 +890,7 @@ defmodule ElixirSense.SignatureTest do name: "terminate", params: ["_reason", "_state"], documentation: "Invoked when the server is about to exit" <> _, - spec: "@callback terminate(reason, state :: term) :: term" <> _ + spec: "@callback terminate(reason, state :: term()) :: term()" <> _ } ] } = ElixirSense.signature(code, 5, 15) @@ -919,7 +920,7 @@ defmodule ElixirSense.SignatureTest do name: "init", params: ["arg"], documentation: summary, - spec: "@callback init(args :: term) ::" <> _ + spec: "@callback init(args :: term()) ::" <> _ } ] } = ElixirSense.signature(code, 5, 10) @@ -942,7 +943,7 @@ defmodule ElixirSense.SignatureTest do documentation: "Docs for bar", name: "bar", params: ["b"], - spec: "@macrocallback bar(integer) :: Macro.t" + spec: "@macrocallback bar(integer()) :: Macro.t()" } ] } = ElixirSense.signature(code, 2, 60) @@ -963,7 +964,7 @@ defmodule ElixirSense.SignatureTest do documentation: "- Args = " <> _, name: "init", params: ["_"], - spec: "@callback init(args :: term) :: init_result(state)" + spec: "@callback init(args :: term()) :: init_result(state())" } ] } = res @@ -985,7 +986,7 @@ defmodule ElixirSense.SignatureTest do documentation: "- Args = " <> _, name: "init", params: ["args"], - spec: "@callback init(args :: term) ::" <> _ + spec: "@callback init(args :: term()) ::" <> _ } ] } = res @@ -1001,7 +1002,7 @@ defmodule ElixirSense.SignatureTest do defmodule MyLocalModule do @behaviour MyBehaviour - + @impl true def flatten(list) do [] @@ -1025,7 +1026,7 @@ defmodule ElixirSense.SignatureTest do documentation: "", name: "flatten", params: ["list"], - spec: "@callback flatten(list) :: list" + spec: "@callback flatten(list()) :: list()" } ] } = res @@ -1060,7 +1061,7 @@ defmodule ElixirSense.SignatureTest do documentation: "", name: "go", params: ["t"], - spec: "@callback go(t) :: integer" + spec: "@callback go(t) :: integer()" } ] } = res @@ -1076,7 +1077,7 @@ defmodule ElixirSense.SignatureTest do defmodule MyLocalModule do @behaviour MyBehaviour - + @impl true defmacro flatten(list) do [] @@ -1101,7 +1102,7 @@ defmodule ElixirSense.SignatureTest do documentation: "", name: "flatten", params: ["list"], - spec: "@macrocallback flatten(list) :: list" + spec: "@macrocallback flatten(list()) :: list()" } ] } = res @@ -1111,7 +1112,7 @@ defmodule ElixirSense.SignatureTest do code = """ defmodule MyLocalModule do @behaviour ElixirSenseExample.BehaviourWithMeta - + @impl true def flatten(list) do [] @@ -1134,7 +1135,7 @@ defmodule ElixirSense.SignatureTest do documentation: "Sample doc", name: "flatten", params: ["list"], - spec: "@callback flatten(list) :: list" + spec: "@callback flatten(list()) :: list()" } ] } = res @@ -1144,7 +1145,7 @@ defmodule ElixirSense.SignatureTest do code = """ defmodule MyLocalModule do @behaviour :gen_statem - + @impl true def init(list) do [] @@ -1168,7 +1169,7 @@ defmodule ElixirSense.SignatureTest do documentation: "- Args = term" <> _, name: "init", params: ["list"], - spec: "@callback init(args :: term) :: init_result(state)" + spec: "@callback init(args :: term()) :: init_result(state())" } ] } = res @@ -1179,7 +1180,7 @@ defmodule ElixirSense.SignatureTest do code = """ defmodule MyLocalModule do @behaviour ElixirSenseExample.BehaviourWithMeta - + @impl true defmacro bar(list) do [] @@ -1203,7 +1204,7 @@ defmodule ElixirSense.SignatureTest do documentation: "Docs for bar", name: "bar", params: ["list"], - spec: "@macrocallback bar(integer) :: Macro.t" + spec: "@macrocallback bar(integer()) :: Macro.t()" } ] } = res @@ -1309,7 +1310,7 @@ defmodule ElixirSense.SignatureTest do params: ["device", "item", "opts"], documentation: "Inspects `item` according to the given options using the IO `device`.", - spec: "@spec inspect(device, item, keyword) :: item when item: var" + spec: "@spec inspect(device(), item, keyword()) :: item when item: var" } ] } = ElixirSense.signature(code, 2, 24) @@ -1452,7 +1453,7 @@ defmodule ElixirSense.SignatureTest do documentation: "", name: "or", params: [_, _], - spec: "@spec boolean or boolean :: boolean" + spec: "@spec boolean() or boolean() :: boolean()" } ] } = ElixirSense.signature(buffer, 4, 14) @@ -1475,7 +1476,7 @@ defmodule ElixirSense.SignatureTest do documentation: summary, name: "date", params: [], - spec: "@spec date :: date when date: :calendar.date" + spec: "@spec date() :: date when date: :calendar.date()" } ] } = ElixirSense.signature(buffer, 2, 16) diff --git a/test/elixir_sense/suggestions_test.exs b/test/elixir_sense/suggestions_test.exs index f9a49b9f..b40371cf 100644 --- a/test/elixir_sense/suggestions_test.exs +++ b/test/elixir_sense/suggestions_test.exs @@ -231,7 +231,7 @@ defmodule ElixirSense.SuggestionsTest do def_arity: 1, name: "flatten", origin: "List", - spec: "@spec flatten(deep_list) :: list when deep_list: [any | deep_list]", + spec: "@spec flatten(deep_list) :: list() when deep_list: [any() | deep_list]", summary: "Flattens the given `list` of nested lists.", type: :function, metadata: %{}, @@ -275,7 +275,8 @@ defmodule ElixirSense.SuggestionsTest do def_arity: 1, name: "some", origin: "ElixirSenseExample.BehaviourWithMacrocallback.Impl", - spec: "@spec some(integer) :: Macro.t\n@spec some(b) :: Macro.t when b: float", + spec: + "@spec some(integer()) :: Macro.t()\n@spec some(b) :: Macro.t() when b: float()", summary: "some macro\n", type: :macro, metadata: %{}, @@ -340,7 +341,7 @@ defmodule ElixirSense.SuggestionsTest do arity: 3, name: "code_change", origin: "GenServer", - spec: "@callback code_change(old_vsn, state :: term, extra :: term) ::" <> _, + spec: "@callback code_change(old_vsn, state :: term(), extra :: term()) ::" <> _, summary: "Invoked to change the state of the `GenServer` when a different version of a\nmodule is loaded (hot code swapping) and the state's term structure should be\nchanged.", type: :callback @@ -441,7 +442,7 @@ defmodule ElixirSense.SuggestionsTest do name: "optional", subtype: :macrocallback, origin: "ElixirSenseExample.BehaviourWithMacrocallback", - spec: "@macrocallback optional(a) :: Macro.t when a: atom", + spec: "@macrocallback optional(a) :: Macro.t() when a: atom()", summary: "An optional macrocallback\n", type: :callback, metadata: %{optional: true} @@ -453,7 +454,7 @@ defmodule ElixirSense.SuggestionsTest do name: "required", subtype: :macrocallback, origin: "ElixirSenseExample.BehaviourWithMacrocallback", - spec: "@macrocallback required(atom) :: Macro.t", + spec: "@macrocallback required(atom()) :: Macro.t()", summary: "A required macrocallback\n", type: :callback, metadata: %{optional: false} @@ -540,7 +541,7 @@ defmodule ElixirSense.SuggestionsTest do arity: 0, name: "foo", origin: "ElixirSenseExample.OverridableBehaviour", - spec: "@callback foo :: any", + spec: "@callback foo() :: any()", summary: "", type: :callback, subtype: :callback, @@ -552,7 +553,7 @@ defmodule ElixirSense.SuggestionsTest do metadata: %{optional: false}, name: "bar", origin: "ElixirSenseExample.OverridableBehaviour", - spec: "@macrocallback bar(any) :: Macro.t", + spec: "@macrocallback bar(any()) :: Macro.t()", subtype: :macrocallback, summary: "", type: :callback @@ -643,7 +644,7 @@ defmodule ElixirSense.SuggestionsTest do arity: 3, name: "reduce", origin: "Enumerable", - spec: "@callback reduce(t, acc, reducer) :: result", + spec: "@callback reduce(t(), acc(), reducer()) :: result()", summary: "Reduces the `enumerable` into an element.", type: :protocol_function, metadata: %{} @@ -668,7 +669,7 @@ defmodule ElixirSense.SuggestionsTest do arity: 3, name: "reduce", origin: "Enumerable", - spec: "@callback reduce(t, acc, reducer) :: result", + spec: "@callback reduce(t(), acc(), reducer()) :: result()", summary: "Reduces the `enumerable` into an element.", type: :protocol_function, metadata: %{} @@ -695,41 +696,45 @@ defmodule ElixirSense.SuggestionsTest do %{ description: "{:reply, reply, new_state}", snippet: "{:reply, \"${1:reply}$\", \"${2:new_state}$\"}", - spec: "{:reply, reply, new_state} when reply: term, new_state: term, reason: term", + spec: + "{:reply, reply, new_state} when reply: term(), new_state: term(), reason: term()", type: :return }, %{ description: - "{:reply, reply, new_state, timeout | :hibernate | {:continue, term}}", + "{:reply, reply, new_state, timeout() | :hibernate | {:continue, term()}}", snippet: - "{:reply, \"${1:reply}$\", \"${2:new_state}$\", \"${3:timeout | :hibernate | {:continue, term}}$\"}", - spec: "{:reply, reply, new_state, timeout | :hibernate | {:continue, term}}" <> _, + "{:reply, \"${1:reply}$\", \"${2:new_state}$\", \"${3:timeout() | :hibernate | {:continue, term()}}$\"}", + spec: + "{:reply, reply, new_state, timeout() | :hibernate | {:continue, term()}}" <> _, type: :return }, %{ description: "{:noreply, new_state}", snippet: "{:noreply, \"${1:new_state}$\"}", - spec: "{:noreply, new_state} when reply: term, new_state: term, reason: term", + spec: + "{:noreply, new_state} when reply: term(), new_state: term(), reason: term()", type: :return }, %{ - description: "{:noreply, new_state, timeout | :hibernate | {:continue, term}}", + description: "{:noreply, new_state, timeout() | :hibernate | {:continue, term()}}", snippet: - "{:noreply, \"${1:new_state}$\", \"${2:timeout | :hibernate | {:continue, term}}$\"}", - spec: "{:noreply, new_state, timeout | :hibernate | {:continue, term}}" <> _, + "{:noreply, \"${1:new_state}$\", \"${2:timeout() | :hibernate | {:continue, term()}}$\"}", + spec: "{:noreply, new_state, timeout() | :hibernate | {:continue, term()}}" <> _, type: :return }, %{ description: "{:stop, reason, reply, new_state}", snippet: "{:stop, \"${1:reason}$\", \"${2:reply}$\", \"${3:new_state}$\"}", spec: - "{:stop, reason, reply, new_state} when reply: term, new_state: term, reason: term", + "{:stop, reason, reply, new_state} when reply: term(), new_state: term(), reason: term()", type: :return }, %{ description: "{:stop, reason, new_state}", snippet: "{:stop, \"${1:reason}$\", \"${2:new_state}$\"}", - spec: "{:stop, reason, new_state} when reply: term, new_state: term, reason: term", + spec: + "{:stop, reason, new_state} when reply: term(), new_state: term(), reason: term()", type: :return } ] = list @@ -752,9 +757,9 @@ defmodule ElixirSense.SuggestionsTest do assert list == [ %{ - description: "Macro.t", - snippet: "\"${1:Macro.t}$\"", - spec: "Macro.t", + description: "Macro.t()", + snippet: "\"${1:Macro.t()}$\"", + spec: "Macro.t()", type: :return } ] @@ -775,15 +780,15 @@ defmodule ElixirSense.SuggestionsTest do assert [ %{ - description: "{:ok, non_neg_integer}", + description: "{:ok, non_neg_integer()}", snippet: "{:ok, non_neg_integer()}", - spec: "{:ok, non_neg_integer}", + spec: "{:ok, non_neg_integer()}", type: :return }, %{ - description: "{:error, module}", + description: "{:error, module()}", snippet: "{:error, module()}", - spec: "{:error, module}", + spec: "{:error, module()}", type: :return } ] == list @@ -850,7 +855,7 @@ defmodule ElixirSense.SuggestionsTest do metadata: %{implementing: MyBehaviour}, name: "flatten", origin: "MyLocalModule", - spec: "@callback flatten(list) :: list", + spec: "@callback flatten(list()) :: list()", # TODO docs summary: "", type: :function, @@ -890,7 +895,7 @@ defmodule ElixirSense.SuggestionsTest do metadata: %{implementing: BB}, name: "go", origin: "BB.String", - spec: "@callback go(t) :: integer", + spec: "@callback go(t) :: integer()", # TODO docs summary: "", type: :function, @@ -938,7 +943,7 @@ defmodule ElixirSense.SuggestionsTest do metadata: %{implementing: MyBehaviour}, name: "flatten", origin: "MyLocalModule", - spec: "@macrocallback flatten(list) :: list", + spec: "@macrocallback flatten(list()) :: list()", # TODO docs summary: "", type: :macro, @@ -977,7 +982,7 @@ defmodule ElixirSense.SuggestionsTest do metadata: %{implementing: ElixirSenseExample.BehaviourWithMeta}, name: "flatten", origin: "MyLocalModule", - spec: "@callback flatten(list) :: list", + spec: "@callback flatten(list()) :: list()", summary: "Sample doc", type: :function, visibility: :public @@ -1016,7 +1021,7 @@ defmodule ElixirSense.SuggestionsTest do metadata: %{implementing: :gen_statem, since: "OTP 19.0"}, name: "init", origin: "MyLocalModule", - spec: "@callback init(args :: term) ::" <> _, + spec: "@callback init(args :: term()) ::" <> _, summary: "- Args = term" <> _, type: :function, visibility: :public @@ -1056,7 +1061,7 @@ defmodule ElixirSense.SuggestionsTest do metadata: %{implementing: ElixirSenseExample.BehaviourWithMeta}, name: "bar", origin: "MyLocalModule", - spec: "@macrocallback bar(integer) :: Macro.t", + spec: "@macrocallback bar(integer()) :: Macro.t()", summary: "Docs for bar", type: :macro, visibility: :public @@ -1093,7 +1098,7 @@ defmodule ElixirSense.SuggestionsTest do metadata: %{implementing: GenServer}, name: "terminate", origin: "MyServer", - spec: "@callback terminate(reason, state :: term) :: term" <> _, + spec: "@callback terminate(reason, state :: term()) :: term()" <> _, summary: "Invoked when the server is about to exit. It should do any cleanup required.", type: :function, @@ -1133,7 +1138,7 @@ defmodule ElixirSense.SuggestionsTest do assert %{ summary: "- InitArgs = Args" <> _, metadata: %{implementing: :gen_event}, - spec: "@callback init(initArgs :: term) ::" <> _, + spec: "@callback init(initArgs :: term()) ::" <> _, args_list: ["arg"] } = init_res end @@ -1187,7 +1192,7 @@ defmodule ElixirSense.SuggestionsTest do name: "baz", origin: "ElixirSenseExample.ExampleBehaviourWithDocCallbackImpl", snippet: nil, - spec: "@callback baz(integer) :: :ok", + spec: "@callback baz(integer()) :: :ok", summary: "Docs for baz", type: :function, visibility: :public @@ -1215,7 +1220,7 @@ defmodule ElixirSense.SuggestionsTest do name: "init", origin: "ElixirSenseExample.ExampleBehaviourWithDocCallbackErlang", snippet: nil, - spec: "@callback init(args :: term) :: init_result(state)", + spec: "@callback init(args :: term()) :: init_result(state())", summary: "- Args = term" <> _, type: :function, visibility: :public @@ -1244,7 +1249,7 @@ defmodule ElixirSense.SuggestionsTest do name: "init", origin: ":file_server", snippet: nil, - spec: "@callback init(args :: term) ::" <> _, + spec: "@callback init(args :: term()) ::" <> _, summary: "- Args = term" <> _, type: :function, visibility: :public