scitools.com

← Graph catalog

Declaration Tree is one of the interactive graphs Understand can draw of your code — call trees, dependencies, control flow, and more.

Declaration Tree

Languages: Ada, VHDL
Targets: Files, Packages, Subprograms
Variants: Classic, Cluster, Compare, Relationship, Simplified

Show the units and subprograms declared directly or indirectly inside a selected scope.

For a selected package, task, protected object, subprogram, or file (in Ada), or a selected architecture, entity, configuration, package, or subprogram (in VHDL), this shows an edge to each unit or subprogram declared immediately inside it, then recurses into each of those in turn, building a multi-level tree that mirrors the nesting of the source code.

Rooted at the Ada package Control below, the graph shows its nested declarations: the package Logging (which declares the procedure Write), the task Worker (which declares the entries Start and Stop), the protected object Mutex (which declares the entry Acquire, the procedure Release, and the function Is_Locked), and the procedure Run (which declares the nested function Double). The inverse graph, Declared In, shows the reverse relationship — the scope a selected unit is declared inside — but it's only available for Ada; there's no equivalent inverse graph for VHDL.

See the following code and corresponding graph

package Control is

   package Logging is
      procedure Write (Message : String);
   end Logging;

   task Worker is
      entry Start (Id : Integer);
      entry Stop;
   end Worker;

   protected Mutex is
      entry Acquire;
      procedure Release;
      function Is_Locked return Boolean;
   private
      Locked : Boolean := False;
   end Mutex;

   procedure Run (Count : Integer);

end Control;

package body Control is

   package body Logging is
      procedure Write (Message : String) is
         pragma Unreferenced (Message);
      begin
         null;
      end Write;
   end Logging;

   task body Worker is
   begin
      loop
         select
            accept Start (Id : Integer) do
               pragma Unreferenced (Id);
            end Start;
         or
            accept Stop;
            exit;
         end select;
      end loop;
   end Worker;

   protected body Mutex is
      entry Acquire when not Locked is
      begin
         Locked := True;
      end Acquire;

      procedure Release is
      begin
         Locked := False;
      end Release;

      function Is_Locked return Boolean is
      begin
         return Locked;
      end Is_Locked;
   end Mutex;

   procedure Run (Count : Integer) is
      pragma Unreferenced (Count);

      function Double (X : Integer) return Integer is
      begin
         return X * 2;
      end Double;

      Result : Integer := Double (0);
      pragma Unreferenced (Result);
   begin
      null;
   end Run;

end Control;

Declaration Tree - Classic

The Classic variant is similar to the Simplified variant, showing all relationships in a simple tree, but it uses a custom layout algorithm instead of Graphviz.


Back to Declaration Tree

Declaration Tree - Cluster

The Cluster variant groups entities by their containing class/file/architecture.


Back to Declaration Tree

Declaration Tree - Compare

The Compare variant shows how the graph has changed relative to the project's comparison database.


Back to Declaration Tree

Declaration Tree - Relationship

The Relationship variant filters the graph to only paths connecting the two entities.


Back to Declaration Tree

Declaration Tree - Simplified

The Simplified variant shows all relationships in a simple tree (no clusters)


Back to Declaration Tree