* cedet/semantic.el (semantic-new-buffer-setup-functions): New
[bpt/emacs.git] / lisp / cedet / semantic.el
CommitLineData
d3d82e7b
CY
1;;; semantic.el --- Semantic buffer evaluator.
2
bd2afec2
GM
3;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4;; 2008, 2009 Free Software Foundation, Inc.
d3d82e7b
CY
5
6;; Author: Eric M. Ludlam <zappo@gnu.org>
7;; Keywords: syntax
8
9;; This file is part of GNU Emacs.
10
11;; GNU Emacs is free software: you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by
13;; the Free Software Foundation, either version 3 of the License, or
14;; (at your option) any later version.
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
22;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23
24;;; Commentary:
25;;
26;; API for providing the semantic content of a buffer.
27;;
28;; The semantic API provides an interface to a series of different parser
29;; implementations. Each parser outputs a parse tree in a similar format
30;; designed to handle typical functional and object oriented languages.
31
715f35a5 32(require 'cedet)
9d389824
CY
33(require 'semantic/tag)
34(require 'semantic/lex)
d3d82e7b 35
00999a2e
CY
36(defvar semantic-version "2.0pre7"
37 "Current version of Semantic.")
38
d3d82e7b 39(declare-function inversion-test "inversion")
17e1f4bc 40(declare-function semanticdb-load-ebrowse-caches "semantic/db-ebrowse")
d3d82e7b
CY
41
42(defun semantic-require-version (major minor &optional beta)
43 "Non-nil if this version of semantic does not satisfy a specific version.
44Arguments can be:
45
46 (MAJOR MINOR &optional BETA)
47
48 Values MAJOR and MINOR must be integers. BETA can be an integer, or
49excluded if a released version is required.
50
51It is assumed that if the current version is newer than that specified,
52everything passes. Exceptions occur when known incompatibilities are
53introduced."
54 (require 'inversion)
55 (inversion-test 'semantic
56 (concat major "." minor
57 (when beta (concat "beta" beta)))))
58
59(defgroup semantic nil
60 "Parser Generator and parser framework."
61 :group 'lisp)
62
63(defgroup semantic-faces nil
64 "Faces used for Semantic enabled tools."
65 :group 'semantic)
66
9d389824 67(require 'semantic/fw)
d3d82e7b
CY
68
69;;; Code:
70;;
71
72;;; Variables and Configuration
73;;
74(defvar semantic--parse-table nil
75 "Variable that defines how to parse top level items in a buffer.
76This variable is for internal use only, and its content depends on the
77external parser used.")
78(make-variable-buffer-local 'semantic--parse-table)
79(semantic-varalias-obsolete 'semantic-toplevel-bovine-table
80 'semantic--parse-table)
81
82(defvar semantic-symbol->name-assoc-list
83 '((type . "Types")
84 (variable . "Variables")
85 (function . "Functions")
86 (include . "Dependencies")
87 (package . "Provides"))
88 "Association between symbols returned, and a string.
89The string is used to represent a group of objects of the given type.
90It is sometimes useful for a language to use a different string
91in place of the default, even though that language will still
92return a symbol. For example, Java return's includes, but the
93string can be replaced with `Imports'.")
94(make-variable-buffer-local 'semantic-symbol->name-assoc-list)
95
96(defvar semantic-symbol->name-assoc-list-for-type-parts nil
97 "Like `semantic-symbol->name-assoc-list' for type parts.
98Some tags that have children (see `semantic-tag-children-compatibility')
99will want to define the names of classes of tags differently than at
100the top level. For example, in C++, a Function may be called a
101Method. In addition, there may be new types of tags that exist only
102in classes, such as protection labels.")
103(make-variable-buffer-local 'semantic-symbol->name-assoc-list-for-type-parts)
104
105(defvar semantic-case-fold nil
106 "Value for `case-fold-search' when parsing.")
107(make-variable-buffer-local 'semantic-case-fold)
108
109(defvar semantic-expand-nonterminal nil
110 "Function to call for each nonterminal production.
111Return a list of non-terminals derived from the first argument, or nil
112if it does not need to be expanded.
113Languages with compound definitions should use this function to expand
114from one compound symbol into several. For example, in C the definition
115 int a, b;
116is easily parsed into one tag. This function should take this
117compound tag and turn it into two tags, one for A, and the other for B.")
118(make-variable-buffer-local 'semantic-expand-nonterminal)
119
120(defvar semantic--buffer-cache nil
121 "A cache of the fully parsed buffer.
122If no significant changes have been made (based on the state) then
123this is returned instead of re-parsing the buffer.
124
125 DO NOT USE THIS VARIABLE IN PROGRAMS.
126
127If you need a tag list, use `semantic-fetch-tags'. If you need the
128cached values for some reason, chances are you can, add a hook to
129`semantic-after-toplevel-cache-change-hook'.")
130(make-variable-buffer-local 'semantic--buffer-cache)
131(semantic-varalias-obsolete 'semantic-toplevel-bovine-cache
132 'semantic--buffer-cache)
133
134(defvar semantic-unmatched-syntax-cache nil
135 "A cached copy of unmatched syntax tokens.")
136(make-variable-buffer-local 'semantic-unmatched-syntax-cache)
137
138(defvar semantic-unmatched-syntax-cache-check nil
139 "Non nil if the unmatched syntax cache is out of date.
140This is tracked with `semantic-change-function'.")
141(make-variable-buffer-local 'semantic-unmatched-syntax-cache-check)
142
143(defvar semantic-edits-are-safe nil
144 "When non-nil, modifications do not require a reparse.
145This prevents tags from being marked dirty, and it prevents top level
146edits from causing a cache check.
147Use this when writing programs that could cause a full reparse, but
148will not change the tag structure, such as adding or updating
149`top-level' comments.")
150
151(defvar semantic-unmatched-syntax-hook nil
152 "Hooks run when semantic detects syntax not matched in a grammar.
153Each individual piece of syntax (such as a symbol or punctuation
154character) is called with this hook when it doesn't match in the
155grammar, and multiple unmatched syntax elements are not grouped
156together. Each hook is called with one argument, which is a list of
157syntax tokens created by the semantic lexer. Use the functions
158`semantic-lex-token-start', `semantic-lex-token-end' and
159`semantic-lex-token-text' to get information about these tokens. The
160current buffer is the buffer these tokens are derived from.")
161
162(defvar semantic--before-fetch-tags-hook nil
163 "Hooks run before a buffer is parses for tags.
164It is called before any request for tags is made via the function
165`semantic-fetch-tags' by an application.
166If any hook returns a nil value, the cached value is returned
167immediately, even if it is empty.")
168(semantic-varalias-obsolete 'semantic-before-toplevel-bovination-hook
169 'semantic--before-fetch-tags-hook)
170
171(defvar semantic-after-toplevel-bovinate-hook nil
172 "Hooks run after a toplevel parse.
173It is not run if the toplevel parse command is called, and buffer does
174not need to be fully reparsed.
175For language specific hooks, make sure you define this as a local hook.
176
177This hook should not be used any more.
178Use `semantic-after-toplevel-cache-change-hook' instead.")
e6e267fc 179(make-obsolete-variable 'semantic-after-toplevel-bovinate-hook nil "23.2")
d3d82e7b
CY
180
181(defvar semantic-after-toplevel-cache-change-hook nil
182 "Hooks run after the buffer tag list has changed.
183This list will change when a buffer is reparsed, or when the tag list
184in a buffer is cleared. It is *NOT* called if the current tag list is
185partially reparsed.
186
187Hook functions must take one argument, which is the new list of tags
188associated with this buffer.
189
190For language specific hooks, make sure you define this as a local hook.")
191
192(defvar semantic-before-toplevel-cache-flush-hook nil
193 "Hooks run before the toplevel tag cache is flushed.
194For language specific hooks, make sure you define this as a local
195hook. This hook is called before a corresponding
196`semantic-after-toplevel-cache-change-hook' which is also called
197during a flush when the cache is given a new value of nil.")
198
199(defcustom semantic-dump-parse nil
200 "When non-nil, dump parsing information."
201 :group 'semantic
202 :type 'boolean)
203
204(defvar semantic-parser-name "LL"
205 "Optional name of the parser used to parse input stream.")
206(make-variable-buffer-local 'semantic-parser-name)
8bf997ef
CY
207
208(defvar semantic--completion-cache nil
209 "Internal variable used by `semantic-complete-symbol'.")
210(make-variable-buffer-local 'semantic--completion-cache)
d3d82e7b
CY
211\f
212;;; Parse tree state management API
213;;
214(defvar semantic-parse-tree-state 'needs-rebuild
215 "State of the current parse tree.")
216(make-variable-buffer-local 'semantic-parse-tree-state)
217
218(defmacro semantic-parse-tree-unparseable ()
219 "Indicate that the current buffer is unparseable.
220It is also true that the parse tree will need either updating or
221a rebuild. This state will be changed when the user edits the buffer."
222 `(setq semantic-parse-tree-state 'unparseable))
223
224(defmacro semantic-parse-tree-unparseable-p ()
225 "Return non-nil if the current buffer has been marked unparseable."
226 `(eq semantic-parse-tree-state 'unparseable))
227
228(defmacro semantic-parse-tree-set-needs-update ()
229 "Indicate that the current parse tree needs to be updated.
230The parse tree can be updated by `semantic-parse-changes'."
231 `(setq semantic-parse-tree-state 'needs-update))
232
233(defmacro semantic-parse-tree-needs-update-p ()
234 "Return non-nil if the current parse tree needs to be updated."
235 `(eq semantic-parse-tree-state 'needs-update))
236
237(defmacro semantic-parse-tree-set-needs-rebuild ()
238 "Indicate that the current parse tree needs to be rebuilt.
239The parse tree must be rebuilt by `semantic-parse-region'."
240 `(setq semantic-parse-tree-state 'needs-rebuild))
241
242(defmacro semantic-parse-tree-needs-rebuild-p ()
243 "Return non-nil if the current parse tree needs to be rebuilt."
244 `(eq semantic-parse-tree-state 'needs-rebuild))
245
246(defmacro semantic-parse-tree-set-up-to-date ()
247 "Indicate that the current parse tree is up to date."
248 `(setq semantic-parse-tree-state nil))
249
250(defmacro semantic-parse-tree-up-to-date-p ()
251 "Return non-nil if the current parse tree is up to date."
252 `(null semantic-parse-tree-state))
253
254;;; Interfacing with the system
255;;
256(defcustom semantic-inhibit-functions nil
257 "List of functions to call with no arguments before Semantic is setup.
258If any of these functions returns non-nil, the current buffer is not
259setup to use Semantic."
260 :group 'semantic
261 :type 'hook)
262
82481502
CY
263(defcustom semantic-new-buffer-setup-functions
264 '((js-mode . wisent-javascript-setup-parser)
265 (java-mode . wisent-java-default-setup)
266 (scheme-mode . semantic-default-scheme-setup)
267 (c-mode . semantic-default-c-setup)
268 (c++-mode . semantic-default-c-setup)
269 (html-mode . semantic-default-html-setup)
270 (srecode-template-mode . srecode-template-setup-parser)
271 (makefile-automake-mode . semantic-default-make-setup)
272 (makefile-gmake-mode . semantic-default-make-setup)
273 (makefile-makepp-mode . semantic-default-make-setup)
274 (makefile-bsdmake-mode . semantic-default-make-setup)
275 (makefile-imake-mode . semantic-default-make-setup)
276 (makefile-mode . semantic-default-make-setup))
277 "Alist of functions to call to set up Semantic parsing in the buffer.
278Each element has the form (MODE . FN), where MODE is a value of
279`major-mode' for the buffer and FN is the corresponding function
280to call, with no arguments, to set up the parser.
281
282These functions are called by `semantic-new-buffer-fcn', before
283`semantic-inhibit-functions'."
284 :group 'semantic
285 :type '(alist :key-type symbol :value-type function))
286
b82525f2
CY
287(defvar semantic-init-hook nil
288 "Hook run when a buffer is initialized with a parsing table.")
d3d82e7b 289
b82525f2
CY
290(defvar semantic-init-mode-hook nil
291 "Hook run when a buffer of a particular mode is initialized.")
292(make-variable-buffer-local 'semantic-init-mode-hook)
d3d82e7b 293
b82525f2
CY
294(defvar semantic-init-db-hook nil
295 "Hook run when a buffer is initialized with a parsing table for DBs.
d3d82e7b
CY
296This hook is for database functions which intend to swap in a tag table.
297This guarantees that the DB will go before other modes that require
298a parse of the buffer.")
299
1ac9ebc8
CY
300(semantic-varalias-obsolete 'semantic-init-hooks
301 'semantic-init-hook)
302(semantic-varalias-obsolete 'semantic-init-mode-hooks
303 'semantic-init-mode-hook)
304(semantic-varalias-obsolete 'semantic-init-db-hooks
305 'semantic-init-db-hook)
b82525f2 306
d3d82e7b
CY
307(defvar semantic-new-buffer-fcn-was-run nil
308 "Non nil after `semantic-new-buffer-fcn' has been executed.")
309(make-variable-buffer-local 'semantic-new-buffer-fcn-was-run)
310
311(defsubst semantic-active-p ()
312 "Return non-nil if the current buffer was set up for parsing."
313 semantic-new-buffer-fcn-was-run)
314
315(defsubst semantic--umatched-syntax-needs-refresh-p ()
316 "Return non-nil if the unmatched syntax cache needs a refresh.
317That is if it is dirty or if the current parse tree isn't up to date."
318 (or semantic-unmatched-syntax-cache-check
319 (not (semantic-parse-tree-up-to-date-p))))
320
321(defun semantic-new-buffer-fcn ()
322 "Setup the current buffer to use Semantic.
323If the major mode is ready for Semantic, and no
324`semantic-inhibit-functions' disabled it, the current buffer is setup
325to use Semantic, and `semantic-init-hook' is run."
82481502
CY
326 ;; In upstream Semantic, the parser setup functions are called from
327 ;; mode hooks. In the version bundled with Emacs, we do it here.
328 (let ((entry (assq major-mode semantic-new-buffer-setup-functions)))
329 (when entry
330 (funcall (cdr entry))))
d3d82e7b
CY
331 ;; Do stuff if semantic was activated by a mode hook in this buffer,
332 ;; and not afterwards disabled.
333 (when (and semantic--parse-table
334 (not (semantic-active-p))
335 (not (run-hook-with-args-until-success
336 'semantic-inhibit-functions)))
337 ;; Make sure that if this buffer is cloned, our tags and overlays
338 ;; don't go along for the ride.
339 (add-hook 'clone-indirect-buffer-hook 'semantic-clear-toplevel-cache
340 nil t)
341 ;; Specify that this function has done it's work. At this point
342 ;; we can consider that semantic is active in this buffer.
343 (setq semantic-new-buffer-fcn-was-run t)
344 ;; Here are some buffer local variables we can initialize ourselves
345 ;; of a mode does not choose to do so.
346 (semantic-lex-init)
347 ;; Force this buffer to have its cache refreshed.
348 (semantic-clear-toplevel-cache)
349 ;; Call DB hooks before regular init hooks
b82525f2 350 (run-hooks 'semantic-init-db-hook)
d3d82e7b 351 ;; Set up semantic modes
b82525f2 352 (run-hooks 'semantic-init-hook)
d3d82e7b 353 ;; Set up major-mode specific semantic modes
b82525f2 354 (run-hooks 'semantic-init-mode-hook)))
d3d82e7b
CY
355
356(defun semantic-fetch-tags-fast ()
357 "For use in a hook. When only a partial reparse is needed, reparse."
358 (condition-case nil
359 (if (semantic-parse-tree-needs-update-p)
360 (semantic-fetch-tags))
361 (error nil))
362 semantic--buffer-cache)
d3d82e7b
CY
363\f
364;;; Parsing Commands
365;;
366(eval-when-compile
367 (condition-case nil (require 'pp) (error nil)))
368
369(defvar semantic-edebug nil
370 "When non-nil, activate the interactive parsing debugger.
371Do not set this yourself. Call `semantic-debug'.")
372
373(defun semantic-elapsed-time (start end)
374 "Copied from elp.el. Was elp-elapsed-time.
375Argument START and END bound the time being calculated."
376 (+ (* (- (car end) (car start)) 65536.0)
377 (- (car (cdr end)) (car (cdr start)))
378 (/ (- (car (cdr (cdr end))) (car (cdr (cdr start)))) 1000000.0)))
379
380(defun bovinate (&optional clear)
381 "Parse the current buffer. Show output in a temp buffer.
382Optional argument CLEAR will clear the cache before parsing.
383If CLEAR is negative, it will do a full reparse, and also not display
384the output buffer."
385 (interactive "P")
386 (if clear (semantic-clear-toplevel-cache))
387 (if (eq clear '-) (setq clear -1))
388 (let* ((start (current-time))
389 (out (semantic-fetch-tags))
390 (end (current-time)))
391 (message "Retrieving tags took %.2f seconds."
392 (semantic-elapsed-time start end))
393 (when (or (null clear) (not (listp clear)))
394 (pop-to-buffer "*Parser Output*")
395 (require 'pp)
396 (erase-buffer)
397 (insert (pp-to-string out))
398 (goto-char (point-min)))))
399\f
400;;; Functions of the parser plug-in API
401;;
402;; Overload these functions to create new types of parsers.
403;;
404(define-overloadable-function semantic-parse-stream (stream nonterminal)
405 "Parse STREAM, starting at the first NONTERMINAL rule.
406For bovine and wisent based parsers, STREAM is from the output of
407`semantic-lex', and NONTERMINAL is a rule in the apropriate language
408specific rules file.
409The default parser table used for bovine or wisent based parsers is
410`semantic--parse-table'.
411
412Must return a list: (STREAM TAGS) where STREAM is the unused elements
413from STREAM, and TAGS is the list of semantic tags found, usually only
414one tag is returned with the exception of compound statements")
415
416(define-overloadable-function semantic-parse-changes ()
417 "Reparse changes in the current buffer.
418The list of changes are tracked as a series of overlays in the buffer.
419When overloading this function, use `semantic-changes-in-region' to
420analyze.")
421
422(define-overloadable-function semantic-parse-region
423 (start end &optional nonterminal depth returnonerror)
424 "Parse the area between START and END, and return any tags found.
425If END needs to be extended due to a lexical token being too large, it
426will be silently ignored.
427
428Optional arguments:
429NONTERMINAL is the rule to start parsing at.
430DEPTH specifies the lexical depth to decend for parser that use
431lexical analysis as their first step.
432RETURNONERROR specifies that parsing should stop on the first
433unmatched syntax encountered. When nil, parsing skips the syntax,
434adding it to the unmatched syntax cache.
435
436Must return a list of semantic tags wich have been cooked
437\(repositioned properly) but which DO NOT HAVE OVERLAYS associated
438with them. When overloading this function, use `semantic--tag-expand'
439to cook raw tags.")
440
441(defun semantic-parse-region-default
442 (start end &optional nonterminal depth returnonerror)
443 "Parse the area between START and END, and return any tags found.
444If END needs to be extended due to a lexical token being too large, it
445will be silently ignored.
446Optional arguments:
447NONTERMINAL is the rule to start parsing at if it is known.
448DEPTH specifies the lexical depth to scan.
449RETURNONERROR specifies that parsing should end when encountering
450unterminated syntax."
451 (when (or (null semantic--parse-table) (eq semantic--parse-table t))
452 ;; If there is no table, or it was set to t, then we are here by
453 ;; some other mistake. Do not throw an error deep in the parser.
454 (error "No support found to parse buffer %S" (buffer-name)))
455 (save-restriction
456 (widen)
457 (when (or (< end start) (> end (point-max)))
458 (error "Invalid parse region bounds %S, %S" start end))
459 (nreverse
460 (semantic-repeat-parse-whole-stream
461 (or (cdr (assq start semantic-lex-block-streams))
462 (semantic-lex start end depth))
463 nonterminal returnonerror))))
464\f
465;;; Parsing functions
466;;
467(defun semantic-set-unmatched-syntax-cache (unmatched-syntax)
468 "Set the unmatched syntax cache.
469Argument UNMATCHED-SYNTAX is the syntax to set into the cache."
470 ;; This function is not actually called by the main parse loop.
471 ;; This is intended for use by semanticdb.
472 (setq semantic-unmatched-syntax-cache unmatched-syntax
473 semantic-unmatched-syntax-cache-check nil)
474 ;; Refresh the display of unmatched syntax tokens if enabled
475 (run-hook-with-args 'semantic-unmatched-syntax-hook
476 semantic-unmatched-syntax-cache))
477
478(defun semantic-clear-unmatched-syntax-cache ()
479 "Clear the cache of unmatched syntax tokens."
480 (setq semantic-unmatched-syntax-cache nil
481 semantic-unmatched-syntax-cache-check t))
482
483(defun semantic-unmatched-syntax-tokens ()
484 "Return the list of unmatched syntax tokens."
485 ;; If the cache need refresh then do a full re-parse.
486 (if (semantic--umatched-syntax-needs-refresh-p)
487 ;; To avoid a recursive call, temporarily disable
488 ;; `semantic-unmatched-syntax-hook'.
489 (let (semantic-unmatched-syntax-hook)
490 (condition-case nil
491 (progn
492 (semantic-clear-toplevel-cache)
493 (semantic-fetch-tags))
494 (quit
495 (message "semantic-unmatched-syntax-tokens:\
496 parsing of buffer canceled"))
497 )))
498 semantic-unmatched-syntax-cache)
499
500(defun semantic-clear-toplevel-cache ()
501 "Clear the toplevel tag cache for the current buffer.
502Clearing the cache will force a complete reparse next time a tag list
503is requested."
504 (interactive)
505 (run-hooks 'semantic-before-toplevel-cache-flush-hook)
506 (setq semantic--buffer-cache nil)
507 (semantic-clear-unmatched-syntax-cache)
508 (semantic-clear-parser-warnings)
509 ;; Nuke all semantic overlays. This is faster than deleting based
510 ;; on our data structure.
511 (let ((l (semantic-overlay-lists)))
512 (mapc 'semantic-delete-overlay-maybe (car l))
513 (mapc 'semantic-delete-overlay-maybe (cdr l))
514 )
515 (semantic-parse-tree-set-needs-rebuild)
516 ;; Remove this hook which tracks if a buffer is up to date or not.
517 (remove-hook 'after-change-functions 'semantic-change-function t)
518 ;; Old model. Delete someday.
519 ;;(run-hooks 'semantic-after-toplevel-bovinate-hook)
520
521 (run-hook-with-args 'semantic-after-toplevel-cache-change-hook
522 semantic--buffer-cache)
8bf997ef
CY
523
524 (setq semantic--completion-cache nil))
d3d82e7b
CY
525
526(defvar semantic-bovinate-nonterminal-check-obarray)
527
528(defun semantic--set-buffer-cache (tagtable)
529 "Set the toplevel cache cache to TAGTABLE."
530 (setq semantic--buffer-cache tagtable
06511291
CY
531 semantic-unmatched-syntax-cache-check nil)
532 ;; This is specific to the bovine parser.
533 (set (make-local-variable 'semantic-bovinate-nonterminal-check-obarray)
534 nil)
d3d82e7b
CY
535 (semantic-parse-tree-set-up-to-date)
536 (semantic-make-local-hook 'after-change-functions)
537 (add-hook 'after-change-functions 'semantic-change-function nil t)
538 (run-hook-with-args 'semantic-after-toplevel-cache-change-hook
539 semantic--buffer-cache)
8bf997ef 540 (setq semantic--completion-cache nil)
d3d82e7b
CY
541 ;; Refresh the display of unmatched syntax tokens if enabled
542 (run-hook-with-args 'semantic-unmatched-syntax-hook
543 semantic-unmatched-syntax-cache)
544 ;; Old Semantic 1.3 hook API. Maybe useful forever?
545 (run-hooks 'semantic-after-toplevel-bovinate-hook)
546 )
547
548(defvar semantic-working-type 'percent
549 "*The type of working message to use when parsing.
550'percent means we are doing a linear parse through the buffer.
551'dynamic means we are reparsing specific tags.")
552(semantic-varalias-obsolete 'semantic-bovination-working-type
553 'semantic-working-type)
554
555(defvar semantic-minimum-working-buffer-size (* 1024 5)
556 "*The minimum size of a buffer before working messages are displayed.
557Buffers smaller than will parse silently.
bd2afec2 558Buffers larger than this will display the working progress bar.")
d3d82e7b
CY
559
560(defsubst semantic-parser-working-message (&optional arg)
561 "Return the message string displayed while parsing.
562If optional argument ARG is non-nil it is appended to the message
563string."
17e1f4bc
CY
564 (concat "Parsing"
565 (if arg (format " %s" arg))
566 (if semantic-parser-name (format " (%s)" semantic-parser-name))
567 "..."))
d3d82e7b
CY
568\f
569;;; Application Parser Entry Points
570;;
571;; The best way to call the parser from programs is via
572;; `semantic-fetch-tags'. This, in turn, uses other internal
573;; API functions which plug-in parsers can take advantage of.
574
575(defun semantic-fetch-tags ()
576 "Fetch semantic tags from the current buffer.
577If the buffer cache is up to date, return that.
578If the buffer cache is out of date, attempt an incremental reparse.
579If the buffer has not been parsed before, or if the incremental reparse
580fails, then parse the entire buffer.
bd2afec2 581If a lexical error had been previously discovered and the buffer
d3d82e7b
CY
582was marked unparseable, then do nothing, and return the cache."
583 (and
584 ;; Is this a semantic enabled buffer?
585 (semantic-active-p)
586 ;; Application hooks say the buffer is safe for parsing
587 (run-hook-with-args-until-failure
588 'semantic-before-toplevel-bovination-hook)
589 (run-hook-with-args-until-failure
590 'semantic--before-fetch-tags-hook)
591 ;; If the buffer was previously marked unparseable,
592 ;; then don't waste our time.
593 (not (semantic-parse-tree-unparseable-p))
594 ;; The parse tree actually needs to be refreshed
595 (not (semantic-parse-tree-up-to-date-p))
596 ;; So do it!
597 (let* ((gc-cons-threshold (max gc-cons-threshold 10000000))
598 (semantic-lex-block-streams nil)
599 (res nil))
600 (garbage-collect)
601 (cond
602
603;;;; Try the incremental parser to do a fast update.
604 ((semantic-parse-tree-needs-update-p)
605 (setq res (semantic-parse-changes))
606 (if (semantic-parse-tree-needs-rebuild-p)
607 ;; If the partial reparse fails, jump to a full reparse.
608 (semantic-fetch-tags)
609 ;; Clear the cache of unmatched syntax tokens
610 ;;
611 ;; NOTE TO SELF:
612 ;;
613 ;; Move this into the incremental parser. This is a bug.
614 ;;
615 (semantic-clear-unmatched-syntax-cache)
616 (run-hook-with-args ;; Let hooks know the updated tags
617 'semantic-after-partial-cache-change-hook res))
8bf997ef 618 (setq semantic--completion-cache nil))
d3d82e7b
CY
619
620;;;; Parse the whole system.
621 ((semantic-parse-tree-needs-rebuild-p)
d3d82e7b
CY
622 ;; Use Emacs' built-in progress-reporter
623 (let ((semantic--progress-reporter
624 (and (>= (point-max) semantic-minimum-working-buffer-size)
625 (eq semantic-working-type 'percent)
626 (make-progress-reporter
627 (semantic-parser-working-message (buffer-name))
628 0 100))))
629 (setq res (semantic-parse-region (point-min) (point-max)))
59aec83e
CY
630 (if semantic--progress-reporter
631 (progress-reporter-done semantic--progress-reporter)))
d3d82e7b
CY
632
633 ;; Clear the caches when we see there were no errors.
634 ;; But preserve the unmatched syntax cache and warnings!
635 (let (semantic-unmatched-syntax-cache
636 semantic-unmatched-syntax-cache-check
637 semantic-parser-warnings)
638 (semantic-clear-toplevel-cache))
639 ;; Set up the new overlays
640 (semantic--tag-link-list-to-buffer res)
641 ;; Set up the cache with the new results
642 (semantic--set-buffer-cache res)
643 ))))
644
645 ;; Always return the current parse tree.
646 semantic--buffer-cache)
647
648(defun semantic-refresh-tags-safe ()
649 "Refreshes the current buffer's tags safely.
650
651Return non-nil if the refresh was successful.
652Return nil if there is some sort of syntax error preventing a reparse.
653
654Does nothing if the current buffer doesn't need reparsing."
655
656 ;; These checks actually occur in `semantic-fetch-tags', but if we
657 ;; do them here, then all the bovination hooks are not run, and
658 ;; we save lots of time.
659 (cond
660 ;; If the buffer was previously marked unparseable,
661 ;; then don't waste our time.
662 ((semantic-parse-tree-unparseable-p)
663 nil)
664 ;; The parse tree is already ok.
665 ((semantic-parse-tree-up-to-date-p)
666 t)
667 (t
668 (let* ((inhibit-quit nil)
669 (lexically-safe t)
670 )
671
672 (unwind-protect
673 ;; Perform the parsing.
674 (progn
675 (when (semantic-lex-catch-errors safe-refresh
676 (save-excursion (semantic-fetch-tags))
677 nil)
678 ;; If we are here, it is because the lexical step failed,
679 ;; proably due to unterminated lists or something like that.
680
681 ;; We do nothing, and just wait for the next idle timer
682 ;; to go off. In the meantime, remember this, and make sure
683 ;; no other idle services can get executed.
684 (setq lexically-safe nil))
685 )
686 )
687 ;; Return if we are lexically safe
688 lexically-safe))))
689
690(defun semantic-bovinate-toplevel (&optional ignored)
691 "Backward Compatibility Function."
692 (semantic-fetch-tags))
e6e267fc 693(make-obsolete 'semantic-bovinate-toplevel 'semantic-fetch-tags "23.2")
d3d82e7b
CY
694
695;; Another approach is to let Emacs call the parser on idle time, when
696;; needed, use `semantic-fetch-available-tags' to only retrieve
697;; available tags, and setup the `semantic-after-*-hook' hooks to
698;; synchronize with new tags when they become available.
699
700(defsubst semantic-fetch-available-tags ()
701 "Fetch available semantic tags from the current buffer.
702That is, return tags currently in the cache without parsing the
703current buffer.
704Parse operations happen asynchronously when needed on Emacs idle time.
705Use the `semantic-after-toplevel-cache-change-hook' and
706`semantic-after-partial-cache-change-hook' hooks to synchronize with
707new tags when they become available."
708 semantic--buffer-cache)
709\f
710;;; Iterative parser helper function
711;;
712;; Iterative parsers are better than rule-based iterative functions
713;; in that they can handle obscure errors more cleanly.
714;;
715;; `semantic-repeat-parse-whole-stream' abstracts this action for
716;; other parser centric routines.
717;;
718(defun semantic-repeat-parse-whole-stream
719 (stream nonterm &optional returnonerror)
720 "Iteratively parse the entire stream STREAM starting with NONTERM.
721Optional argument RETURNONERROR indicates that the parser should exit
722with the current results on a parse error.
723This function returns semantic tags without overlays."
724 (let ((result nil)
725 (case-fold-search semantic-case-fold)
726 nontermsym tag)
727 (while stream
728 (setq nontermsym (semantic-parse-stream stream nonterm)
729 tag (car (cdr nontermsym)))
730 (if (not nontermsym)
731 (error "Parse error @ %d" (car (cdr (car stream)))))
732 (if (eq (car nontermsym) stream)
733 (error "Parser error: Infinite loop?"))
734 (if tag
735 (if (car tag)
736 (setq tag (mapcar
737 #'(lambda (tag)
738 ;; Set the 'reparse-symbol property to
739 ;; NONTERM unless it was already setup
740 ;; by a tag expander
741 (or (semantic--tag-get-property
742 tag 'reparse-symbol)
743 (semantic--tag-put-property
744 tag 'reparse-symbol nonterm))
745 tag)
746 (semantic--tag-expand tag))
747 result (append tag result))
748 ;; No error in this case, a purposeful nil means don't
749 ;; store anything.
750 )
751 (if returnonerror
752 (setq stream nil)
753 ;; The current item in the stream didn't match, so add it to
754 ;; the list of syntax items which didn't match.
755 (setq semantic-unmatched-syntax-cache
756 (cons (car stream) semantic-unmatched-syntax-cache))
757 ))
758 ;; Designated to ignore.
759 (setq stream (car nontermsym))
760 (if stream
d3d82e7b
CY
761 ;; Use Emacs' built-in progress reporter:
762 (and (boundp 'semantic--progress-reporter)
763 semantic--progress-reporter
aa8724ae 764 (eq semantic-working-type 'percent)
d3d82e7b
CY
765 (progress-reporter-update
766 semantic--progress-reporter
767 (/ (* 100 (semantic-lex-token-start (car stream)))
768 (point-max))))))
769 result))
770\f
771;;; Parsing Warnings:
772;;
773;; Parsing a buffer may result in non-critical things that we should
774;; alert the user to without interrupting the normal flow.
775;;
776;; Any parser can use this API to provide a list of warnings during a
777;; parse which a user may want to investigate.
778(defvar semantic-parser-warnings nil
779 "A list of parser warnings since the last full reparse.")
780(make-variable-buffer-local 'semantic-parser-warnings)
781
782(defun semantic-clear-parser-warnings ()
783 "Clear the current list of parser warnings for this buffer."
784 (setq semantic-parser-warnings nil))
785
786(defun semantic-push-parser-warning (warning start end)
787 "Add a parser WARNING that covers text from START to END."
788 (setq semantic-parser-warnings
789 (cons (cons warning (cons start end))
790 semantic-parser-warnings)))
791
792(defun semantic-dump-parser-warnings ()
793 "Dump any parser warnings."
794 (interactive)
795 (if semantic-parser-warnings
796 (let ((pw semantic-parser-warnings))
797 (pop-to-buffer "*Parser Warnings*")
798 (require 'pp)
799 (erase-buffer)
800 (insert (pp-to-string pw))
801 (goto-char (point-min)))
802 (message "No parser warnings.")))
803
804
805\f
806;;; Compatibility:
807;;
808;; Semantic 1.x parser action helper functions, used by some parsers.
809;; Please move away from these functions, and try using semantic 2.x
810;; interfaces instead.
811;;
812(defsubst semantic-bovinate-region-until-error
813 (start end nonterm &optional depth)
814 "NOTE: Use `semantic-parse-region' instead.
815
816Bovinate between START and END starting with NONTERM.
817Optional DEPTH specifies how many levels of parenthesis to enter.
818This command will parse until an error is encountered, and return
819the list of everything found until that moment.
820This is meant for finding variable definitions at the beginning of
821code blocks in methods. If `bovine-inner-scope' can also support
822commands, use `semantic-bovinate-from-nonterminal-full'."
823 (semantic-parse-region start end nonterm depth t))
824(make-obsolete 'semantic-bovinate-region-until-error
e6e267fc 825 'semantic-parse-region "23.2")
d3d82e7b
CY
826
827(defsubst semantic-bovinate-from-nonterminal
828 (start end nonterm &optional depth length)
829 "Bovinate from within a nonterminal lambda from START to END.
830Argument NONTERM is the nonterminal symbol to start with.
831Optional argument DEPTH is the depth of lists to dive into. When used
832in a `lambda' of a MATCH-LIST, there is no need to include a START and
833END part.
834Optional argument LENGTH specifies we are only interested in LENGTH
835tokens."
836 (car-safe (cdr (semantic-parse-stream
837 (semantic-lex start end (or depth 1) length)
838 nonterm))))
839
840(defsubst semantic-bovinate-from-nonterminal-full
841 (start end nonterm &optional depth)
842 "NOTE: Use `semantic-parse-region' instead.
843
844Bovinate from within a nonterminal lambda from START to END.
845Iterates until all the space between START and END is exhausted.
846Argument NONTERM is the nonterminal symbol to start with.
847If NONTERM is nil, use `bovine-block-toplevel'.
848Optional argument DEPTH is the depth of lists to dive into.
849When used in a `lambda' of a MATCH-LIST, there is no need to include
850a START and END part."
851 (semantic-parse-region start end nonterm (or depth 1)))
852(make-obsolete 'semantic-bovinate-from-nonterminal-full
e6e267fc 853 'semantic-parse-region "23.2")
d3d82e7b 854
b82525f2
CY
855;;; User interface
856
8bf997ef
CY
857(defun semantic-force-refresh ()
858 "Force a full refresh of the current buffer's tags.
859Throw away all the old tags, and recreate the tag database."
860 (interactive)
861 (semantic-clear-toplevel-cache)
715f35a5
CY
862 (semantic-fetch-tags)
863 (message "Buffer reparsed."))
8bf997ef
CY
864
865(defvar semantic-mode-map
715f35a5 866 (let ((map (make-sparse-keymap)))
8bf997ef 867 ;; Key bindings:
8bf997ef
CY
868 ;; (define-key km "f" 'senator-search-set-tag-class-filter)
869 ;; (define-key km "i" 'senator-isearch-toggle-semantic-mode)
870 (define-key map "\C-c,j" 'semantic-complete-jump-local)
871 (define-key map "\C-c,J" 'semantic-complete-jump)
872 (define-key map "\C-c,g" 'semantic-symref-symbol)
873 (define-key map "\C-c,G" 'semantic-symref)
874 (define-key map "\C-c,p" 'senator-previous-tag)
875 (define-key map "\C-c,n" 'senator-next-tag)
876 (define-key map "\C-c,u" 'senator-go-to-up-reference)
877 (define-key map "\C-c, " 'semantic-complete-analyze-inline)
878 (define-key map "\C-c,\C-w" 'senator-kill-tag)
879 (define-key map "\C-c,\M-w" 'senator-copy-tag)
880 (define-key map "\C-c,\C-y" 'senator-yank-tag)
881 (define-key map "\C-c,r" 'senator-copy-tag-to-register)
882 (define-key map [?\C-c ?, up] 'senator-transpose-tags-up)
883 (define-key map [?\C-c ?, down] 'senator-transpose-tags-down)
884 (define-key map "\C-c,l" 'semantic-analyze-possible-completions)
715f35a5
CY
885 ;; This hack avoids showing the CEDET menu twice if ede-minor-mode
886 ;; and Semantic are both enabled. Is there a better way?
887 (define-key map [menu-bar cedet-menu]
888 (list 'menu-item "Development" cedet-menu-map
889 :enable (quote (not (bound-and-true-p global-ede-mode)))))
8bf997ef
CY
890 ;; (define-key km "-" 'senator-fold-tag)
891 ;; (define-key km "+" 'senator-unfold-tag)
892 map))
893
715f35a5
CY
894;; Activate the Semantic items in cedet-menu-map
895(let ((navigate-menu (make-sparse-keymap "Navigate Tags"))
896 (edit-menu (make-sparse-keymap "Edit Tags")))
897
898 ;; Edit Tags submenu:
899 (define-key edit-menu [semantic-analyze-possible-completions]
900 '(menu-item "List Completions" semantic-analyze-possible-completions
901 :help "Display a list of completions for the tag at point"))
902 (define-key edit-menu [semantic-complete-analyze-inline]
903 '(menu-item "Complete Tag Inline" semantic-complete-analyze-inline
904 :help "Display inline completion for the tag at point"))
905 (define-key edit-menu [semantic-completion-separator]
906 '("--"))
907 (define-key edit-menu [senator-transpose-tags-down]
908 '(menu-item "Transpose Tags Down" senator-transpose-tags-down
909 :active (semantic-current-tag)
910 :help "Transpose the current tag and the next tag"))
911 (define-key edit-menu [senator-transpose-tags-up]
912 '(menu-item "Transpose Tags Up" senator-transpose-tags-up
913 :active (semantic-current-tag)
914 :help "Transpose the current tag and the previous tag"))
915 (define-key edit-menu [semantic-edit-separator]
916 '("--"))
917 (define-key edit-menu [senator-yank-tag]
918 '(menu-item "Yank Tag" senator-yank-tag
919 :active (not (ring-empty-p senator-tag-ring))
920 :help "Yank the head of the tag ring into the buffer"))
921 (define-key edit-menu [senator-copy-tag-to-register]
922 '(menu-item "Copy Tag To Register" senator-copy-tag-to-register
923 :active (semantic-current-tag)
924 :help "Yank the head of the tag ring into the buffer"))
925 (define-key edit-menu [senator-copy-tag]
926 '(menu-item "Copy Tag" senator-copy-tag
927 :active (semantic-current-tag)
928 :help "Copy the current tag to the tag ring"))
929 (define-key edit-menu [senator-kill-tag]
930 '(menu-item "Kill Tag" senator-kill-tag
931 :active (semantic-current-tag)
932 :help "Kill the current tag, and copy it to the tag ring"))
933
934 ;; Navigate Tags submenu:
935 (define-key navigate-menu [senator-narrow-to-defun]
936 '(menu-item "Narrow to Tag" senator-narrow-to-defun
937 :active (semantic-current-tag)
938 :help "Narrow the buffer to the bounds of the current tag"))
939 (define-key navigate-menu [semantic-narrow-to-defun-separator]
940 '("--"))
941 (define-key navigate-menu [semantic-symref-symbol]
942 '(menu-item "Find Tag References..." semantic-symref-symbol
943 :help "Read a tag and list the references to it"))
944 (define-key navigate-menu [semantic-complete-jump]
945 '(menu-item "Find Tag Globally..." semantic-complete-jump
946 :help "Read a tag name and find it in the current project"))
947 (define-key navigate-menu [semantic-complete-jump-local]
948 '(menu-item "Find Tag in This Buffer..." semantic-complete-jump-local
949 :help "Read a tag name and find it in this buffer"))
950 (define-key navigate-menu [semantic-navigation-separator]
951 '("--"))
952 (define-key navigate-menu [senator-go-to-up-reference]
953 '(menu-item "Parent Tag" senator-go-to-up-reference
954 :help "Navigate up one reference by tag."))
955 (define-key navigate-menu [senator-next-tag]
956 '(menu-item "Next Tag" senator-next-tag
957 :help "Go to the next tag"))
958 (define-key navigate-menu [senator-previous-tag]
959 '(menu-item "Previous Tag" senator-previous-tag
960 :help "Go to the previous tag"))
961
962 ;; Top level menu items:
963 (define-key cedet-menu-map [semantic-force-refresh]
964 '(menu-item "Reparse Buffer" semantic-force-refresh
a2095e2e
CY
965 :help "Force a full reparse of the current buffer."
966 :visible semantic-mode))
715f35a5 967 (define-key cedet-menu-map [semantic-edit-menu]
a2095e2e
CY
968 `(menu-item "Edit Tags" ,edit-menu
969 :visible semantic-mode))
715f35a5 970 (define-key cedet-menu-map [navigate-menu]
a2095e2e
CY
971 `(menu-item "Navigate Tags" ,navigate-menu
972 :visible semantic-mode))
715f35a5
CY
973 (define-key cedet-menu-map [semantic-options-separator]
974 '("--"))
975 (define-key cedet-menu-map [global-semantic-highlight-func-mode]
a2095e2e
CY
976 '(menu-item "Highlight Current Function" global-semantic-highlight-func-mode
977 :help "Highlight the tag at point"
978 :visible semantic-mode
979 :button (:toggle . global-semantic-highlight-func-mode)))
715f35a5 980 (define-key cedet-menu-map [global-semantic-decoration-mode]
a2095e2e
CY
981 '(menu-item "Decorate Tags" global-semantic-decoration-mode
982 :help "Decorate tags based on tag attributes"
983 :visible semantic-mode
984 :button (:toggle . (bound-and-true-p
985 global-semantic-decoration-mode))))
715f35a5 986 (define-key cedet-menu-map [global-semantic-idle-completions-mode]
a2095e2e
CY
987 '(menu-item "Show Tag Completions" global-semantic-idle-completions-mode
988 :help "Show tag completions when idle"
989 :visible semantic-mode
990 :button (:toggle . global-semantic-idle-completions-mode)))
715f35a5 991 (define-key cedet-menu-map [global-semantic-idle-summary-mode]
a2095e2e
CY
992 '(menu-item "Show Tag Summaries" global-semantic-idle-summary-mode
993 :help "Show tag summaries when idle"
994 :visible semantic-mode
995 :button (:toggle . global-semantic-idle-summary-mode)))
715f35a5
CY
996 (define-key cedet-menu-map [global-semanticdb-minor-mode]
997 '(menu-item "Semantic Database" global-semanticdb-minor-mode
998 :help "Store tag information in a database"
a2095e2e
CY
999 :visible semantic-mode
1000 :button (:toggle . global-semanticdb-minor-mode)))
715f35a5 1001 (define-key cedet-menu-map [global-semantic-idle-scheduler-mode]
a2095e2e
CY
1002 '(menu-item "Reparse When Idle" global-semantic-idle-scheduler-mode
1003 :help "Keep a buffer's parse tree up to date when idle"
1004 :visible semantic-mode
1005 :button (:toggle . global-semantic-idle-scheduler-mode)))
715f35a5
CY
1006 (define-key cedet-menu-map [ede-menu-separator] 'undefined)
1007 (define-key cedet-menu-map [cedet-menu-separator] 'undefined)
1008 (define-key cedet-menu-map [semantic-menu-separator] '("--")))
1009
b82525f2 1010;; The `semantic-mode' command, in conjuction with the
715f35a5
CY
1011;; `semantic-default-submodes' variable, toggles Semantic's various
1012;; auxilliary minor modes.
b82525f2
CY
1013
1014(defvar semantic-load-system-cache-loaded nil
1015 "Non nil when the Semantic system caches have been loaded.
1016Prevent this load system from loading files in twice.")
1017
1018(defconst semantic-submode-list
1019 '(global-semantic-highlight-func-mode
1020 global-semantic-decoration-mode
1021 global-semantic-stickyfunc-mode
1022 global-semantic-idle-completions-mode
1023 global-semantic-idle-scheduler-mode
1024 global-semanticdb-minor-mode
1025 global-semantic-idle-summary-mode
1026 global-semantic-mru-bookmark-mode)
bd2afec2 1027 "List of auxiliary minor modes in the Semantic package.")
b82525f2
CY
1028
1029;;;###autoload
1030(defcustom semantic-default-submodes
1031 '(global-semantic-idle-scheduler-mode global-semanticdb-minor-mode)
bd2afec2 1032 "List of auxiliary Semantic minor modes enabled by `semantic-mode'.
b82525f2
CY
1033The possible elements of this list include the following:
1034
1035 `semantic-highlight-func-mode' - Highlight the current tag.
1036 `semantic-decoration-mode' - Decorate tags based on various attributes.
1037 `semantic-stickyfunc-mode' - Track current function in the header-line.
1038 `semantic-idle-completions-mode' - Provide smart symbol completion
1039 automatically when idle.
1040 `semantic-idle-scheduler-mode' - Keep a buffer's parse tree up to date.
1041 `semanticdb-minor-mode' - Store tags when a buffer is not in memory.
1042 `semantic-idle-summary-mode' - Show a summary for the code at point.
1043 `semantic-mru-bookmark-mode' - Provide `switch-to-buffer'-like
1044 keybinding for tag names."
1045 :group 'semantic
1046 :type `(set ,@(mapcar (lambda (c) (list 'const c))
1047 semantic-submode-list)))
1048
1049;;;###autoload
1050(define-minor-mode semantic-mode
1051 "Toggle Semantic mode.
1052With ARG, turn Semantic mode on if ARG is positive, off otherwise.
1053
1054In Semantic mode, Emacs parses the buffers you visit for their
1055semantic content. This information is used by a variety of
1056auxilliary minor modes, listed in `semantic-default-submodes';
1057all the minor modes in this list are also enabled when you enable
8bf997ef
CY
1058Semantic mode.
1059
1060\\{semantic-mode-map}"
1061 :global t
b82525f2
CY
1062 :group 'semantic
1063 (if semantic-mode
1064 ;; Turn on Semantic mode
1065 (progn
8bf997ef
CY
1066 ;; Enable all the global auxilliary minor modes in
1067 ;; `semantic-submode-list'.
b82525f2
CY
1068 (dolist (mode semantic-submode-list)
1069 (if (memq mode semantic-default-submodes)
1070 (funcall mode 1)))
1071 (unless semantic-load-system-cache-loaded
1072 (setq semantic-load-system-cache-loaded t)
1073 (when (and (boundp 'semanticdb-default-system-save-directory)
1074 (stringp semanticdb-default-system-save-directory)
1075 (file-exists-p semanticdb-default-system-save-directory))
17e1f4bc 1076 (require 'semantic/db-ebrowse)
b82525f2 1077 (semanticdb-load-ebrowse-caches)))
82481502 1078 (add-hook 'mode-local-init-hook 'semantic-new-buffer-fcn))
b82525f2
CY
1079 ;; Disable all Semantic features.
1080 (remove-hook 'mode-local-init-hook 'semantic-new-buffer-fcn)
b82525f2 1081 ;; FIXME: handle semanticdb-load-ebrowse-caches
b82525f2
CY
1082 (dolist (mode semantic-submode-list)
1083 (if (and (boundp mode) (eval mode))
1084 (funcall mode -1)))))
1085
af7b5a91
CY
1086;;; Autoload some functions that are not in semantic/loaddefs
1087
1088(autoload 'global-semantic-idle-completions-mode "semantic/idle"
1089 "Toggle global use of `semantic-idle-completions-mode'.
1090If ARG is positive, enable, if it is negative, disable.
1091If ARG is nil, then toggle." t nil)
1092
1093(autoload 'semantic-idle-completions-mode "semantic/idle"
1094 "Display a list of possible completions in a tooltip.
1095
1096This is a minor mode which performs actions during idle time.
1097With prefix argument ARG, turn on if positive, otherwise off. The
1098minor mode can be turned on only if semantic feature is available and
1099the current buffer was set up for parsing. Return non-nil if the
1100minor mode is enabled." t nil)
1101
1102(autoload 'global-semantic-idle-summary-mode "semantic/idle"
1103 "Toggle global use of `semantic-idle-summary-mode'.
1104If ARG is positive, enable, if it is negative, disable.
1105If ARG is nil, then toggle." t nil)
1106
1107(autoload 'semantic-idle-summary-mode "semantic/idle"
1108 "Display a tag summary of the lexical token under the cursor.
1109Call `semantic-idle-summary-current-symbol-info' for getting the
1110current tag to display information.
1111
1112This is a minor mode which performs actions during idle time.
1113With prefix argument ARG, turn on if positive, otherwise off. The
1114minor mode can be turned on only if semantic feature is available and
1115the current buffer was set up for parsing. Return non-nil if the
1116minor mode is enabled." t nil)
b82525f2 1117
e6e267fc
CY
1118(autoload 'srecode-template-setup-parser "srecode/srecode-template"
1119 "Set up buffer for parsing SRecode template files." t nil)
1120
d3d82e7b
CY
1121(provide 'semantic)
1122
d3d82e7b
CY
1123;; Semantic-util is a part of the semantic API. Include it last
1124;; because it depends on semantic.
9d389824 1125(require 'semantic/util)
a60f2e7b 1126
b82525f2
CY
1127;; (require 'semantic/load)
1128
3999968a 1129;; arch-tag: 31583e10-6508-41a9-be40-f83d0ae0a4ed
a60f2e7b 1130;;; semantic.el ends here