7.2. Unit providers

7.2.2. Libadalang.Project_Provider

This package provides an Unit_Provider implementation that relies on a project file.

package LAL renames Libadalang.Analysis
package Prj renames GNATCOLL.Projects
Trace : constant GNATCOLL.Traces.Trace_Handle
Value: GNATCOLL.Traces.Create (“LIBADALANG.PROJECT_PROVIDER”, GNATCOLL.Traces.From_Config)
type Provider_And_Projects

Associates one project unit provider with all the projects on which it has visibility.

type Provider_And_Projects_Array
type Provider_And_Projects_Array_Access
procedure Free (PAP_Array : Provider_And_Projects_Array_Access)
function Create_Project_Unit_Providers (Tree : Prj.Project_Tree_Access) return Provider_And_Projects_Array_Access

Create unit providers for consistent sets of projects in Tree.

As unit providers must guarantee that there exists at most one source file for each couple (unit name, unit kind), this creates more than one unit providers when Project is an aggregate project that contains multiple definitions for the same unit.

The project pointed to by Tree must outlive the returned unit file providers, and it is up to callers to deallocate Tree itself.

function Create_Project_Unit_Provider (Tree : Prj.Project_Tree_Access; Project : Prj.Project_Type; Env : Prj.Project_Environment_Access; Is_Project_Owner : Boolean) return LAL.Unit_Provider_Reference

Likewise, but create only one unit provider.

If a non-null Project is given, use it to provide units. Raise an Invalid_Project exception if an aggregate projects that aggregates more than one project is in its closure.

If Project is not provided, run Create_Project_Unit_Providers: if it returns only one provider, return it, otherwise raise an error.

If Is_Project_Owner is true, the result owns Tree, thus the caller must not deallocate it itself. Otherwise, the project pointed to by Project must outlive the returned unit file provider.

function Convert (Kind : Analysis_Unit_Kind) return GNATCOLL.Projects.Unit_Parts

Convert our kind for analysis unit into the corresponding GNATCOLL.Projects value.

7.2.2. Libadalang.Auto_Provider

This package provides the capability to automatically discover the layout of source files in an Ada project, given a list of files, or a file name pattern and a list of directories.

It is useful in order to easily run Libadalang on a complex project that does not have its own GPR project file.

Default_Source_Filename_Pattern : constant GNAT.Regpat.Pattern_Matcher
Value: GNAT.Regpat.Compile (”.*\.(ad.|a|spc|bdy)”)

Default matcher for Ada source filenames. This matches most usual file extensions used for Ada sources: .ads, .adb, .ada, .spc, .bdy, etc.

function Find_Files (Name_Pattern : GNAT.Regpat.Pattern_Matcher; Directories : GNATCOLL.VFS.File_Array) return GNATCOLL.VFS.File_Array_Access

Return the list of absolute file names for all regular files in the given Directories whose name match the given regular expression Name_Pattern. The result is dynamically allocated, so the caller must free it when done with it.

type Auto_Unit_Provider

Unit provider for a given list of files

function Create_Auto_Provider (Input_Files : GNATCOLL.VFS.File_Array; Charset : String) return Auto_Unit_Provider

Return a unit provider that knows which compilation units are to be found in the given list of source files.

This knowledge is built trying to parse all given Input_Files as Ada source files and listing the compilation units found there. Files that cannot be parsed properly are discarded. If two compilation units are found for the same unit, the first that is found in Input_Files is taken and the other ones are discarded.

Source files are decoded using the given Charset.

function Create_Auto_Provider_Reference (Input_Files : GNATCOLL.VFS.File_Array; Charset : String) return Unit_Provider_Reference

Wrapper around Create_Auto_Provider as a shortcut to create a unit provider reference.