File: language_handlers-glide.ads

package info (click to toggle)
gnat-gps 2.1.0-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 48,704 kB
  • ctags: 17,175
  • sloc: ada: 307,479; ansic: 153,568; sh: 10,429; perl: 6,526; xml: 4,853; yacc: 3,520; cpp: 2,209; lex: 2,043; makefile: 1,986; tcl: 1,248; python: 1,064; sed: 161; csh: 141; lisp: 22; java: 6; fortran: 2
file content (181 lines) | stat: -rw-r--r-- 7,435 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
-----------------------------------------------------------------------
--                               G P S                               --
--                                                                   --
--                     Copyright (C) 2002-2004                       --
--                            ACT-Europe                             --
--                                                                   --
-- GPS is free  software; you  can redistribute it and/or modify  it --
-- under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or --
-- (at your option) any later version.                               --
--                                                                   --
-- This program is  distributed in the hope that it will be  useful, --
-- but  WITHOUT ANY WARRANTY;  without even the  implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU --
-- General Public License for more details. You should have received --
-- a copy of the GNU General Public License along with this library; --
-- if not,  write to the  Free Software Foundation, Inc.,  59 Temple --
-- Place - Suite 330, Boston, MA 02111-1307, USA.                    --
-----------------------------------------------------------------------

--  See documentation in parent package Language_Handlers.
--
--  When adding new languages, the following needs to be done:
--    - Register a LI handler (for generating the xref database for this
--      language). Since such handlers can be shared by multiple languages,
--      this registration is optional when it has already been done.
--
--    - Register the new language with Register_Language. This is associated
--      with basic syntactic information for highlighting in the source editor
--      and manipulation through the debugger.
--
--    - Register extra information for the language with
--      Add_Language_Info. This registers default extensions for this language,
--      and provide a mapping from this language to the matching LI handler.

with Language;
with Basic_Types;
with Entities;
with Projects;
with GNAT.OS_Lib;

package Language_Handlers.Glide is

   type Glide_Language_Handler_Record is new Language_Handler_Record
     with private;
   type Glide_Language_Handler is access all
     Glide_Language_Handler_Record'Class;

   procedure Gtk_New (Handler : out Glide_Language_Handler);
   --  Create a new language handler

   procedure Destroy (Handler : in out Glide_Language_Handler);
   --  Free the memory occupied by Handler, and removes all the registered LI
   --  handlers. They are destroyed individually.

   procedure Set_Registry
     (Handler  : access Glide_Language_Handler_Record;
      Registry : access Projects.Abstract_Registry'Class);
   --  Set the top-level project for Handler.

   -----------------
   -- LI handlers --
   -----------------
   --  These are the types responsible for generating the xref database for all
   --  the supported language. It is possible that a given handler is
   --  associated with multiple languages.

   procedure Register_LI_Handler
     (Handler : access Glide_Language_Handler_Record;
      Name    : String;
      LI      : Entities.LI_Handler);
   --  Register a new LI handler that can generate xref.
   --  The Name is used both for retrieval of the handler by
   --  Get_LI_Handler_By_Name, and to print in the console when recomputing the
   --  xref database.

   function Get_LI_Handler_By_Name
     (Handler : access Glide_Language_Handler_Record;
      Name    : String) return Entities.LI_Handler;
   --  Return the LI handler which name is Name.
   --  Name is case-sensitive.

   function Get_LI_Name
     (Handler : access Glide_Language_Handler_Record;
      Nth     : Natural) return String;
   --  Return the name of LI.

   function Get_LI_Handler_From_File
     (Handler         : access Glide_Language_Handler_Record;
      Source_Filename : VFS.Virtual_File)
      return Entities.LI_Handler;
   --  Return the LI handler to use for a specific file name.
   --  null is returned if the language is unknown.
   --  Project is the project that contains Source_Filename, or No_Project if
   --  it is unknown.

   function LI_Handlers_Count
     (Handler : access Glide_Language_Handler_Record) return Natural;
   --  Return the number of LI handlers known. This count will generally be
   --  different from the number of supported languages, since some LI handlers
   --  will handle multiple languages.

   function Get_Nth_Handler
     (Handler : access Glide_Language_Handler_Record;
      Num     : Positive) return Entities.LI_Handler;
   --  Return the handler for the Num-th language.
   --  The first handler is number 1.

   ---------------
   -- Languages --
   ---------------

   function Get_Language_From_File
     (Handler : access Glide_Language_Handler_Record;
      Source_Filename : VFS.Virtual_File) return Language.Language_Access;
   --  Find the language of a given file.
   --  Return Unknown_Lang if no other language could be found.

   function Get_Language_From_File
     (Handler : access Glide_Language_Handler_Record;
      Source_Filename : VFS.Virtual_File) return String;
   --  Return "" if the language is unknown.

   function Get_Language_By_Name
     (Handler : access Glide_Language_Handler_Record;
      Name    : String) return Language.Language_Access;

   procedure Register_Language
     (Handler : access Glide_Language_Handler_Record;
      Name    : String;
      Lang    : Language.Language_Access);

   function Known_Languages
     (Handler : access Glide_Language_Handler_Record;
      Sorted  : Boolean := False) return GNAT.OS_Lib.Argument_List;

   procedure Set_Language_Handler
     (Handler       : access Glide_Language_Handler_Record;
      Language_Name : String;
      LI            : Entities.LI_Handler);
   --  Register some extra information for a specific language.
   --  Nothing is done if Language_Name hasn't been registered first.
   --  See also Projects.Registry.Register_Default_Language_Extension and
   --  Projects.Registry.Add_Language_Extension.

   function Languages_Count (Handler : access Glide_Language_Handler_Record)
      return Natural;
   --  Return the number of languages declared in Handler

   function Get_Nth_Language
     (Handler : access Glide_Language_Handler_Record;
      Num     : Positive) return String;
   --  Return the name of the Num-th language.
   --  The first handler is number 1.

private
   type Language_Info is record
      Language_Name : Basic_Types.String_Access;
      Lang          : Language.Language_Access;
      Handler       : Entities.LI_Handler;
   end record;

   type Language_Info_Array is array (Positive range <>) of Language_Info;
   type Language_Info_Access is access Language_Info_Array;

   type Handler_Info is record
      Name    : Basic_Types.String_Access;
      Handler : Entities.LI_Handler;
   end record;

   type Handler_Info_Array is array (Positive range <>) of Handler_Info;
   type Handler_Info_Access is access Handler_Info_Array;

   type Glide_Language_Handler_Record is new Language_Handler_Record
   with record
      Languages : Language_Info_Access;
      Handlers  : Handler_Info_Access;
      Registry  : Projects.Abstract_Registry_Access;
   end record;

end Language_Handlers.Glide;