Function: semantic-fetch-tags
semantic-fetch-tags is a byte-compiled function defined in
semantic.el.gz.
Signature
(semantic-fetch-tags)
Documentation
Fetch semantic tags from the current buffer.
If the buffer cache is up to date, return that. If the buffer cache is out of date, attempt an incremental reparse. If the buffer has not been parsed before, or if the incremental reparse fails, then parse the entire buffer. If a lexical error had been previously discovered and the buffer was marked unparsable, then do nothing, and return the cache.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/semantic.el.gz
(defun semantic-fetch-tags ()
"Fetch semantic tags from the current buffer.
If the buffer cache is up to date, return that.
If the buffer cache is out of date, attempt an incremental reparse.
If the buffer has not been parsed before, or if the incremental reparse
fails, then parse the entire buffer.
If a lexical error had been previously discovered and the buffer
was marked unparsable, then do nothing, and return the cache."
(and
;; Is this a semantic enabled buffer?
(semantic-active-p)
;; Application hooks say the buffer is safe for parsing
(run-hook-with-args-until-failure
'semantic--before-fetch-tags-hook)
;; If the buffer was previously marked unparsable,
;; then don't waste our time.
(not (semantic-parse-tree-unparseable-p))
;; The parse tree actually needs to be refreshed
(not (semantic-parse-tree-up-to-date-p))
;; So do it!
(let* ((gc-cons-threshold (max gc-cons-threshold 10000000))
(semantic-lex-block-streams nil)
(res nil))
(garbage-collect)
(cond
;; Try the incremental parser to do a fast update.
((semantic-parse-tree-needs-update-p)
(setq res (semantic-parse-changes))
(if (semantic-parse-tree-needs-rebuild-p)
;; If the partial reparse fails, jump to a full reparse.
(semantic-fetch-tags)
;; Clear the cache of unmatched syntax tokens
;;
;; NOTE TO SELF:
;;
;; Move this into the incremental parser. This is a bug.
;;
(semantic-clear-unmatched-syntax-cache)
(run-hook-with-args ;; Let hooks know the updated tags
'semantic-after-partial-cache-change-hook res))
(setq semantic--completion-cache nil))
;; Parse the whole system.
((semantic-parse-tree-needs-rebuild-p)
;; Use Emacs's built-in progress-reporter (only interactive).
(if noninteractive
(setq res (semantic-parse-region (point-min) (point-max)))
(let ((semantic--progress-reporter
(and (>= (point-max) semantic-minimum-working-buffer-size)
(eq semantic-working-type 'percent)
(make-progress-reporter
(semantic-parser-working-message (buffer-name))
0 100))))
(setq res (semantic-parse-region (point-min) (point-max)))
(if semantic--progress-reporter
(progress-reporter-done semantic--progress-reporter))))
;; Clear the caches when we see there were no errors.
;; But preserve the unmatched syntax cache and warnings!
(let (semantic-unmatched-syntax-cache
semantic-unmatched-syntax-cache-check
semantic-parser-warnings)
(semantic-clear-toplevel-cache))
;; Set up the new overlays
(semantic--tag-link-list-to-buffer res)
;; Set up the cache with the new results
(semantic--set-buffer-cache res)
))))
;; Always return the current parse tree.
semantic--buffer-cache)