Did you know ... | Search Documentation: |
Pack diagnostics -- prolog/diagnostics.pl |
This module provides a simple and extensible diagnostics interface
based on prolog_colourise_stream/3 from library(prolog_colour)
.
Diagnostics can be ran on multiple source files from the command line like so:
$ swipl -q \ --on-error=status \ -g "use_module(library(diagnostics))" \ -t halt \ -- path/to/source/file.pl [path/to/other/file.pl ...]
There is also support for diagnosing Prolog source code originating
from stdin
, by providing "-" as the first command line argument,
followed by a path to a Prolog source file that will be regarded as
the "current file" during the analysis for resolving relative paths in
source files:
$ swipl -q \ --on-error=status \ -g "use_module(library(diagnostics))" \ -t halt \ -- - path/to/source/file.pl
Detected issues are reported via print_message/2, and can be intercepted via message_hook/3.
Item is a term describing a source fragment to be diagnosed, it follows the same format as the first argument of ColourItem in prolog_colourise_stream/3.
If this predicate succeeds, Kind must be unified with a message kind term that will be used as the first argument of print_message/2, while Message must be unified with a pair Format-Args where Format is a format string that will be formatted using Args. If this predicate fails, the default diagnosis logic will be used to diagnose Item.