Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools

Integrating a Prolog Analysis

There are three multifile predicates that are relevant for the integration of an analysis.

Defining Analyses

prolog_analysis_api:analysis_definition(Name, Severity, Category, Description)
  • Name: The analysis name. It can be an arbitrary Prolog atom.
  • Severity: This defines the kind of the markers created for results. Possible values are info (), warning () and error ().
  • Category: The name of the category to which this analysis belongs.
  • Description: A short description of this analysis which is shown in the Prolog Analyses view.

Defining Categories

prolog_analysis_api:analysis_category(Name, Description)
  • Name: The category name. It can be an arbitrary Prolog atom.
  • Description: A short description of this category which is shown in the Prolog Analyses view.

Defining Analysis Results

prolog_analysis_api:analysis_result(Name, File, Location, Description)

Each result of this predicate represents one analysis result. An analysis result consists of a File, a Location in this file and a Description. This predicate is called in mode (+, -, -, -).

  • Name: The analysis name to which this result belongs.
  • File: The file of the result.
  • Location: The location of the result inside the file. Location is either
    • a line number or
    • the term Start-End where Start and End are character offsets.
  • Description: The individual description of this result which is shown in the Prolog Analyses view.


The PDT Tutorial project contains a small example which is listed below.

The example finds all clauses of the predicate outline_demo:likes/2.

:- multifile(prolog_analysis_api:analysis_definition/4).
:- multifile(prolog_analysis_api:analysis_category/2).
:- multifile(prolog_analysis_api:analysis_result/4).

prolog_analysis_api:analysis_definition('Example Analysis', info, 'Example Category', 'This is an example analysis').

prolog_analysis_api:analysis_category('Example Category', 'This is an example category').

prolog_analysis_api:analysis_result('Example Analysis', File, Line, Description) :-
	nth_clause(outline_demo:likes(_, _), N, Ref),
	clause_property(Ref, file(File)),
	clause_property(Ref, line_count(Line)),
	format(atom(Description), 'This is the ~w. clause of likes/2', [N]).

The results listed in the Prolog Analyses view are shown below.

research/pdt/docs/analysis_integrate.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2024