3 A Cross-Reference Tool
3.1 A Cross-Reference Tool (exref)
The
exreftool has some limitations and is no longer supported. Please consider using the new cross reference tool xref.
exrefis an incremental cross reference tool which builds a cross reference graph for selected modules. Information such as module dependencies and usage graphs can be derived from the cross reference graph produced byexref.A function vertex is represented as:
.{{Mod, Fun, Arity}, {Type, File, Line}}In this representation, the
Typeargument equals:local | exported | {exported, compiler} | {local, compiler} | {Void(), record}A call edge is represented as:
{EdgeId, {Mod1, Fun1, Arity1}, {Modd2, Fun2, Arity2}, Line}The following functions are available for configuring and using the cross reference tool:
start() -> {ok, Pid} | {error, {already_started, Pid}}starts theexrefserver. The server must be started before any other functions in moduleexrefcan be used.
stop() -> stoppedstops theexrefserver.
module(Module) -> trueloads the specified module, or modules, into the cross reference graph.
module(Module, Options) -> trueloads the moduleModuleinto the cross reference graph.Modulemay also be a list of modules. Type can be any of the following:
module = atom() | [atom()]
Options = [Option], where
Option = search | verbose | auto | warnings | recursive, where
searchsearches for source file in code path and replaces the pathX/ebinwithX/src.
verbosecreates an output of module names during loading.
autoincludes all referenced modules in the graph, with the exception of modules listed in the excludes(Modules) function shown below.
warningsemits warnings about the application and the spawning of variables. The reason for this is thatapplycalls lead to an incomplete graph for variable modules or functions. Theapplycall is inserted into the graph instead of the actual call. The same applies tospawn.
recursiverecursively includes all files in a directory.
directory(Directory)loads all modules in a directory into the cross reference graph.
directory(Directory, Module)loads specific modules from a directory other than the current directory into the cross reference graph.
directory(Directory, Module, Options)loads specific modules from a directory other than the current directory into the cross reference graph.
delete_module(Module)deletes a module from the cross reference path.Modulecan be a list of modules.
excludes(Modules)excludes a module, or list of modules, from the cross reference path.
includes(Dirs)specifies where to search for Erlangincludefiles.
defs(Defs)adds definitions to be used when processing source code. This function appends the definitions specified withDefsto the definition list used byerl_pp.
analyse(Type [,Arg]) -> Resultanalyses the cross reference graph and returns an Erlang term of a format which depends on theTypespecified. The result from this analysis can be pretty printed with thepretty/1function listed below. Some ofTypecan have optional arguments. Refer to the Reference Manual, the sectiontools, moduleexreffor details.
pretty(AnalyseResult) -> okprints a verbose textual representation of the analysis result produced by theanalyse/2function shown above. The result produced from a user defined analysis cannot be used as input to this function.