Skip to content

Commit

Permalink
BE:Fix some eqwalizer warnings in the erlang service
Browse files Browse the repository at this point in the history
Summary: As title

Reviewed By: jcpetruzza

Differential Revision: D62124103

fbshipit-source-id: 63c2907b3d3b24cdd1effb86ef14b41af30f1e90
  • Loading branch information
alanz authored and facebook-github-bot committed Sep 3, 2024
1 parent 03ecec5 commit b2ff100
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
35 changes: 22 additions & 13 deletions erlang_service/src/elp_epp.erl
Original file line number Diff line number Diff line change
Expand Up @@ -110,32 +110,37 @@
%% parse_file(FileName, IncludePath, PreDefMacros)
%% macro_defs(Epp)

-spec open(erlang_service_server:id(), FileName, IncludePath) ->
{'ok', Epp} | {'error', ErrorDescriptor}
-spec open(Id, FileName, IncludePath) ->
{'ok', Epp} | {'ok', Epp, Extra} | {'error', ErrorDescriptor}
when
Id :: erlang_service_server:id(),
FileName :: file:name(),
IncludePath :: [DirectoryName :: file:name()],
Epp :: epp_handle(),
Extra :: [{'encoding', source_encoding() | 'none'}],
ErrorDescriptor :: term().

open(Id, Name, Path) ->
open(Id, Name, Path, []).

-spec open(erlang_service_server:id(), FileName, IncludePath, PredefMacros) ->
{'ok', Epp} | {'error', ErrorDescriptor}
-spec open(Id, FileName, IncludePath, PredefMacros) ->
{'ok', Epp} | {'ok', Epp, Extra} | {'error', ErrorDescriptor}
when
Id :: erlang_service_server:id(),
FileName :: file:name(),
IncludePath :: [DirectoryName :: file:name()],
PredefMacros :: macros(),
Epp :: epp_handle(),
Extra :: [{'encoding', source_encoding() | 'none'}],
ErrorDescriptor :: term().

open(Id, Name, Path, Pdm) ->
open(Id, [{name, Name}, {includes, Path}, {macros, Pdm}]).

-spec open(erlang_service_server:id(), Options) ->
-spec open(Id, Options) ->
{'ok', Epp} | {'ok', Epp, Extra} | {'error', ErrorDescriptor}
when
Id :: erlang_service_server:id(),
Options :: [
{'default_encoding', DefEncoding :: source_encoding()}
| {'includes', IncludePath :: [DirectoryName :: file:name()]}
Expand Down Expand Up @@ -290,9 +295,10 @@ format_error(string_concat) ->
format_error(E) ->
file:format_error(E).

-spec scan_file(erlang_service_server:id(), FileName, Options) ->
-spec scan_file(Id, FileName, Options) ->
{'ok', [Form], Extra} | {error, OpenError}
when
Id :: erlang_service_server:id(),
FileName :: file:name(),
Options :: [
{'includes', IncludePath :: [DirectoryName :: file:name()]}
Expand All @@ -304,7 +310,7 @@ when
Loc :: elp_scan:location(),
ErrorInfo :: elp_scan:error_info(),
Extra :: [{'encoding', source_encoding() | 'none'}],
OpenError :: file:posix() | badarg | system_limit.
OpenError :: term().

scan_file(Id, Ifile, Options) ->
case open(Id, [{name, Ifile}, extra | Options]) of
Expand All @@ -326,23 +332,26 @@ scan_file(Epp) ->
[{eof, {Offset, Offset}}]
end.

-spec parse_file(erlang_service_server:id(), FileName, IncludePath, PredefMacros) ->
{'ok', [Form]} | {error, OpenError}
-spec parse_file(Id, FileName, IncludePath, PredefMacros) ->
{'ok', [Form]} | {'ok', [Form], Extra} | {error, OpenError}
when
Id :: erlang_service_server:id(),
FileName :: file:name(),
IncludePath :: [DirectoryName :: file:name()],
Form :: elp_parse:abstract_form() | {'error', ErrorInfo} | {'eof', Location},
PredefMacros :: macros(),
Form :: elp_parse:abstract_form() | {'error', ErrorInfo} | {'eof', Location},
Extra :: [{'encoding', source_encoding() | 'none'}],
Location :: elp_scan:location(),
ErrorInfo :: elp_scan:error_info() | elp_parse:error_info(),
OpenError :: file:posix() | badarg | system_limit.
OpenError :: term().

parse_file(Id, Ifile, Path, Predefs) ->
parse_file(Id, Ifile, [{includes, Path}, {macros, Predefs}]).

-spec parse_file(erlang_service_server:id(), FileName, Options) ->
-spec parse_file(Id, FileName, Options) ->
{'ok', [Form]} | {'ok', [Form], Extra} | {error, OpenError}
when
Id :: erlang_service_server:id(),
FileName :: file:name(),
Options :: [
{'includes', IncludePath :: [DirectoryName :: file:name()]}
Expand All @@ -358,7 +367,7 @@ when
Location :: elp_scan:location(),
ErrorInfo :: elp_scan:error_info() | elp_parse:error_info(),
Extra :: [{'encoding', source_encoding() | 'none'}],
OpenError :: file:posix() | badarg | system_limit.
OpenError :: term().

parse_file(Id, Ifile, Options) ->
case open(Id, [{name, Ifile} | Options]) of
Expand Down
4 changes: 2 additions & 2 deletions erlang_service/src/erlang_service_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ start_link() ->

-define(RECURSIVE_CALLBACK_TIMEOUT, infinity).

-spec path_open(id(), string(), normal|lib)
-spec path_open(id(), string(), normal | lib | doc)
-> {value, [string()]} | failed.
path_open(ReqId, Name, IncludeType) ->
case gen_server:call(?SERVER, {request, ReqId,
Expand Down Expand Up @@ -98,7 +98,7 @@ init(noargs) ->
State = #{io => Port, requests => [], own_requests => []},
{ok, State}.

-spec handle_call({path_open, string(), string(), normal|lib|doc}, any(), state())
-spec handle_call({request, id(), any()}, any(), state())
-> {noreply, state()} | {stop|reply, any(), state()}.
handle_call({request, ReqId, Data}, From,
#{io := IO, requests := Requests, own_requests := OwnRequests} = State) ->
Expand Down

0 comments on commit b2ff100

Please sign in to comment.