GNAT Studio 22 Release Notes

We present here a few highlights of the new features in GNAT Studio 22. You can access the complete list here. This GNAT Studio development cycle was focused on reducing the technical debt and improving the Ada Language Server by adding new features and stabilizing the existing ones. Two major internal components (Gtk+ and Python) were also updated.

Gtk 3.24+ Transition

GNAT Studio now uses Gtk 3.24+ instead of Gtk 3.14+, benefitting from various fixes and improvements made regarding styling, memory management, clipboard handling, along with new graphical features such as smooth scrolling.

Python 3

With the Python 2 End of Life Announced as January 1st 2020, we have actively worked to transition the Python interpreter embedded in GNAT Studio from Python 2.7 to Python 3.7.

This included implementing new bindings between Ada and Python 3 (see GNATCOLL.Bindings and GNATCOLL.Python for more details), transitioning the existing plug-ins and the Python scripting API. For the end user, the transition should be transparent - with the important exception that any custom plug-ins will now be interpreted by Python 3.

If you are developing your own GNAT Studio Python plug-ins, you can find more information about the transition, along with some helpful links to get started, in this section of the User’s Guide: https://docs.adacore.com/live/wave/gps/html/gps_ug/GPS.html#transition-to-python-3

Completion

GNAT Studio now uses a new engine for Ada completion, based on the LSP and the Ada Language Server. This fixes issues when completing some Ada 2012 features such as “for of” loops or very complex tagged type hierarchies. This also makes GNAT Studio start up faster, avoiding the load constructs task that parses all the files to provide completion. This will also allow us to fix issues more easily, since this engine is fully based on Libadalang and thus will benefit from all the fixes made on that technology.

_images/for_of_completion.png

This provides enhancement to startup time and memory consumption, as the indexing phase is now shared between all features in the Language Server.

With this new engine, you can have snippets-based completion by enabling the LSP ‣ Completion ‣ Use snippets preference. When enabled, snippets will be inserted for some completion items (subprograms, aggregates…), allowing you to fill the needed parameters/fields one by one using the TAB key.

Note that users can revert to the old engine by disabling the GPS.LSP.COMPLETION trace in your $HOME/.gnatstudio/traces.cfg file.

_images/snippet.png

In addition, we have added a fuzzy mode for completion, which is enabled by default and controlled by the Editor ‣ Completion filter mode preference.

_images/fuzzy.png

Users can also choose whether they want to insert or replace the current word when completing via the Editor ‣ Completion insert mode preference.

Refactorings

New refactorings have been implemented in the Ada Language Server and are thus available in GNAT Studio.

These new refactorings include:

  • Import missing package

  • Remove parameter

  • Change parameter mode

  • Safe rename

    • Identifier collision (including collision with other compilation units, subprogram parameters, and subtype indication of a subprogram parameter)

    • Identifier shadowing (both when an identifier hides or is hidden by another)

    • Subprogram overriding that changes the dynamic dispatching

    • File rename when renaming a top-level declaration (following GNAT convention for now)

  • Suppress separates

All these refactorings are available depending on the context by clicking on the light-bulb icon that appears on the editor’s left side.

_images/refactorings.png

Doing undo (via a key-shortcut or the toolbar icon) after a refactoring will revert all the modifications made for this refactoring. This is useful to revert a rename that affects several buffers at once for instance.

C & C++ Support

Several formatting preferences have been added to the Preferences ‣ Editor ‣ C & C++ page. Extra tuning can be done in the .clangd-format file which GNAT Studio creates for each C/C++ project in the top source directory (see https://www.clangpowertools.com/blog/getting-started-with-clang-format-style-options.html for more information about formatting options).

Source Editor

The tooltips that appear when hovering over entities are now clickable and selectable, allowing users to copy their contents. To copy text from it, just click on the tooltip: the tooltip will then be highlighted and its contents will be selectable.

_images/selectable_tooltip.png

The auto-highlighting that occurs when the cursor is placed on a given word has been reimplemented via the LSP textDocument/documentHighlight request. As a result, the auto_highlight_occurrence.py plugin has been removed. The write and read references are now highlighted using a separate color. It’s also more stable and faster than before, especially on large files.