]> code.delx.au - gnu-emacs-elpa/blob - packages/ada-mode/gpr-query.el
publish ada-mode 5.1.6, wisi 1.0.6, new package ada-ref-man
[gnu-emacs-elpa] / packages / ada-mode / gpr-query.el
1 ;;; gpr-query.el --- minor-mode for navigating sources using the
2 ;;; custom gpr_query tool, based on AdaCore cross reference tool
3 ;;; gnatinspect.
4 ;;;
5 ;;; gpr-query supports Ada and any gcc language that supports the
6 ;;; AdaCore -fdump-xref switch (which includes C, C++).
7 ;;
8 ;;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
9
10 ;; Author: Stephen Leake <stephen_leake@member.fsf.org>
11 ;; Maintainer: Stephen Leake <stephen_leake@member.fsf.org>
12 ;; Version: 1.0
13
14 ;; This file is part of GNU Emacs.
15
16 ;; GNU Emacs is free software: you can redistribute it and/or modify
17 ;; it under the terms of the GNU General Public License as published by
18 ;; the Free Software Foundation, either version 3 of the License, or
19 ;; (at your option) any later version.
20
21 ;; GNU Emacs is distributed in the hope that it will be useful,
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;; GNU General Public License for more details.
25
26 ;; You should have received a copy of the GNU General Public License
27 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28
29 ;;; Usage:
30 ;;
31 ;; M-x gpr-query
32
33 (require 'ada-mode) ;; for ada-prj-*, some other things
34 (require 'gnat-core)
35 (require 'cl-lib)
36 (require 'compile)
37
38 ;;;;; sessions
39
40 ;; gpr_query reads the project files and the database at startup,
41 ;; which is noticeably slow for a reasonably sized project. But
42 ;; running queries after startup is fast. So we leave gpr_query
43 ;; running, and send it new queries via stdin, getting responses via
44 ;; stdout.
45 ;;
46 ;; We maintain a cache of active sessions, one per gnat project.
47
48 (cl-defstruct (gpr-query--session)
49 (process nil) ;; running gpr_query
50 (buffer nil)) ;; receives output of gpr_query
51
52 (defconst gpr-query-buffer-name-prefix " *gpr_query-")
53
54 (defun gpr-query--start-process (session)
55 "Start the session process running gpr_query."
56 (unless (buffer-live-p (gpr-query--session-buffer session))
57 ;; user may have killed buffer
58 (setf (gpr-query--session-buffer session) (gnat-run-buffer gpr-query-buffer-name-prefix)))
59
60 (with-current-buffer (gpr-query--session-buffer session)
61 (let ((process-environment (ada-prj-get 'proc_env)) ;; for GPR_PROJECT_PATH
62
63 (project-file (file-name-nondirectory (ada-prj-get 'gpr_file))))
64 (erase-buffer); delete any previous messages, prompt
65 (setf (gpr-query--session-process session)
66 ;; gnatcoll-1.6 can't handle aggregate projects; M910-032
67 ;; gpr_query can handle some aggregate projects, but not all
68 ;; FIXME: need good error message on bad project file:
69 ;; "can't handle aggregate projects?")
70 (start-process (concat "gpr_query " (buffer-name))
71 (gpr-query--session-buffer session)
72 "gpr_query"
73 (concat "--project=" project-file)))
74 (set-process-query-on-exit-flag (gpr-query--session-process session) nil)
75 (gpr-query-session-wait session)
76
77 ;; check for warnings about invalid directories etc
78 (goto-char (point-min))
79 (when (search-forward "warning:" nil t)
80 (error "gpr_query warnings"))
81 )))
82
83 (defun gpr-query--make-session ()
84 "Create and return a session for the current project file."
85 (let ((session
86 (make-gpr-query--session
87 :buffer (gnat-run-buffer gpr-query-buffer-name-prefix))))
88 (gpr-query--start-process session)
89 session))
90
91 (defvar gpr-query--sessions '()
92 "Assoc list of sessions, indexed by absolute GNAT project file name.")
93
94 (defun gpr-query-cached-session ()
95 "Return a session for the current project file, creating it if necessary."
96 (let* ((session (cdr (assoc ada-prj-current-file gpr-query--sessions))))
97 (if session
98 (progn
99 (unless (process-live-p (gpr-query--session-process session))
100 (gpr-query--start-process session))
101 session)
102 ;; else
103 (prog1
104 (setq session (gpr-query--make-session))
105 (setq gpr-query--sessions
106 (cl-acons ada-prj-current-file session gpr-query--sessions))))
107 ))
108
109 (defconst gpr-query-prompt "^>>> $"
110 ;; gpr_query output ends with this
111 "Regexp matching gpr_query prompt; indicates previous command is complete.")
112
113 (defun gpr-query-session-wait (session)
114 "Wait for the current command to complete."
115 (unless (process-live-p (gpr-query--session-process session))
116 (gpr-query-show-buffer session)
117 (error "gpr-query process died"))
118
119 (with-current-buffer (gpr-query--session-buffer session)
120 (let ((process (gpr-query--session-process session))
121 (search-start (point-min))
122 (wait-count 0))
123 (while (and (process-live-p process)
124 (progn
125 ;; process output is inserted before point, so move back over it to search it
126 (goto-char search-start)
127 (not (re-search-forward gpr-query-prompt (point-max) 1))))
128 (setq search-start (point));; don't search same text again
129 (message (concat "running gpr_query ..." (make-string wait-count ?.)))
130 ;; FIXME: use --display-progress
131 (accept-process-output process 1.0)
132 (setq wait-count (1+ wait-count)))
133 (if (process-live-p process)
134 (message (concat "running gpr_query ... done"))
135 (gpr-query-show-buffer session)
136 (error "gpr_query process died"))
137 )))
138
139 (defun gpr-require-prj ()
140 "Throw error if no project file defined."
141 (unless (or (ada-prj-get 'gpr_file)
142 (ada-prj-get 'gpr_query_file))
143 (error "no gpr project file defined.")))
144
145 (defun gpr-query-session-send (cmd wait)
146 "Send CMD to gpr_query session for current project.
147 If WAIT is non-nil, wait for command to complete.
148 Return buffer that holds output."
149 (gpr-require-prj)
150 (let ((session (gpr-query-cached-session)))
151 ;; always wait for previous command to complete; also checks for
152 ;; dead process.
153 (gpr-query-session-wait session)
154 (with-current-buffer (gpr-query--session-buffer session)
155 (erase-buffer)
156 (process-send-string (gpr-query--session-process session)
157 (concat cmd "\n"))
158 (when wait
159 (gpr-query-session-wait session))
160 (current-buffer)
161 )))
162
163 (defun gpr-query-kill-session (session)
164 (let ((process (gpr-query--session-process session)))
165 (when (process-live-p process)
166 (process-send-string (gpr-query--session-process session) "exit\n")
167 (while (process-live-p process)
168 (accept-process-output process 1.0)))
169 ))
170
171 (defun gpr-query-kill-all-sessions ()
172 (interactive)
173 (let ((count 0))
174 (mapc (lambda (assoc)
175 (let ((session (cdr assoc)))
176 (when (process-live-p (gpr-query--session-process session))
177 (setq count (1+ count))
178 (process-send-string (gpr-query--session-process session) "exit\n")
179 )))
180 gpr-query--sessions)
181 (message "Killed %d sessions" count)
182 ))
183
184 (defun gpr-query-show-buffer (&optional session)
185 "For `ada-show-xref-tool-buffer'; show gpr-query buffer for current project."
186 (interactive)
187 (pop-to-buffer (gpr-query--session-buffer (or session (gpr-query-cached-session)))))
188
189 ;;;;; utils
190
191 (defun gpr-query-get-src-dirs (src-dirs)
192 "Append list of source dirs in current gpr project to SRC-DIRS.
193 Uses 'gpr_query'. Returns new list."
194
195 (with-current-buffer (gpr-query--session-buffer (gpr-query-cached-session))
196 (gpr-query-session-send "source_dirs" t)
197 (goto-char (point-min))
198 (while (not (looking-at gpr-query-prompt))
199 (add-to-list 'src-dirs
200 (directory-file-name
201 (buffer-substring-no-properties (point) (point-at-eol))))
202 (forward-line 1))
203 )
204 src-dirs)
205
206 (defun gpr-query-get-prj-dirs (prj-dirs)
207 "Append list of source dirs in current gpr project to PRJ-DIRS.
208 Uses 'gpr_query'. Returns new list."
209
210 (with-current-buffer (gpr-query--session-buffer (gpr-query-cached-session))
211 (gpr-query-session-send "project_path" t)
212 (goto-char (point-min))
213 (while (not (looking-at gpr-query-prompt))
214 (add-to-list 'prj-dirs
215 (directory-file-name
216 (buffer-substring-no-properties (point) (point-at-eol))))
217 (forward-line 1))
218 )
219 prj-dirs)
220
221 (defconst gpr-query-ident-file-regexp
222 ;; C:\Projects\GDS\work_dscovr_release\common\1553\gds-mil_std_1553-utf.ads:252:25
223 ;; /Projects/GDS/work_dscovr_release/common/1553/gds-mil_std_1553-utf.ads:252:25
224 "\\(\\(?:.:\\\|/\\)[^:]*\\):\\([0123456789]+\\):\\([0123456789]+\\)"
225 ;; 1 2 3
226 "Regexp matching <file>:<line>:<column>")
227
228 (defconst gpr-query-ident-file-regexp-alist
229 (list (concat "^" gpr-query-ident-file-regexp) 1 2 3)
230 "For compilation-error-regexp-alist, matching gpr_query output")
231
232 (defconst gpr-query-ident-file-type-regexp
233 (concat gpr-query-ident-file-regexp " (\\(.*\\))")
234 "Regexp matching <file>:<line>:<column> (<type>)")
235
236 ;; debugging:
237 ;; in *compilation-gpr_query-refs*, run
238 ;; (progn (set-text-properties (point-min)(point-max) nil)(compilation-parse-errors (point-min)(point-max) gpr-query-ident-file-regexp-alist))
239
240 (defun gpr-query-compilation (identifier file line col cmd comp-err)
241 "Run gpr_query IDENTIFIER:FILE:LINE:COL CMD,
242 set compilation-mode with compilation-error-regexp-alist set to COMP-ERR."
243 ;; Useful when gpr_query will return a list of references; we use
244 ;; `compilation-start' to run gpr_query, so the user can navigate
245 ;; to each result in turn via `next-error'.
246 (let ((cmd-1 (format "%s %s:%s:%d:%d" cmd identifier file line col))
247 (result-count 0)
248 file line column)
249 (with-current-buffer (gpr-query--session-buffer (gpr-query-cached-session))
250 (compilation-mode)
251 (setq buffer-read-only nil)
252 (set (make-local-variable 'compilation-error-regexp-alist) (list comp-err))
253 (gpr-query-session-send cmd-1 t)
254 ;; point is at EOB. gpr_query returns one line per result plus prompt
255 (setq result-count (- (line-number-at-pos) 1))
256 (font-lock-fontify-buffer)
257 ;; font-lock-fontify-buffer applies compilation-message text properties
258 ;; IMPROVEME: for some reason, next-error works, but the font
259 ;; colors are not right (no koolaid!)
260 (goto-char (point-min))
261
262 (cl-case result-count
263 (0
264 (error "gpr_query returned no results"))
265 (1
266 (when (looking-at "^Error: entity not found")
267 (error (buffer-substring-no-properties (line-beginning-position) (line-end-position))))
268
269 ;; just go there, don't display session-buffer. We have to
270 ;; fetch the compilation-message while in the session-buffer.
271 (let* ((msg (compilation-next-error 0 nil (point-min)))
272 (loc (compilation--message->loc msg)))
273 (setq file (caar (compilation--loc->file-struct loc))
274 line (caar (cddr (compilation--loc->file-struct loc)))
275 column (1- (compilation--loc->col loc)))
276 ))
277
278 (t
279 ;; for next-error, below
280 (setq next-error-last-buffer (current-buffer)))
281
282 ));; case, with-currrent-buffer
283
284 (if (> result-count 1)
285 ;; more than one result; display session buffer, goto first ref
286 ;;
287 ;; compilation-next-error-function assumes there is not an error
288 ;; at point-min; work around that by moving forward 0 errors for
289 ;; the first one. Unless the first line contains "warning: ".
290 (if (looking-at "^warning: ")
291 (next-error)
292 (next-error 0 t))
293
294 ;; just one result; go there
295 (ada-goto-source file line column nil))
296 ))
297
298 (defun gpr-query-dist (found-line line found-col col)
299 "Return distance between FOUND-LINE FOUND-COL and LINE COL."
300 (+ (abs (- found-col col))
301 (* (abs (- found-line line)) 250)))
302
303 ;;;;; user interface functions
304
305 (defun gpr-query-show-references ()
306 "Show all references of identifier at point."
307 (interactive)
308 (gpr-query-all
309 (thing-at-point 'symbol)
310 (file-name-nondirectory (buffer-file-name))
311 (line-number-at-pos)
312 (1+ (current-column)))
313 )
314
315 (defun gpr-query-overridden (other-window)
316 "Move to the overridden declaration of the identifier around point.
317 If OTHER-WINDOW (set by interactive prefix) is non-nil, show the
318 buffer in another window."
319 (interactive "P")
320
321 (let ((target
322 (gpr-query-overridden-1
323 (thing-at-point 'symbol)
324 (buffer-file-name)
325 (line-number-at-pos)
326 (save-excursion
327 (goto-char (car (bounds-of-thing-at-point 'symbol)))
328 (1+ (current-column)))
329 )))
330
331 (ada-goto-source (nth 0 target)
332 (nth 1 target)
333 (nth 2 target)
334 other-window)
335 ))
336
337 (defun gpr-query-goto-declaration (other-window)
338 "Move to the declaration or body of the identifier around point.
339 If at the declaration, go to the body, and vice versa. If at a
340 reference, goto the declaration.
341
342 If OTHER-WINDOW (set by interactive prefix) is non-nil, show the
343 buffer in another window."
344 (interactive "P")
345
346 (let ((target
347 (gpr-query-other
348 (thing-at-point 'symbol)
349 (buffer-file-name)
350 (line-number-at-pos)
351 (save-excursion
352 (goto-char (car (bounds-of-thing-at-point 'symbol)))
353 (1+ (current-column)))
354 )))
355
356 (ada-goto-source (nth 0 target)
357 (nth 1 target)
358 (nth 2 target)
359 other-window)
360 ))
361
362 (defvar gpr-query-map
363 (let ((map (make-sparse-keymap)))
364 ;; C-c C-i prefix for gpr-query minor mode
365
366 (define-key map "\C-c\C-i\C-d" 'gpr-query-goto-declaration)
367 (define-key map "\C-c\C-i\C-p" 'ada-build-prompt-select-prj-file)
368 (define-key map "\C-c\C-i\C-q" 'gpr-query-refresh)
369 (define-key map "\C-c\C-i\C-r" 'gpr-query-show-references)
370 ;; FIXME: (define-key map "\C-c\M-d" 'gpr-query-parents)
371 ;; FIXME: overriding
372 map
373 ) "Local keymap used for GNAT inspect minor mode.")
374
375 (defvar gpr-query-menu (make-sparse-keymap "gpr-query"))
376 (easy-menu-define gpr-query-menu gpr-query-map "Menu keymap for gpr-query minor mode"
377 '("gpr-query"
378 ["Find and select project ..." ada-build-prompt-select-prj-file t]
379 ["Select project ..." ada-prj-select t]
380 ["Show current project" ada-prj-show t]
381 ["Show gpr-query buffer" gpr-query-show-buffer t]
382 ["Next compilation error" next-error t]
383 ["Show secondary error" ada-show-secondary-error t]
384 ["Goto declaration/body" gpr-query-goto-declaration t]
385 ["Show parent declarations" ada-show-declaration-parents t]
386 ["Show references" gpr-query-show-references t]
387 ;; ["Show overriding" gpr-query-show-overriding t]
388 ;; ["Show overridden" gpr-query-show-overridden t]
389 ["Refresh cross reference cache" gpr-query-refresh t]
390 ))
391
392 (define-minor-mode gpr-query
393 "Minor mode for navigating sources using GNAT cross reference tool.
394 Enable mode if ARG is positive"
395 :initial-value t
396 :lighter " gpr-query" ;; mode line
397
398 ;; just enable the menu and keymap
399 )
400
401 ;;;;; support for Ada mode
402
403 (defun gpr-query-refresh ()
404 "For `ada-xref-refresh-function', using gpr_query."
405 (interactive)
406 ;; need to kill session to get changed env vars etc
407 (let ((session (gpr-query-cached-session)))
408 (gpr-query-kill-session session)
409 (gpr-query--start-process session)))
410
411 (defun gpr-query-other (identifier file line col)
412 "For `ada-xref-other-function', using gpr_query."
413 (when (eq ?\" (aref identifier 0))
414 ;; gpr_query wants the quotes stripped
415 (setq col (+ 1 col))
416 (setq identifier (substring identifier 1 (1- (length identifier))))
417 )
418
419 (when (eq system-type 'windows-nt)
420 ;; Since Windows file system is case insensitive, GNAT and Emacs
421 ;; can disagree on the case, so convert all to lowercase.
422 (setq file (downcase file)))
423
424 (let ((cmd (format "refs %s:%s:%d:%d" identifier (file-name-nondirectory file) line col))
425 (decl-loc nil)
426 (body-loc nil)
427 (search-type nil)
428 (min-distance (1- (expt 2 29)))
429 (result nil))
430
431 (with-current-buffer (gpr-query-session-send cmd t)
432 ;; 'gpr_query refs' returns a list containing the declaration,
433 ;; the body, and all the references, in no particular order.
434 ;;
435 ;; We search the list, looking for the input location,
436 ;; declaration and body, then return the declaration or body as
437 ;; appropriate.
438 ;;
439 ;; the format of each line is file:line:column (type)
440 ;; 1 2 3 4
441 ;;
442 ;; 'type' can be:
443 ;; body
444 ;; declaration
445 ;; full declaration (for a private type)
446 ;; implicit reference
447 ;; reference
448 ;; static call
449 ;;
450 ;; Module_Type:/home/Projects/GDS/work_stephe_2/common/1553/gds-hardware-bus_1553-wrapper.ads:171:9 (full declaration)
451 ;;
452 ;; itc_assert:/home/Projects/GDS/work_stephe_2/common/itc/opsim/itc_dscovr_gdsi/Gds1553/src/Gds1553.cpp:830:9 (reference)
453
454 (message "parsing result ...")
455
456 (goto-char (point-min))
457
458 (while (not (eobp))
459 (cond
460 ((looking-at gpr-query-ident-file-type-regexp)
461 ;; process line
462 (let* ((found-file (match-string 1))
463 (found-line (string-to-number (match-string 2)))
464 (found-col (string-to-number (match-string 3)))
465 (found-type (match-string 4))
466 (dist (gpr-query-dist found-line line found-col col))
467 )
468
469 (when (eq system-type 'windows-nt)
470 ;; 'expand-file-name' converts Windows directory
471 ;; separators to normal Emacs. Since Windows file
472 ;; system is case insensitive, GNAT and Emacs can
473 ;; disagree on the case, so convert all to lowercase.
474 (setq found-file (downcase (expand-file-name found-file))))
475
476 (when (string-equal found-type "declaration")
477 (setq decl-loc (list found-file found-line (1- found-col))))
478
479 (when (or
480 (string-equal found-type "body")
481 (string-equal found-type "full declaration"))
482 (setq body-loc (list found-file found-line (1- found-col))))
483
484 (when
485 ;; The source may have changed since the xref database
486 ;; was computed, so allow for fuzzy matches.
487 (and (equal found-file file)
488 (< dist min-distance))
489 (setq min-distance dist)
490 (setq search-type found-type))
491 ))
492
493 (t ;; ignore line
494 ;;
495 ;; This skips GPR_PROJECT_PATH and echoed command at start of buffer.
496 ;;
497 ;; It also skips warning lines. For example,
498 ;; gnatcoll-1.6w-20130902 can't handle the Auto_Text_IO
499 ;; language, because it doesn't use the gprconfig
500 ;; configuration project. That gives lines like:
501 ;;
502 ;; common_text_io.gpr:15:07: language unknown for "gds-hardware-bus_1553-time_tone.ads"
503 ;;
504 ;; There are probably other warnings that might be reported as well.
505 )
506 )
507 (forward-line 1)
508 )
509
510 (cond
511 ((null search-type)
512 nil)
513
514 ((and
515 (string-equal search-type "declaration")
516 body-loc)
517 (setq result body-loc))
518
519 (decl-loc
520 (setq result decl-loc))
521 )
522
523 (when (null result)
524 (error "gpr_query did not return other item; refresh?"))
525
526 (message "parsing result ... done")
527 result)))
528
529 (defun gpr-query-all (identifier file line col)
530 "For `ada-xref-all-function', using gpr_query."
531 (gpr-query-compilation identifier file line col "refs" 'gpr-query-ident-file))
532
533 (defun gpr-query-parents (identifier file line col)
534 "For `ada-xref-parent-function', using gpr_query."
535 (gpr-query-compilation identifier file line col "parent_types" 'gpr-query-ident-file))
536
537 (defun gpr-query-overriding (identifier file line col)
538 "For `ada-xref-overriding-function', using gpr_query."
539 (gpr-query-compilation identifier file line col "overriding" 'gpr-query-ident-file))
540
541 (defun gpr-query-overridden-1 (identifier file line col)
542 "For `ada-xref-overridden-function', using gpr_query."
543 (when (eq ?\" (aref identifier 0))
544 ;; gpr_query wants the quotes stripped
545 (setq col (+ 1 col))
546 (setq identifier (substring identifier 1 (1- (length identifier))))
547 )
548
549 (let ((cmd (format "overridden %s:%s:%d:%d" identifier (file-name-nondirectory file) line col))
550 result)
551 (with-current-buffer (gpr-query-session-send cmd t)
552
553 (goto-char (point-min))
554 (when (looking-at gpr-query-ident-file-regexp)
555 (setq result
556 (list
557 (match-string 1)
558 (string-to-number (match-string 2))
559 (string-to-number (match-string 3)))))
560
561 (when (null result)
562 (error "gpr_query did not return a result; refresh?"))
563
564 (message "parsing result ... done")
565 result)))
566
567 (defun ada-gpr-query-select-prj ()
568 (setq ada-file-name-from-ada-name 'ada-gnat-file-name-from-ada-name)
569 (setq ada-ada-name-from-file-name 'ada-gnat-ada-name-from-file-name)
570 (setq ada-make-package-body 'ada-gnat-make-package-body)
571
572 (add-hook 'ada-syntax-propertize-hook 'gnatprep-syntax-propertize)
573
574 ;; must be after indentation engine setup, because that resets the
575 ;; indent function list.
576 (add-hook 'ada-mode-hook 'ada-gpr-query-setup t)
577
578 (setq ada-xref-refresh-function 'gpr-query-refresh)
579 (setq ada-xref-all-function 'gpr-query-all)
580 (setq ada-xref-other-function 'gpr-query-other)
581 (setq ada-xref-parent-function 'gpr-query-parents)
582 (setq ada-xref-all-function 'gpr-query-all)
583 (setq ada-xref-overriding-function 'gpr-query-overriding)
584 (setq ada-xref-overridden-function 'gpr-query-overridden-1)
585 (setq ada-show-xref-tool-buffer 'gpr-query-show-buffer)
586
587 (add-to-list 'completion-ignored-extensions ".ali") ;; gnat library files, used for cross reference
588 )
589
590 (defun ada-gpr-query-deselect-prj ()
591 (setq ada-file-name-from-ada-name nil)
592 (setq ada-ada-name-from-file-name nil)
593 (setq ada-make-package-body nil)
594
595 (setq ada-syntax-propertize-hook (delq 'gnatprep-syntax-propertize ada-syntax-propertize-hook))
596 (setq ada-mode-hook (delq 'ada-gpr-query-setup ada-mode-hook))
597
598 (setq ada-xref-other-function nil)
599 (setq ada-xref-parent-function nil)
600 (setq ada-xref-all-function nil)
601 (setq ada-xref-overriding-function nil)
602 (setq ada-xref-overridden-function nil)
603 (setq ada-show-xref-tool-buffer nil)
604
605 (setq completion-ignored-extensions (delete ".ali" completion-ignored-extensions))
606 )
607
608 (defun ada-gpr-query-setup ()
609 (when (boundp 'wisi-indent-calculate-functions)
610 (add-to-list 'wisi-indent-calculate-functions 'gnatprep-indent))
611 )
612
613 (defun ada-gpr-query ()
614 "Set Ada mode global vars to use gpr_query."
615 (add-to-list 'ada-prj-parser-alist '("gpr" . gnat-parse-gpr))
616 (add-to-list 'ada-select-prj-xref-tool '(gpr_query . ada-gpr-query-select-prj))
617 (add-to-list 'ada-deselect-prj-xref-tool '(gpr_query . ada-gpr-query-deselect-prj))
618
619 ;; no parse-*-xref
620
621 (font-lock-add-keywords 'ada-mode
622 ;; gnatprep preprocessor line
623 (list (list "^[ \t]*\\(#.*\n\\)" '(1 font-lock-type-face t))))
624 )
625
626 (provide 'gpr-query)
627 (provide 'ada-xref-tool)
628
629 (add-to-list 'compilation-error-regexp-alist-alist
630 (cons 'gpr-query-ident-file gpr-query-ident-file-regexp-alist))
631
632 (unless (and (boundp 'ada-xref-tool)
633 (default-value 'ada-xref-tool))
634 (setq ada-xref-tool 'gpr_query))
635
636 (ada-gpr-query)
637
638 ;;; end of file