⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xref.erl

📁 OTP是开放电信平台的简称
💻 ERL
📖 第 1 页 / 共 2 页
字号:
%%          {ok, State, Timeout} |%%          ignore               |%%          {stop, Reason}%%----------------------------------------------------------------------init(Args) ->    case xref_base:new(Args) of	{ok, S} ->	    {ok, S};	{error, _Module, Reason} ->	    {stop, Reason}    end.%%----------------------------------------------------------------------%% Func: handle_call/3%% Returns: {reply, Reply, State}          |%%          {reply, Reply, State, Timeout} |%%          {noreply, State}               |%%          {noreply, State, Timeout}      |%%          {stop, Reason, Reply, State}   | (terminate/2 is called)%%          {stop, Reason, State}            (terminate/2 is called)%%----------------------------------------------------------------------handle_call(stop, _From, State) ->    {stop, normal, stopped, State};handle_call({add_release, Dir}, _From, State) ->    case xref_base:add_release(State, Dir) of	{ok, ReleaseName, NewState} ->	    {reply, {ok, ReleaseName}, NewState};	Error ->	    {reply, Error, State}    end;handle_call({add_release, Dir, Options}, _From, State) ->    case xref_base:add_release(State, Dir, Options) of	{ok, ReleaseName, NewState} ->	    {reply, {ok, ReleaseName}, NewState};	Error ->	    {reply, Error, State}    end;handle_call({add_application, Dir}, _From, State) ->    case xref_base:add_application(State, Dir) of	{ok, AppName, NewState} ->	    {reply, {ok, AppName}, NewState};	Error ->	    {reply, Error, State}    end;handle_call({add_application, Dir, Options}, _From, State) ->    case xref_base:add_application(State, Dir, Options) of	{ok, AppName, NewState} ->	    {reply, {ok, AppName}, NewState};	Error ->	    {reply, Error, State}    end;handle_call({add_module, File}, _From, State) ->    case xref_base:add_module(State, File) of	{ok, Module, NewState} ->	    {reply, {ok, Module}, NewState};	Error ->	    {reply, Error,  State}    end;handle_call({add_module, File, Options}, _From, State) ->    case xref_base:add_module(State, File, Options) of	{ok, Module, NewState} ->	    {reply, {ok, Module}, NewState};	Error ->	    {reply, Error,  State}    end;handle_call({replace_application, Appl, Dir}, _From, State) ->    case xref_base:replace_application(State, Appl, Dir) of	{ok, AppName, NewState} ->	    {reply, {ok, AppName}, NewState};	Error ->	    {reply, Error, State}    end;handle_call({replace_application, Appl, Dir, Opts}, _From, State) ->    case xref_base:replace_application(State, Appl, Dir, Opts) of	{ok, AppName, NewState} ->	    {reply, {ok, AppName}, NewState};	Error ->	    {reply, Error, State}    end;handle_call({remove_module, Mod}, _From, State) ->    case xref_base:remove_module(State, Mod) of	{ok, NewState} ->	    {reply, ok, NewState};	Error ->	    {reply, Error, State}    end;handle_call({remove_application, Appl}, _From, State) ->    case xref_base:remove_application(State, Appl) of	{ok, NewState} ->	    {reply, ok, NewState};	Error ->	    {reply, Error, State}    end;handle_call({remove_release, Rel}, _From, State) ->    case xref_base:remove_release(State, Rel) of	{ok, NewState} ->	    {reply, ok, NewState};	Error ->	    {reply, Error, State}    end;handle_call({add_directory, Dir}, _From, State) ->    case xref_base:add_directory(State, Dir) of	{ok, Modules, NewState} ->	    {reply, {ok, Modules}, NewState};	Error ->	    {reply, Error, State}    end;handle_call({add_directory, Dir, Options}, _From, State) ->    case xref_base:add_directory(State, Dir, Options) of	{ok, Modules, NewState} ->	    {reply, {ok, Modules}, NewState};	Error ->	    {reply, Error, State}    end;handle_call(get_library_path, _From, State) ->    Path = xref_base:get_library_path(State),    {reply, Path, State};handle_call({set_library_path, Path}, _From, State) ->    case xref_base:set_library_path(State, Path) of	{ok, NewState} ->	    {reply, ok, NewState};	Error ->	    {reply, Error, State}    end;handle_call({set_library_path, Path, Options}, _From, State) ->    case xref_base:set_library_path(State, Path, Options) of	{ok, NewState} ->	    {reply, ok, NewState};	Error ->	    {reply, Error, State}    end;handle_call({replace_module, Module, File}, _From, State) ->    case xref_base:replace_module(State, Module, File) of	{ok, Module, NewState} ->	    {reply, {ok, Module}, NewState};	Error ->	    {reply, Error, State}    end;handle_call({replace_module, Module, File, Options}, _From, State) ->    case xref_base:replace_module(State, Module, File, Options) of	{ok, Module, NewState} ->	    {reply, {ok, Module}, NewState};	Error ->	    {reply, Error, State}    end;handle_call(info, _From, State) ->    {reply, xref_base:info(State), State};handle_call({info, What}, _From, State) ->    {reply, xref_base:info(State, What), State};handle_call({info, What, Qual}, _From, State) ->    {reply, xref_base:info(State, What, Qual), State};handle_call(update, _From, State) ->    case xref_base:update(State) of	{ok, NewState, Modules} ->	    {reply, {ok, Modules}, NewState};	Error ->	    {reply, Error, State}    end;handle_call({update, Options}, _From, State) ->    case xref_base:update(State, Options) of	{ok, NewState, Modules} ->	    {reply, {ok, Modules}, NewState};	Error ->	    {reply, Error, State}    end;handle_call(forget, _From, State) ->    {ok, NewState} = xref_base:forget(State),    {reply, ok, NewState};handle_call({forget, Variable}, _From, State) ->    case xref_base:forget(State, Variable) of	{ok, NewState} ->	    {reply, ok, NewState};	Error ->	    {reply, Error, State}    end;handle_call(variables, _From, State) ->    %% The reason the ok-Error pattern is broken for variables, q and    %% analyze is that the state may have been updated even if an    %% error occurs.    {Reply, NewState} = xref_base:variables(State),    {reply, Reply, NewState};handle_call({variables, Options}, _From, State) ->    {Reply, NewState} = xref_base:variables(State, Options),    {reply, Reply, NewState};handle_call({analyze, What}, _From, State) ->    {Reply, NewState} = xref_base:analyze(State, What),    {reply, unsetify(Reply), NewState};handle_call({analyze, What, Options}, _From, State) ->    {Reply, NewState} = xref_base:analyze(State, What, Options),    {reply, unsetify(Reply), NewState};handle_call({qry, Q}, _From, State) ->    {Reply, NewState} = xref_base:q(State, Q),    {reply, unsetify(Reply), NewState};handle_call({qry, Q, Options}, _From, State) ->    {Reply, NewState} = xref_base:q(State, Q, Options),    {reply, unsetify(Reply), NewState};handle_call(get_default, _From, State) ->    Reply = xref_base:get_default(State),    {reply, Reply, State};handle_call({get_default, Option}, _From, State) ->    Reply = xref_base:get_default(State, Option),    {reply, Reply, State};handle_call({set_default, OptionValues}, _From, State) ->    case xref_base:set_default(State, OptionValues) of	{ok, NewState} ->	    {reply, ok, NewState};	Error ->	    {reply, Error, State}    end;handle_call({set_default, Option, Value}, _From, State) ->    case xref_base:set_default(State, Option, Value) of	{ok, OldValue, NewState} ->	    {reply, {ok, OldValue}, NewState};	Error ->	    {reply, Error, State}    end.%%----------------------------------------------------------------------%% Func: handle_cast/2 %% Returns: {noreply, State} | %% {noreply, State, Timeout} | %% {stop, Reason, State} (terminate/2 is called)%%----------------------------------------------------------------------handle_cast(_Msg, State) -> {noreply, State}.%%----------------------------------------------------------------------%% Func: handle_info/2%% Returns: {noreply, State}          |%%          {noreply, State, Timeout} |%%          {stop, Reason, State}            (terminate/2 is called)%%----------------------------------------------------------------------handle_info(_Info, State) ->    {noreply, State}.%%----------------------------------------------------------------------%% Func: terminate/2%% Purpose: Shutdown the server%% Returns: any (ignored by gen_server)%%----------------------------------------------------------------------terminate(_Reason, _State) ->    ok.%%----------------------------------------------------------------------%% Func: code_change/3%% Purpose: Convert process state when code is changed%% Returns: {ok, NewState}%%----------------------------------------------------------------------code_change(_OldVsn, State, _Extra) ->    {ok, State}.%%%----------------------------------------------------------------------%%% Internal functions%%%----------------------------------------------------------------------do_functions_analysis(FFun) ->    {ok, State} = xref_base:new(),    {ok, State1} = xref_base:set_library_path(State, code_path),    {ok, State2} = xref_base:set_default(State1, 					 [{verbose,false},{warnings,false}]),    State3 = case FFun(State2) of		 {ok, _, S} -> S;		 Error2 -> throw(Error2)	     end,    {Undef, State4} = do_analysis(State3, undefined_function_calls),    {Unused, State5} = do_analysis(State4, locals_not_used),    {Deprecated, _} = do_analysis(State5, deprecated_function_calls),    [{deprecated,to_external(Deprecated)},     {undefined,to_external(Undef)},      {unused,to_external(Unused)}].do_modules_analysis(FFun) ->    {ok, State} = xref_base:new({xref_mode, modules}),    {ok, State1} = xref_base:set_library_path(State, code_path),    {ok, State2} = xref_base:set_default(State1, 					 [{verbose,false},{warnings,false}]),    State3 = case FFun(State2) of		 {ok, _, S} -> S;		 Error2 -> throw(Error2)	     end,    {Undef, State4} = do_analysis(State3, undefined_functions),    {Deprecated, _} = do_analysis(State4, deprecated_functions),    [{deprecated,to_external(Deprecated)},     {undefined,to_external(Undef)}].do_analysis(State, Analysis) ->    case xref_base:analyze(State, Analysis) of	{{ok, Reply}, NewState} ->	    {Reply, NewState};	{Error, _} ->	    throw(Error)    end.unsetify(Reply={ok, X}) ->    case is_sofs_set(X) of	true -> {ok, to_external(X)};	false -> Reply    end;unsetify(Reply) ->    Reply.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -