-
-
- Using the Prolog IDE
-
-
-
Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering
Depending on their properties, predicates, quoted atoms and comments are highlighted with a specific colours. These colours can be modified in the preferences.
Highlighting | Indicated Property |
---|---|
Dynamic predicate | |
Built-in predicate | |
Meta predicate | |
Module transparent predicate | |
Normal (having none of the properties mentioned above) predicate | |
Quoted atom | |
Comment |
Occurences of atom and variable names are highlighted in the current clause (that is the clause in which the cursor is currently located). The highlighting is updated instantly, upon typing.
Highlighting in the editor | Description |
---|---|
All occurences of the variable touched by the cursor (that means, the cursor is located just before, just after or within the variable name) are highlighted with a grey background. | |
All occurences of the atom touched by the cursor (that means, the cursor is located just before, just after or within the atom name) are highlighted with a grey background. | |
Singleton variables are highlighted with a red background. | |
Variables that start with “_” but occur multiply in the current clause (that is the clause in which the cursor is currently located) are highlighted with a light ivory background. |
All SWI-Prolog errors and warnings that occur while consulting a file are displayed in the Prolog Editor:
These errors and warnings are also displayed in the Eclipse Package Explorer and Eclipse Problems View:
The file which is opened in the editor can be consulted to the current process by pressing F9.
Whenever you save a file in the editor it is automatically (re)consulted. If you don't want a file to be consulted after saving you can save the file by pressing Ctrl+Alt+S or by selecting the menu item “Save without consult”. 1)
Furthermore you have the possibility to deactivate the reconsult on save in the Preferences. This means, that files will only be consulted manually.
The Outline view displays an outline of all predicates defined in the Prolog file opened in the editor. The Outline supports multi-file awareness, that is, it shows all the clauses of a predicate, also for multifile predicates:
total number of clauses of each predicate (in this and in other files).
Dynamic predicates are emphasized with blue text colour. The icon to the left of the predicate indicator represents the visibility of the predicate: A green icon indicates exported predicates and predicates in non-module files. A yellow icon indicates non-exported predicates of a module. * **Third level**: * Top: Clauses of the predicate defined in the local file (each clause with its first line number and its first argument. If the argument is a function term it is presented as Functor/Arity. * Rest: Other files that contain multifile contributions to the predicate. * **Fourth level**: Clauses in each file listed at the third level (= multifile contributions from other files). Each clause is displayed with its first line number and its first argument. If the argument is a function term it is presented as Functor/Arity.
In the outline, multifile predicates are shown either as “for” or “from” contributions:
contains predicates for remote modules (= modules different from the one defined in the local file, i.e. modules defined explicitly in another file or a modules defined just implicitly by mutlifile contributions in different files)
the remote modules are displayed in the outline with a black arrow overlay on the module icon. Below each remote module icon, its ++local predicates| (= predicates for which the local file contains clauses)++ are displayed with all their clauses: The ++local clauses| (= clauses in the local file)++ at the top, followed by the other files that contribute clauses (at the third level) and the contributed contributed clauses (at the fourth level). * **From**: If local predicates from other files are listed below a file icon. The local clauses are displayed immediately below the predicate icon, no matter whether they are for the local module or another module.
A single click on the icon of a local predicate or clause selects the first line of that predicate / clause in the associated editor. A single click on the icon of remote clause (= a clause from another file) has no effect. Double clicking a remote clause shows its first line in another editor. Single click is equivalent to navigating via the arrow keys, double click is equivalent to hitting <Return>.
The order of modules in the outline is
Within each module's section, predicates are displayed by default according to the textual order in the local file. However, the predicates can also be sorted alphabetically using the corresponding icon in the outline's tool bar. The order of modules cannot be changed.
In the Prolog Editor a quick outline is available via Ctrl+O or via the context menu.
When nothing is typed into the input field, the quick outline shows the same content as the outline view. Typing retains only the predicates whose name contains the typed string. Hitting Return when there is just one choice left jumps to that predicate.
The Prolog Editor supports code completion dependent on the current file and the loaded code in the currently selected Prolog process. Code completion in the Prolog editor uses the default Eclipse key binding (<Ctrl><Space>). The following elements are shown in the completion:
the following table shows some examples for the completion (click on the images to enlarge).
Select a predicate call and run Open Primary Definition or Declaration | The cursor goes to line 17 | Suggested alternatives if a non-existing or locally invisible predicate is searched |
Open Primary Definition or Declaration offers the possibility to easily jump to the first clause of a selected predicate, similar to the “Open Declaration” command in the Java editor. In the example above the declaration is contained in the same file and therefore the cursor will jump to line 17. If the declaration of the predicate is contained in another file, the other file will be opened in new editor.
will be opened in the editor. Additionally the find definitions and declarations search will be started to display all clauses.
list of similar predicates or show a warning if there are no similar predicates.
Search for all declarations and definitions of the currently selected predicate in the editor. This search is done using the currently selected prolog process in the Prolog Console. The resulting modules get a visibility depending on the context of the selected goal. Possible values for visibility are local, super, sub and invisible.
Search for all references to the currently selected predicate in the editor. This search is done using the currently selected prolog process in the Prolog Console. Each result represents one clause that contains a call to the selected predicate.
SWI Prolog offers the possibility of setting breakpoints in the prolog code. These breakpoints are visible in the SWI GUI Tracer and they can be set and removed within the GUI Tracer.
The PDT Prolog Editor also displays these breakpoints. These breakpoints are those from the currently selected prolog process in the Prolog Console. In the PDT Prolog Editor, one line in the editor can only have one breakpoint. It is possible to set and remove breakpoints directly from the editor. This can be done by double-clicking at the required location on the bar at the left edge of the editor or by using the context menu at the same location (see the screenshots below).
Setting a breakpoint in the editor means setting the breakpoint in the currently selected prolog process in the Prolog Console. Therefore the file in the editor must be consulted in this prolog process, otherwise setting of breakpoints is not possible.
Files which are not contained in any project in the workspace are called external files. For example the prolog code of SWI Prolog is usually not contained in any project in the workspace. To emphasize that a file in the Prolog Editor is an external file the editor uses a different icon in the editor title bar and the background colour of the editor is different (light gray).
The SWI-Prolog predicate edit/1 can be used in the Prolog Console to open a Prolog editor for any currently loaded predicate that has attached source code. This applies also to predicates residing in external files.
E. g. the query “?- edit(member).” will open the library file “lists.pl” and position the cursor in the first clause of member/2 (see screenshots).
Even then, please be aware that the default behaviour of saving an edited file includes reconsulting the file. So it is very easy to break a running system if you edit a system file and save it before editing another file that would need a consistent change.
If you want to perform a set of related changes in different system files use <Ctrl> <Alt> S for saving, disabling the auto-consult for that particular action. You can also change the default behaviour of <Ctrl> S in the PDT preferences.