Skip to content
Jan Wielemaker edited this page Sep 25, 2025 · 3 revisions

The SWI-Prolog cross-referencing tool

SWI-Prolog cross-referencing tool

The cross-referencing tool examines the currently loaded program to figure out the call sites for predicates. It does so using library(prolog_xref), which is also used by PceEmacs to highlight goals depending on how (and whether) the predicate is resolved.

The cross referencing tool shows two sub windows. The left pane shows all files and predicates found. The right pane is a tabbed sub window that can

  • Show the dependency graph between files. This view can be extended by dragging files or directories onto it as well as using the context menu.
  • Show details on a file: which predicates are undefined or not called, where are predicates used? Which predicates are imported or exported? Clicking a predicate opens the editor on the source.
  • The file header on a File info tab provides a context menu that allows generating a module header for non-module files. This may be used to convert a non-modular project into a set of modules. Using modules reduces the risk for name conflicts, makes private code (that may be modified without implications to other modules) explicit and improves the navigation features of the development tools.

File names in the left pane are marked as problematic or good. Undefined predicates are always considered problematic. The Settings menu can be used to enable/disable warnings for predicates that are not called (dead code) or predicates that are not explicitly imported but can be auto loaded.

Clone this wiki locally