Skip to content

Commit 99736c1

Browse files
committed
make tests pass
1 parent 7191aeb commit 99736c1

File tree

5 files changed

+48
-124
lines changed

5 files changed

+48
-124
lines changed

apps/language_server/lib/language_server/providers/completion.ex

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -747,17 +747,15 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
747747
defp from_completion_item(%{type: :param_option} = suggestion, context, _options) do
748748
%{
749749
name: name,
750-
origin: _origin,
751-
doc: doc,
752750
type_spec: type_spec,
753-
expanded_spec: expanded_spec,
751+
origin: origin,
754752
subtype: subtype
755753
} =
756754
suggestion
757755

758756
formatted_spec =
759-
if expanded_spec != "" do
760-
"\n\n```elixir\n#{expanded_spec}\n```\n"
757+
if type_spec != "" do
758+
"\n\n```elixir\n#{type_spec}\n```\n"
761759
else
762760
""
763761
end
@@ -789,8 +787,8 @@ defmodule ElixirLS.LanguageServer.Providers.Completion do
789787

790788
%__MODULE__{
791789
label: to_string(name),
792-
detail: "#{type_spec}",
793-
documentation: "#{doc}#{formatted_spec}",
790+
detail: "#{origin} option",
791+
documentation: formatted_spec,
794792
insert_text: insert_text,
795793
text_edit: text_edit,
796794
priority: 10,

apps/language_server/lib/language_server/providers/completion/reducers/params.ex

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.Reducers.Params do
1818
subtype: :keyword | :atom,
1919
name: String.t(),
2020
origin: String.t(),
21-
type_spec: String.t(),
22-
doc: String.t(),
23-
expanded_spec: String.t()
21+
type_spec: String.t()
2422
}
2523

