- Developer's corner
Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering
Follow the installation instructions for LogicAJ and set up the LogicAJ Demo Project.
To activate JTransformer for an existing Java project switch to the Java Perspective, right-click on the Java project in the context menu and select Assign JTranformer Factbase.
A Background job generating the fact representation should start immediately, as indicated by a progress bar in the lower right corner of the window. As usual you can open the Progress View (Window→Show View→Basic→Progress), to get more detailed information. Note that this initial fact generation may take a while on large projects, but it only happens once. From this point on, the fact representation will be updated on every change to the Java source, as long as there are no compilation problems.
By assigning the jtransformer factbase a project with the name <project name>-output is created and your project is marked with a green JT in the upper left corner of the project icon. See screenshot on the right.
Now the project is ready for use with LogicAJ aspects. Import the LogicAJ demo project into your workspace (File→Import). Open an aspect from the directory aspects. The screenshot below shows the integration of the LogicAJ compiler into Eclipse. The LogicAJ editor provides highlighting and an outline for the aspect constructs. Errors in the LogicAJ aspects and the blame assignment of the declare error / warning statements are shown in the standard problems view:
Aspect compilation and weaving are two different steps in LogicAJ. Compilation checks the syntactic correctness of the aspect and the type safety of aspect code that does not depend on logic-meta variables.
The compilation is done automatically on every save of a file or if you press the c button (see toolbar on the right).
To weave/deactivate an aspect toggle the Weave Aspect item in navigator's context menu. This item will add resp. remove the aspect from the /lajbuild file in the project's root folder. It contains project relative paths to the selected aspects:
aspects/HashcodeEqualsAspect.aj aspects/MockAspect.aj aspects/AbstractVisitorAspect.aj aspects/VisitorAspect.aj
Here you may change the order of the aspects. The order is important if you refer to an introduces class member from another introduced element of advice. The introducing aspect must come first in the lajbuild file in this case.
To weave the selected aspects press the button in the LogicAJ toolbar (see screenshot on the right). Make sure that the file currently open in the editor is contained in the project you want to weave. The button only weaves the aspects for the enclosing project.
Weaving results will be shown in the outline. In the outline you can click on the rows below the aspect construct to show the join point shadow in the editor. It is underlined in the source code.
Alternatively you may open the the weaving results view which shows an aggregation of all aspect outlines in on view: LogicAJ→Show Weaving Results
The LogicAJ compiler realizes aspect weaving as a source-to-source transformation. The weaving step generates all (woven) classes into the corresponding output project.
That's why you run your main classes (Html2Wiki in case of the LogicAJDemo project) only from the output project.