2.2.8. GNAT Project Explorer

The GNAT Project Explorer provides a GNAT-specific view of the project, including a contextual menu, without the additional information provided by the Navigator (for example) that might be extraneous in normal use. Projects that are not configured as GNATbench projects are given the standard resource layout with no changes. With the GNAT Project Explorer you will not need to use the Eclipse Navigator except for a few Eclipse resource-oriented activities.

In this view, GNATbench projects contain four kind of entries: the source directories, the run-time library, the object directory, and finally the resources present in the project but not managed through the GNAT project file.

The source directories are listed at the beginning of the project. Their content is the exact sources of the project, filtering out non-source files.

The run-time library entry gives access to the run-time files currently used by the project.

The object directory contains the object code files and the ali files generated by the compilation process. Unless you specify otherwise, this directory will also contain the executable image, but as shown below the executable can be in a dedicated directory as well.

A sample project in the GNAT Project Explorer is shown in the figure below.

gnat project explorer Enabling the GNAT Project Explorer

In the Ada perspective you can open the view by using the Window menu entry and selecting the shortcut to the view:

enabling the project explorer view via Window menu

Otherwise you can use the Window menu entry and select “Show View” -> “Other...” to bring up the dialog box shown below. Expand the “Ada” category and select “GNAT Project Explorer”.

enabling the project explorer view

Press OK and the Explorer will open. Source Folders and Source Files

“Source folders” are those folders specified in the GNAT project file via the “Source_Dirs” attribute. Similarly, “binary folders” are those folders defined to contain compilation products, such as object files and executables, via the “Object_Dir” and “Exec_Dir” attributes. The figure below illustrates two of these attributes:


“Source files” are files that are both located within “source folders” and are of recognized languages defined by GNAT and the GNAT project file. The next figure shows a typical definition of the Languages attribute in a project file:


The GNAT Project Explorer only shows the “source files” within a “source folder”. If you want to maintain other files in folders, you should create additional folders to contain them rather than use a “source folder” for that purpose. Viewing Project Source Folders and Files

The GNAT Project Explorer shows the source folders and source files within those directories, in tree format, as the first node(s) in the project. The icon for the source folders is that of a folder containing a package, as shown below. Clicking on file names within these trees will open the corresponding files in the Ada-aware editor.

Note that the source folders are displayed as a flat list, regardless of how they are represented on the disk.

project explorer showing source files Browsing Unit Content

Additionally, the GNAT Project Explorer includes browser functionality similar to that of the Outline View. In particular, if you expand a given file node you will see icons for the language-specific contents of the file. Clicking on one of these entities in the Project Explorer will take you to the source code for that entity, opening the file in an editor if not already open.

project explorer browsing Contextual Menus

Project nodes within the GNAT Project Explorer have a contextual menu offering specific commands for Ada development, as well as some general capabilities. Additional menu entries for other external tools will also appear, in particular SPARK and CodePeer, if they are installed.

project explorer contextual menu

Lower level nodes also have a contextual menu offering specific commands for Ada development. Note in particular the command to compile the corresponding file.

project explorer contextual menu Viewing Run-Time Library Files

The run-time library entry gives access to the run-time files currently used by the project. You can open any of these files in the editor for browsing. You should not alter these files unless you intend to recompile the library.

Note that the run-time library files include the GNAT-provided utility packages in the GNAT.* hierarchy.

Note also that the displayed content may change if you install a new version of the compiler or if you change the settings of the project file to use a different compiler or run-time library.

In the following figure we have expanded the run-time library node to show the source files and have opened the spec for package Ada.Calendar.Formatting in the file named “a-calfor.ads”

project explorer browsing runtime library Viewing Project Dependencies

The GNAT Project Explorer displays the other projects, if any, that the current project depends upon. (One project depends upon another if its GNAT project file (the “gpr file”) contains a “with-clause” specifying the other GNAT project file.) These dependencies are displayed in a sub-node named “Project Dependencies.”

For example, the following figure illustrates the case in which the GNAT project “example” depends upon another project named “Components”:

project explorer showing project dependency