## vim: ft=makoada

---------------------------------
-- Bare_Basic_Decl_Short_Image --
---------------------------------

function Bare_Basic_Decl_Short_Image
  (Node : access Bare_Basic_Decl_Type'Class) return Text_Type
is
   Self : access Bare_Basic_Decl_Type'Class := Node;
   Ret  : Unbounded_Wide_Wide_String;

   function Name_Image (Node : access Bare_Expr_Type'Class) return Text_Type;
   --  Print a Dotted Name

   function Name_Image (Node : access Bare_Expr_Type'Class) return Text_Type
   is
      D : Bare_Dotted_Name;
   begin
      if Node = null then
         return "None";
      end if;

      if Node.all in Bare_Single_Tok_Node_Type'Class then
         return Node.Text;

      elsif Node.all in Bare_Dotted_Name_Type'Class then
         D := Bare_Dotted_Name_Type (Node.all)'Access;
         return Name_Image (D.F_Prefix) & "." & Name_Image (D.F_Suffix);

      elsif Node.all in Bare_Defining_Name_Type'Class then
         return Name_Image (Bare_Defining_Name (Node).F_Name);
      else
         return "<>";
      end if;
   end Name_Image;

   Children : Entity_Defining_Name_Array_Access := Self.P_Defining_Names;
begin
   Append (Ret, "<" & To_Text (Kind_Name (Self)) & " [");

   for I in Children.Items'Range loop
      Append (Ret, """");
      Append (Ret, Name_Image (Children.Items (I).El));
         Append (Ret, """");
      if I /= Children.Items'Last then
         Append (Ret, ", ");
      end if;
   end loop;
   Dec_Ref (Children);

   Append (Ret, "] " & To_Text (Image (Sloc_Range (Node))) & ">");
   return To_Wide_Wide_String (Ret);
end Bare_Basic_Decl_Short_Image;
