Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering
Running a transformation and rewriting the code can be time-consuming. This section explains how to declare a transformation as quickfix and link them to an analysis.
Transformations of program elements returned as analysis results are declared using the multifile predicate transformation_api:transformation/5. Its arguments are:
This predicate is called by JTransformer with the mode (+, +, -, -, -), i.e. Group and RoleTerm are bound.
The following listing shows the transformation defined for the “Singleton Constructor not private” analysis from our Tutorial project. You find it in JTransformer via the menues: New → Example → JTransformer Example Projects → JTransformer Tutorial - Prolog Files.
:- multifile(transformation_api:transformation/5). % Don't forget the declaration! transformation_api:transformation( _, % Individual result (No group) sysout_call(CallId), % RoleTerm replaceSysoutWithLogging(CallId), % CTHead 'Replace by call to logging method', % Description [preview]). % Option: Show Preview
The declared transformations for a particular analysis result are shown in the Java editor. The screenshot below shows the transformations for a result of the “System.out.println” detector. The first two offered transformations result from the transformation definition shown above.
This suggestion is always generated, independent of the options set in the transformation declaration.
This suggestion is generated if the 'preview' or the 'global' option is set in the transformation declaration (for analyses that apply globally, a preview is always generated).
The last four transformations are always offered for each result. For further information see Viewing Results.