@@ -3734,219 +3734,163 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.SuggestionTest do
3734
3734
test "options as inline list" do
3735
3735
buffer = "Local.func_with_options_as_inline_list("
3736
3736
3737
- assert % { type_spec: "local_t()" , expanded_spec: "@type local_t() :: atom()"} =
3737
+ assert % { type_spec: "atom()" } =
3738
3738
suggestion_by_name ( "local_o" , buffer )
3739
3739
3740
3740
assert % {
3741
- type_spec: "keyword()" ,
3742
- expanded_spec: """
3743
- @type keyword() :: [
3744
- {atom(), any()}
3745
- ]\
3746
- """
3741
+ type_spec: "keyword()"
3747
3742
} = suggestion_by_name ( "builtin_o" , buffer )
3748
3743
end
3749
3744
3750
3745
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"
3754
3748
3755
3749
buffer = "Local.func_with_option_var_defined_in_when("
3756
3750
suggestion = suggestion_by_name ( "local_o" , buffer )
3757
3751
3758
3752
assert suggestion . type_spec == type_spec
3759
3753
assert suggestion . origin == origin
3760
- assert suggestion . expanded_spec == spec
3754
+
3755
+ origin = "ElixirSenseExample.ModuleWithTypespecs.Local.func_with_options_var_defined_in_when"
3761
3756
3762
3757
buffer = "Local.func_with_options_var_defined_in_when("
3763
3758
suggestion = suggestion_by_name ( "local_o" , buffer )
3764
3759
3765
3760
assert suggestion . type_spec == type_spec
3766
3761
assert suggestion . origin == origin
3767
- assert suggestion . expanded_spec == spec
3768
3762
end
3769
3763
3770
3764
test "opaque type internal structure is not revealed" do
3771
3765
buffer = "Local.func_with_options("
3772
3766
suggestion = suggestion_by_name ( "opaque_o" , buffer )
3773
3767
3774
3768
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"
3778
3770
end
3779
3771
3780
3772
test "private type" do
3781
3773
buffer = "Local.func_with_options("
3782
3774
suggestion = suggestion_by_name ( "private_o" , buffer )
3783
3775
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"
3788
3778
end
3789
3779
3790
3780
test "local type" do
3791
3781
buffer = "Local.func_with_options("
3792
3782
suggestion = suggestion_by_name ( "local_o" , buffer )
3793
3783
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"
3798
3786
end
3799
3787
3800
3788
test "local type with params" do
3801
3789
buffer = "Local.func_with_options("
3802
3790
suggestion = suggestion_by_name ( "local_with_params_o" , buffer )
3803
3791
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"
3807
3794
end
3808
3795
3809
3796
test "basic type" do
3810
3797
buffer = "Local.func_with_options("
3811
3798
suggestion = suggestion_by_name ( "basic_o" , buffer )
3812
3799
3813
3800
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"
3817
3802
end
3818
3803
3819
3804
test "basic type with params" do
3820
3805
buffer = "Local.func_with_options("
3821
3806
suggestion = suggestion_by_name ( "basic_with_params_o" , buffer )
3822
3807
3823
3808
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"
3827
3810
end
3828
3811
3829
3812
test "built-in type" do
3830
3813
buffer = "Local.func_with_options("
3831
3814
suggestion = suggestion_by_name ( "builtin_o" , buffer )
3832
3815
3833
3816
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"
3843
3818
end
3844
3819
3845
3820
test "built-in type with params" do
3846
3821
buffer = "Local.func_with_options("
3847
3822
suggestion = suggestion_by_name ( "builtin_with_params_o" , buffer )
3848
3823
3849
3824
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"
3853
3826
end
3854
3827
3855
3828
test "union type" do
3856
3829
buffer = "Local.func_with_options("
3857
3830
suggestion = suggestion_by_name ( "union_o" , buffer )
3858
3831
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"
3866
3834
end
3867
3835
3868
3836
test "list type" do
3869
3837
buffer = "Local.func_with_options("
3870
3838
suggestion = suggestion_by_name ( "list_o" , buffer )
3871
3839
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"
3875
3842
end
3876
3843
3877
3844
test "remote type" do
3878
3845
buffer = "Local.func_with_options("
3879
3846
suggestion = suggestion_by_name ( "remote_o" , buffer )
3880
3847
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"
3885
3850
end
3886
3851
3887
3852
test "remote type with args" do
3888
3853
buffer = "Local.func_with_options("
3889
3854
suggestion = suggestion_by_name ( "remote_with_params_o" , buffer )
3890
3855
3891
3856
assert suggestion . type_spec ==
3892
- "ElixirSenseExample.ModuleWithTypespecs.Remote.remote_t( atom(), integer()) "
3857
+ "{ atom(), integer()} "
3893
3858
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"
3897
3860
end
3898
3861
3899
3862
test "remote erlang type with doc" do
3900
3863
buffer = "Local.func_with_erlang_type_options("
3901
3864
suggestion = suggestion_by_name ( "erlang_t" , buffer )
3902
3865
3903
3866
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"
3910
3868
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"
3914
3870
end
3915
3871
3916
3872
test "remote aliased type" do
3917
3873
buffer = "Local.func_with_options("
3918
3874
suggestion = suggestion_by_name ( "remote_aliased_o" , buffer )
3919
3875
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"
3930
3878
end
3931
3879
3932
3880
test "remote aliased inline type" do
3933
3881
buffer = "Local.func_with_options("
3934
3882
suggestion = suggestion_by_name ( "remote_aliased_inline_o" , buffer )
3935
3883
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"
3940
3886
end
3941
3887
3942
3888
test "inline list type" do
3943
3889
buffer = "Local.func_with_options("
3944
3890
suggestion = suggestion_by_name ( "inline_list_o" , buffer )
3945
3891
3946
3892
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"
3950
3894
end
3951
3895
3952
3896
test "non existent type" do
@@ -3956,14 +3900,12 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.SuggestionTest do
3956
3900
assert suggestion . type_spec ==
3957
3901
"ElixirSenseExample.ModuleWithTypespecs.Remote.non_existent()"
3958
3902
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"
3962
3904
end
3963
3905
3964
3906
test "named options" do
3965
3907
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 ()"
3967
3909
end
3968
3910
3969
3911
test "options with only one option" do
@@ -3974,14 +3916,14 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.SuggestionTest do
3974
3916
test "union of options" do
3975
3917
buffer = "Local.func_with_union_of_options("
3976
3918
3977
- assert suggestion_by_name ( "local_o" , buffer ) . type_spec == "local_t ()"
3919
+ assert suggestion_by_name ( "local_o" , buffer ) . type_spec == "atom ()"
3978
3920
assert suggestion_by_name ( "option_1" , buffer ) . type_spec == "atom()"
3979
3921
end
3980
3922
3981
3923
test "union of options inline" do
3982
3924
buffer = "Local.func_with_union_of_options_inline("
3983
3925
3984
- assert suggestion_by_name ( "local_o" , buffer ) . type_spec == "local_t ()"
3926
+ assert suggestion_by_name ( "local_o" , buffer ) . type_spec == "atom ()"
3985
3927
assert suggestion_by_name ( "option_1" , buffer ) . type_spec == "atom()"
3986
3928
end
3987
3929
@@ -3990,9 +3932,7 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.SuggestionTest do
3990
3932
assert suggestion_by_name ( "option_1" , buffer ) . type_spec == "boolean()"
3991
3933
3992
3934
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()"
3996
3936
end
3997
3937
3998
3938
test "atom only options" do
@@ -4030,15 +3970,7 @@ defmodule ElixirLS.LanguageServer.Providers.Completion.SuggestionTest do
4030
3970
test "format type spec" do
4031
3971
buffer = "Local.func_with_options("
4032
3972
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()}"
4042
3974
end
4043
3975
4044
3976
test "params with default args" do
0 commit comments