Skip to content

Commit

Permalink
removed has_eep48_edoc/0 (assume OTP>=24)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkoMin committed Sep 16, 2024
1 parent d5742bb commit 865c8b4
Showing 1 changed file with 25 additions and 77 deletions.
102 changes: 25 additions & 77 deletions apps/els_lsp/test/els_completion_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1812,23 +1812,10 @@ resolve_application_remote_otp(Config) ->
?assertEqual(Expected, Result).

call_markdown(F, Doc) ->
call_markdown(<<"completion_resolve">>, F, Doc).
call_markdown(M, F, Doc) ->
case has_eep48_edoc() of
true ->
<<"```erlang\n", F/binary,
"() -> ok.\n"
"```\n\n"
"---\n\n", Doc/binary, "\n">>;
false ->
<<"## ", M/binary, ":", F/binary,
"/0\n\n"
"---\n\n"
"```erlang\n"
"-spec ", F/binary,
"() -> 'ok'.\n"
"```\n\n", Doc/binary, "\n\n">>
end.
<<"```erlang\n", F/binary,
"() -> ok.\n"
"```\n\n"
"---\n\n", Doc/binary, "\n">>.

-spec resolve_type_application_local(config()) -> ok.
resolve_type_application_local(Config) ->
Expand All @@ -1843,19 +1830,11 @@ resolve_type_application_local(Config) ->
),
#{result := Result} = els_client:completionitem_resolve(Selected),
Value =
case has_eep48_edoc() of
true ->
<<
"```erlang\n-type mytype() :: "
"completion_resolve_type:myopaque().\n```"
"\n\n---\n\nThis is my type\n"
>>;
false ->
<<
"```erlang\n-type mytype() :: "
"completion_resolve_type:myopaque().\n```"
>>
end,
<<
"```erlang\n-type mytype() :: "
"completion_resolve_type:myopaque().\n```"
"\n\n---\n\nThis is my type\n"
>>,
Expected = Selected#{
documentation =>
#{
Expand All @@ -1878,18 +1857,10 @@ resolve_opaque_application_local(Config) ->
),
#{result := Result} = els_client:completionitem_resolve(Selected),
Value =
case has_eep48_edoc() of
true ->
<<
"```erlang\n-opaque myopaque() \n```\n\n---\n\n"
"This is my opaque\n"
>>;
false ->
<<
"```erlang\n"
"-opaque myopaque() :: term().\n```"
>>
end,
<<
"```erlang\n-opaque myopaque() \n```\n\n---\n\n"
"This is my opaque\n"
>>,
Expected = Selected#{
documentation =>
#{
Expand All @@ -1913,20 +1884,10 @@ resolve_opaque_application_remote_self(Config) ->
#{result := Result} = els_client:completionitem_resolve(Selected),

Value =
case has_eep48_edoc() of
true ->
<<
"```erlang\n-opaque myopaque() \n```\n\n---\n\n"
"This is my opaque\n"
>>;
false ->
<<
"```erlang\n"
"-opaque myopaque() :: term().\n"
"```"
>>
end,

<<
"```erlang\n-opaque myopaque() \n```\n\n---\n\n"
"This is my opaque\n"
>>,
Expected = Selected#{
documentation =>
#{
Expand All @@ -1949,15 +1910,10 @@ resolve_type_application_remote_external(Config) ->
),
#{result := Result} = els_client:completionitem_resolve(Selected),
Value =
case has_eep48_edoc() of
true ->
<<
"```erlang\n-type mytype(T) :: [T].\n```\n\n---\n\n"
"Hello\n"
>>;
false ->
<<"```erlang\n-type mytype(T) :: [T].\n```">>
end,
<<
"```erlang\n-type mytype(T) :: [T].\n```\n\n---\n\n"
"Hello\n"
>>,
Expected = Selected#{
documentation =>
#{
Expand All @@ -1980,15 +1936,10 @@ resolve_opaque_application_remote_external(Config) ->
),
#{result := Result} = els_client:completionitem_resolve(Selected),
Value =
case has_eep48_edoc() of
true ->
<<
"```erlang\n-opaque myopaque(T) \n```\n\n---\n\n"
"Is there anybody in there\n"
>>;
false ->
<<"```erlang\n-opaque myopaque(T) :: [T].\n```">>
end,
<<
"```erlang\n-opaque myopaque(T) \n```\n\n---\n\n"
"Is there anybody in there\n"
>>,
Expected = Selected#{
documentation =>
#{
Expand Down Expand Up @@ -2057,9 +2008,6 @@ completion_request_fails(Config) ->
select_completionitems(CompletionItems, Kind, Label) ->
[CI || #{kind := K, label := L} = CI <- CompletionItems, L =:= Label, K =:= Kind].

has_eep48_edoc() ->
list_to_integer(erlang:system_info(otp_release)) >= 24.

has_eep48(Module) ->
case catch code:get_doc(Module) of
{ok, {docs_v1, _, erlang, _, _, _, Docs}} ->
Expand Down

0 comments on commit 865c8b4

Please sign in to comment.