2624
@doc """
@@ -60,10 +58,8 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.Reducers.Params do
6058
expanded_spec = Introspection.to_string_with_parens(type)
6159

6260
%{
63-
doc: "",
64-
expanded_spec: expanded_spec,
6561
name: name |> Atom.to_string(),
66-
origin: inspect(mod),
62+
origin: "#{inspect(mod)}.#{fun}",
6763
type: :param_option,
6864
subtype: :keyword,
6965
type_spec: expanded_spec
@@ -75,10 +71,8 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.Reducers.Params do
7571
if options_so_far == [] and cursor_at_option == true and
7672
Matcher.match?(inspect(name), hint) do
7773
%{
78-
doc: "",
79-
expanded_spec: "",
8074
name: name |> Atom.to_string(),
81-
origin: inspect(mod),
75+
origin: "#{inspect(mod)}.#{fun}",
8276
type: :param_option,
8377
subtype: :atom,
8478
type_spec: ""

apps/language_server/test/providers/completion/suggestions_test.exs

Lines changed: 38 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -3734,219 +3734,163 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.SuggestionTest do
37343734
test "options as inline list" do
37353735
buffer = "Local.func_with_options_as_inline_list("
37363736

3737-
assert %{type_spec: "local_t()", expanded_spec: "@type local_t() :: atom()"} =
3737+
assert %{type_spec: "atom()"} =
37383738
suggestion_by_name("local_o", buffer)
37393739

37403740
assert %{
3741-
type_spec: "keyword()",
3742-
expanded_spec: """
3743-
@type keyword() :: [
3744-
{atom(), any()}
3745-
]\
3746-
"""
3741+
type_spec: "keyword()"
37473742
} = suggestion_by_name("builtin_o", buffer)
37483743
end
37493744

37503745
test "options vars defined in when" do
3751-
type_spec = "local_t()"
3752-
origin = "ElixirSenseExample.ModuleWithTypespecs.Local"
3753-
spec = "@type local_t() :: atom()"
3746+
type_spec = "atom()"
3747+
origin = "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_option_var_defined_in_when"
37543748

37553749
buffer = "Local.func_with_option_var_defined_in_when("
37563750
suggestion = suggestion_by_name("local_o", buffer)
37573751

37583752
assert suggestion.type_spec == type_spec
37593753
assert suggestion.origin == origin
3760-
assert suggestion.expanded_spec == spec
3754+
3755+
origin = "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options_var_defined_in_when"
37613756

37623757
buffer = "Local.func_with_options_var_defined_in_when("
37633758
suggestion = suggestion_by_name("local_o", buffer)
37643759

37653760
assert suggestion.type_spec == type_spec
37663761
assert suggestion.origin == origin
3767-
assert suggestion.expanded_spec == spec
37683762
end
37693763

37703764
test "opaque type internal structure is not revealed" do
37713765
buffer = "Local.func_with_options("
37723766
suggestion = suggestion_by_name("opaque_o", buffer)
37733767

37743768
assert suggestion.type_spec == "opaque_t()"
3775-
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local"
3776-
assert suggestion.expanded_spec == "@opaque opaque_t()"
3777-
assert suggestion.doc == "Local opaque type"
3769+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
37783770
end
37793771

37803772
test "private type" do
37813773
buffer = "Local.func_with_options("
37823774
suggestion = suggestion_by_name("private_o", buffer)
37833775

3784-
assert suggestion.type_spec == "private_t()"
3785-
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local"
3786-
assert suggestion.expanded_spec == "@typep private_t() :: atom()"
3787-
assert suggestion.doc == ""
3776+
assert suggestion.type_spec == "atom()"
3777+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
37883778
end
37893779

37903780
test "local type" do
37913781
buffer = "Local.func_with_options("
37923782
suggestion = suggestion_by_name("local_o", buffer)
37933783

3794-
assert suggestion.type_spec == "local_t()"
3795-
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local"
3796-
assert suggestion.expanded_spec == "@type local_t() :: atom()"
3797-
assert suggestion.doc == "Local type"
3784+
assert suggestion.type_spec == "atom()"
3785+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
37983786
end
37993787

38003788
test "local type with params" do
38013789
buffer = "Local.func_with_options("
38023790
suggestion = suggestion_by_name("local_with_params_o", buffer)
38033791

3804-
assert suggestion.type_spec == "local_t(atom(), integer())"
3805-
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local"
3806-
assert suggestion.expanded_spec =~ "@type local_t(a, b) ::"
3792+
assert suggestion.type_spec == "{atom(), integer()}"
3793+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
38073794
end
38083795

38093796
test "basic type" do
38103797
buffer = "Local.func_with_options("
38113798
suggestion = suggestion_by_name("basic_o", buffer)
38123799

38133800
assert suggestion.type_spec == "pid()"
3814-
assert suggestion.origin == ""
3815-
assert suggestion.expanded_spec == ""
3816-
assert suggestion.doc == "A process identifier, pid, identifies a process"
3801+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
38173802
end
38183803

38193804
test "basic type with params" do
38203805
buffer = "Local.func_with_options("
38213806
suggestion = suggestion_by_name("basic_with_params_o", buffer)
38223807

38233808
assert suggestion.type_spec == "[atom(), ...]"
3824-
assert suggestion.origin == ""
3825-
assert suggestion.expanded_spec == ""
3826-
assert suggestion.doc == "Non-empty proper list"
3809+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
38273810
end
38283811

38293812
test "built-in type" do
38303813
buffer = "Local.func_with_options("
38313814
suggestion = suggestion_by_name("builtin_o", buffer)
38323815

38333816
assert suggestion.type_spec == "keyword()"
3834-
assert suggestion.origin == ""
3835-
3836-
assert suggestion.expanded_spec == """
3837-
@type keyword() :: [
3838-
{atom(), any()}
3839-
]\
3840-
"""
3841-
3842-
assert suggestion.doc == "A keyword list"
3817+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
38433818
end
38443819

38453820
test "built-in type with params" do
38463821
buffer = "Local.func_with_options("
38473822
suggestion = suggestion_by_name("builtin_with_params_o", buffer)
38483823

38493824
assert suggestion.type_spec == "keyword(term())"
3850-
assert suggestion.origin == ""
3851-
assert suggestion.expanded_spec =~ "@type keyword(t()) ::"
3852-
assert suggestion.doc == "A keyword list with values of type `t`"
3825+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
38533826
end
38543827

38553828
test "union type" do
38563829
buffer = "Local.func_with_options("
38573830
suggestion = suggestion_by_name("union_o", buffer)
38583831

3859-
assert suggestion.type_spec == "union_t()"
3860-
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local"
3861-
3862-
assert suggestion.expanded_spec == """
3863-
@type union_t() ::
3864-
atom() | integer()\
3865-
"""
3832+
assert suggestion.type_spec == "atom() | integer()"
3833+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
38663834
end
38673835

38683836
test "list type" do
38693837
buffer = "Local.func_with_options("
38703838
suggestion = suggestion_by_name("list_o", buffer)
38713839

3872-
assert suggestion.type_spec == "list_t()"
3873-
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local"
3874-
assert suggestion.expanded_spec =~ "@type list_t() ::"
3840+
assert suggestion.type_spec == "[:trace | :log]"
3841+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
38753842
end
38763843

38773844
test "remote type" do
38783845
buffer = "Local.func_with_options("
38793846
suggestion = suggestion_by_name("remote_o", buffer)
38803847

3881-
assert suggestion.type_spec == "ElixirSenseExample.ModuleWithTypespecs.Remote.remote_t()"
3882-
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Remote"
3883-
assert suggestion.expanded_spec == "@type remote_t() :: atom()"
3884-
assert suggestion.doc == "Remote type"
3848+
assert suggestion.type_spec == "atom()"
3849+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
38853850
end
38863851

38873852
test "remote type with args" do
38883853
buffer = "Local.func_with_options("
38893854
suggestion = suggestion_by_name("remote_with_params_o", buffer)
38903855

38913856
assert suggestion.type_spec ==
3892-
"ElixirSenseExample.ModuleWithTypespecs.Remote.remote_t(atom(), integer())"
3857+
"{atom(), integer()}"
38933858

3894-
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Remote"
3895-
assert suggestion.expanded_spec =~ "@type remote_t(a, b) ::"
3896-
assert suggestion.doc == "Remote type with params"
3859+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
38973860
end
38983861

38993862
test "remote erlang type with doc" do
39003863
buffer = "Local.func_with_erlang_type_options("
39013864
suggestion = suggestion_by_name("erlang_t", buffer)
39023865

39033866
assert suggestion.type_spec ==
3904-
":erlang.time_unit()"
3905-
3906-
assert suggestion.origin == ":erlang"
3907-
3908-
assert suggestion.expanded_spec ==
3909-
"@type time_unit() ::\n pos_integer()\n | :second\n | :millisecond\n | :microsecond\n | :nanosecond\n | :native\n | :perf_counter\n | deprecated_time_unit()"
3867+
"pos_integer()\n| :second\n| :millisecond\n| :microsecond\n| :nanosecond\n| :native\n| :perf_counter\n| :seconds\n| :milli_seconds\n| :micro_seconds\n| :nano_seconds"
39103868

3911-
if System.otp_release() |> String.to_integer() >= 23 do
3912-
assert suggestion.doc =~ "Supported time unit representations"
3913-
end
3869+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_erlang_type_options"
39143870
end
39153871

39163872
test "remote aliased type" do
39173873
buffer = "Local.func_with_options("
39183874
suggestion = suggestion_by_name("remote_aliased_o", buffer)
39193875

3920-
assert suggestion.type_spec == "remote_aliased_t()"
3921-
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local"
3922-
3923-
assert suggestion.expanded_spec == """
3924-
@type remote_aliased_t() ::
3925-
ElixirSenseExample.ModuleWithTypespecs.Remote.remote_t()
3926-
| ElixirSenseExample.ModuleWithTypespecs.Remote.remote_list_t()\
3927-
"""
3928-
3929-
assert suggestion.doc == "Remote type from aliased module"
3876+
assert suggestion.type_spec == "atom() | [atom()]"
3877+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
39303878
end
39313879

39323880
test "remote aliased inline type" do
39333881
buffer = "Local.func_with_options("
39343882
suggestion = suggestion_by_name("remote_aliased_inline_o", buffer)
39353883

3936-
assert suggestion.type_spec == "ElixirSenseExample.ModuleWithTypespecs.Remote.remote_t()"
3937-
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Remote"
3938-
assert suggestion.expanded_spec == "@type remote_t() :: atom()"
3939-
assert suggestion.doc == "Remote type"
3884+
assert suggestion.type_spec == "atom()"
3885+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
39403886
end
39413887

39423888
test "inline list type" do
39433889
buffer = "Local.func_with_options("
39443890
suggestion = suggestion_by_name("inline_list_o", buffer)
39453891

39463892
assert suggestion.type_spec == "[:trace | :log]"
3947-
assert suggestion.origin == ""
3948-
assert suggestion.expanded_spec == ""
3949-
assert suggestion.doc == ""
3893+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
39503894
end
39513895

39523896
test "non existent type" do
@@ -3956,14 +3900,12 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.SuggestionTest do
39563900
assert suggestion.type_spec ==
39573901
"ElixirSenseExample.ModuleWithTypespecs.Remote.non_existent()"
39583902

3959-
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Remote"
3960-
assert suggestion.expanded_spec == ""
3961-
assert suggestion.doc == ""
3903+
assert suggestion.origin == "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options"
39623904
end
39633905

39643906
test "named options" do
39653907
buffer = "Local.func_with_named_options("
3966-
assert suggestion_by_name("local_o", buffer).type_spec == "local_t()"
3908+
assert suggestion_by_name("local_o", buffer).type_spec == "atom()"
39673909
end
39683910

39693911
test "options with only one option" do
@@ -3974,14 +3916,14 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.SuggestionTest do
39743916
test "union of options" do
39753917
buffer = "Local.func_with_union_of_options("
39763918

3977-
assert suggestion_by_name("local_o", buffer).type_spec == "local_t()"
3919+
assert suggestion_by_name("local_o", buffer).type_spec == "atom()"
39783920
assert suggestion_by_name("option_1", buffer).type_spec == "atom()"
39793921
end
39803922

39813923
test "union of options inline" do
39823924
buffer = "Local.func_with_union_of_options_inline("
39833925

3984-
assert suggestion_by_name("local_o", buffer).type_spec == "local_t()"
3926+
assert suggestion_by_name("local_o", buffer).type_spec == "atom()"
39853927
assert suggestion_by_name("option_1", buffer).type_spec == "atom()"
39863928
end
39873929

@@ -3990,9 +3932,7 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.SuggestionTest do
39903932
assert suggestion_by_name("option_1", buffer).type_spec == "boolean()"
39913933

39923934
suggestion = suggestion_by_name("remote_option_1", buffer)
3993-
assert suggestion.type_spec == "ElixirSenseExample.ModuleWithTypespecs.Remote.remote_t()"
3994-
assert suggestion.expanded_spec == "@type remote_t() :: atom()"
3995-
assert suggestion.doc == "Remote type"
3935+
assert suggestion.type_spec == "atom()"
39963936
end
39973937

39983938
test "atom only options" do
@@ -4030,15 +3970,7 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.SuggestionTest do
40303970
test "format type spec" do
40313971
buffer = "Local.func_with_options("
40323972

4033-
assert suggestion_by_name("large_o", buffer).expanded_spec == """
4034-
@type large_t() ::
4035-
pid()
4036-
| port()
4037-
| (registered_name ::
4038-
atom())
4039-
| {registered_name ::
4040-
atom(), node()}\
4041-
"""
3973+
assert suggestion_by_name("large_o", buffer).type_spec == "pid() | port() | (registered_name :: atom()) | {registered_name :: atom(), node()}"
40423974
end
40433975

40443976
test "params with default args" do

dep_versions.exs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[
2-
elixir_sense: "710b449732da6d515ed0bbb182c7681968a6d190",
2+
elixir_sense: "46bfe270e86ef549b972d55199355137fac039af",
33
dialyxir_vendored: "f8f64cfb6797c518294687e7c03ae817bacbc6ee",
44
jason_v: "f1c10fa9c445cb9f300266122ef18671054b2330",
55
erl2ex_vendored: "073ac6b9a44282e718b6050c7b27cedf9217a12a",

mix.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"benchee": {:hex, :benchee, "1.1.0", "f3a43817209a92a1fade36ef36b86e1052627fd8934a8b937ac9ab3a76c43062", [:mix], [{:deep_merge, "~> 1.0", [hex: :deep_merge, repo: "hexpm", optional: false]}, {:statistex, "~> 1.0", [hex: :statistex, repo: "hexpm", optional: false]}], "hexpm", "7da57d545003165a012b587077f6ba90b89210fd88074ce3c60ce239eb5e6d93"},
33
"deep_merge": {:hex, :deep_merge, "1.0.0", "b4aa1a0d1acac393bdf38b2291af38cb1d4a52806cf7a4906f718e1feb5ee961", [:mix], [], "hexpm", "ce708e5f094b9cd4e8f2be4f00d2f4250c4095be93f8cd6d018c753894885430"},
44
"dialyxir_vendored": {:git, "https://github.com/elixir-lsp/dialyxir.git", "f8f64cfb6797c518294687e7c03ae817bacbc6ee", [ref: "f8f64cfb6797c518294687e7c03ae817bacbc6ee"]},
5-
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "710b449732da6d515ed0bbb182c7681968a6d190", [ref: "6c293f27ea3afc4f5913a7ed03a07db0fa15a0a2"]},
5+
"elixir_sense": {:git, "https://github.com/elixir-lsp/elixir_sense.git", "46bfe270e86ef549b972d55199355137fac039af", [ref: "6c293f27ea3afc4f5913a7ed03a07db0fa15a0a2"]},
66
"erl2ex_vendored": {:git, "https://github.com/elixir-lsp/erl2ex.git", "073ac6b9a44282e718b6050c7b27cedf9217a12a", [ref: "073ac6b9a44282e718b6050c7b27cedf9217a12a"]},
77
"erlex_vendored": {:git, "https://github.com/elixir-lsp/erlex.git", "c0e448db27bcbb3f369861d13e3b0607ed37048d", [ref: "c0e448db27bcbb3f369861d13e3b0607ed37048d"]},
88
"jason_v": {:git, "https://github.com/elixir-lsp/jason.git", "f1c10fa9c445cb9f300266122ef18671054b2330", [ref: "f1c10fa9c445cb9f300266122ef18671054b2330"]},

0 commit comments

Comments
 (0)