SDA SE Wiki

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

User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
research:pdt:docs:analysis_integrate [2015/01/20 14:43]
andreas.becker
research:pdt:docs:analysis_integrate [2018/05/09 01:59] (current)
Line 1: Line 1:
 +====== Integrating a Prolog Analysis ======
  
 +There are three multifile predicates that are relevant for the integration of an analysis.
 +
 +===== Defining Analyses =====
 +
 +<​Code>​
 +prolog_analysis_api:​analysis_definition(Name,​ Severity, Category, Description)
 +</​Code>​
 +
 +  * **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// ({{:​research:​pdt:​docs:​information.gif|}}),​ //warning// ({{:​research:​pdt:​docs:​warning.gif|}}) and //error// ({{:​research:​pdt:​docs:​error.gif|}}).
 +  * **Category**:​ The name of the category to which this analysis belongs.
 +  * **Description**:​ A short description of this analysis which is shown in the [[analysis_view|Prolog Analyses]] view.
 +
 +===== Defining Categories =====
 +
 +<​Code>​
 +prolog_analysis_api:​analysis_category(Name,​ Description)
 +</​Code>​
 +
 +  * **Name**: The category name. It can be an arbitrary Prolog atom.
 +  * **Description**:​ A short description of this category which is shown in the [[analysis_view|Prolog Analyses]] view.
 +
 +===== Defining Analysis Results =====
 +
 +<​Code>​
 +prolog_analysis_api:​analysis_result(Name,​ File, Location, Description)
 +</​Code>​
 +
 +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 [[analysis_view|Prolog Analyses]] view.
 +
 +
 +===== Example =====
 +
 +The [[getting_started#​create_an_example_prolog_project|PDT Tutorial project]] contains a small example which is listed below.
 +
 +The example finds all clauses of the predicate ''​outline_demo:​likes/​2''​.
 +
 +<​Code>​
 +:- 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]).
 +
 +</​Code>​
 +
 +The results listed in the Prolog Analyses view are shown below.
 +
 +{{:​research:​pdt:​docs:​analyses_result_table.png|}}
research/pdt/docs/analysis_integrate.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2019