
prolog_xref.pl -- Prolog cross-referencer data collectionThis library collects information on defined and used objects in Prolog source files. Typically these are predicates, but we expect the library to deal with other types of objects in the future. The library is a building block for tools doing dependency tracking in applications. Dependency tracking is useful to reveal the structure of an unknown program or detect missing components at compile time, but also for program transformation or minimising a program saved state by only saving the reachable objects.
The library is exploited by two graphical tools in the SWI-Prolog environment: the XPCE front-end started by gxref/0, and library(prolog_colour), which exploits this library for its syntax highlighting.
For all predicates described below, Source is the source that is processed. This is normally a filename in any notation acceptable to the file loading predicates (see load_files/2). Input handling is done by the library(prolog_source), which may be hooked to process any source that can be translated into a Prolog stream holding Prolog source text. Callable is a callable term (see callable/1). Callables do not carry a module qualifier unless the referred predicate is not in the module defined by Source.
prolog:called_by(+Goal, +Module, +Context, -Called) is semidet[multifile]
prolog:called_by(+Goal, -ListOfCalled)[multifile]
prolog:meta_goal(+Goal, -Pattern)[multifile]
prolog:hook(Goal)[multifile]
xref_source(+Source) is det
xref_source(+Source, +Options) is dettrue (default false), emit warning messages.all, non_iso or non_built_in (default).store, comments are stored into the
database as if the file was compiled. If collect, comments are
entered to the xref database and made available through
xref_mode/2 and xref_comment/4. If ignore, comments are simply
ignored. Default is to collect comments.true).
xref_clean(+Source) is det
xref_current_source(?Source)
xref_done(+Source, -Time) is det
xref_called(?Source, ?Called, ?By) is nondet
xref_called(?Source, ?Called, ?By, ?Cond) is nondet
xref_called(?Source, ?Called, ?By, ?Cond, ?Line) is nondetCalled-By pairs. The xref_called/5 version may return
duplicate Called-By if Called is called from multiple clauses in
By, but at most one call per clause.
xref_defined(?Source, +Goal, ?How) is nondetinclude(File)) directive.
dynamic(Location)thread_local(Location)multifile(Location)public(Location)local(Location)foreign(Location)constraint(Location)imported(From)
xref_definition_line(+How, -Line)
xref_exported(?Source, ?Head) is nondet
xref_module(?Source, ?Module) is nondet
xref_uses_file(?Source, ?Spec, ?Path) is nondet
xref_op(?Source, Op) is nondet
xref_prolog_flag(?Source, ?Flag, ?Value, ?Line) is nondet
xref_comment(?Source, ?Title, ?Comment) is nondet
xref_comment(?Source, ?Head, ?Summary, ?Comment) is nondet
xref_mode(?Source, ?Mode, ?Det) is nondet
xref_option(?Source, ?Option) is nondet
xref_meta(+Source, +Head, -Called) is semidet
xref_meta(+Head, -Called) is semidet
xref_meta_src(+Head, -Called, +Src) is semidet
xref_hook(?Callable)
xref_public_list(+Spec, +Source, +Options) is semidet[] for
.qlf files.[] for .qlf files.The information collected by this predicate is cached. The cached data is considered valid as long as the modification time of the file does not change.
xref_public_list(+File, -Path, -Export, +Src) is semidet
xref_public_list(+File, -Path, -Module, -Export, -Meta, +Src) is semidet
xref_public_list(+File, -Path, -Module, -Export, -Public, -Meta, +Src) is semidetThese predicates fail if File is not a module-file.
xref_source_file(+Spec, -File, +Src) is semidet
xref_source_file(+Spec, -File, +Src, +Options) is semidetThe following predicates are exported, but not or incorrectly documented.
xref_used_class(Arg1, Arg2)
xref_defined_class(Arg1, Arg2, Arg3)
xref_built_in(Arg1)