Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[LSP] Fix initialize on OTP 23.0/23.1 #1449

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion apps/els_core/src/els_uri.erl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
%%==============================================================================
-module(els_uri).

-if(?OTP_RELEASE =:= 23).
-compile([{nowarn_deprecated_function, [{http_uri, decode, 1}]}]).
-endif.

%%==============================================================================
%% Exports
%%==============================================================================
Expand Down Expand Up @@ -84,10 +88,25 @@ uri(Path) ->
uri_join(List) ->
lists:join(<<"/">>, List).

-if(?OTP_RELEASE >= 23).
-if(?OTP_RELEASE > 23).
-spec percent_decode(binary()) -> binary().
percent_decode(Str) ->
uri_string:percent_decode(Str).
-elif(?OTP_RELEASE =:= 23).
-spec percent_decode(binary()) -> binary().
percent_decode(Str) ->
%% The `percent_decode/1' function is unavailable until OTP 23.2
case erlang:function_exported(uri_string, percent_decode, 1) of
'true' ->
percent_decode2(Str);
'false' ->
http_uri:decode(Str)
end.

-dialyzer([{nowarn_function, percent_decode2/1}]).
-spec percent_decode2(binary()) -> binary().
percent_decode2(Str) ->
uri_string:percent_decode(Str).
-else.
-spec percent_decode(binary()) -> binary().
percent_decode(Str) ->
Expand Down
2 changes: 2 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@
%% Set xref ignores for functions introduced in OTP 23 & function of wrangler
{xref_ignores, [
{code, get_doc, 1},
{http_uri, decode, 1},
{shell_docs, render, 4},
{uri_string, percent_decode, 1},
wrangler_handler,
api_wrangler,
wls_code_lens,
Expand Down
Loading