Function: semanticdb-file-table-object

semanticdb-file-table-object is an autoloaded and byte-compiled function defined in db.el.gz.

Signature

(semanticdb-file-table-object FILE &optional DONTLOAD)

Documentation

Return a semanticdb table belonging to FILE, make it up to date.

If file has database tags available in the database, return it. If file does not have tags available, and DONTLOAD is nil, then load the tags for FILE, and create a new table object for it. DONTLOAD does not affect the creation of new database objects.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/db.el.gz
;;;###autoload
(defun semanticdb-file-table-object (file &optional dontload)
  "Return a semanticdb table belonging to FILE, make it up to date.
If file has database tags available in the database, return it.
If file does not have tags available, and DONTLOAD is nil,
then load the tags for FILE, and create a new table object for it.
DONTLOAD does not affect the creation of new database objects."
  ;; (message "Object Translate: %s" file)
  (when (and file (file-exists-p file) (file-regular-p file))
    (let* ((default-directory (file-name-directory file))
	   (tab (semanticdb-file-table-object-from-hash file))
	   (fullfile nil))

      ;; If it is not in the cache, then extract the more traditional
      ;; way by getting the database, and finding a table in that database.
      ;; Once we have a table, add it to the hash.
      (when (eq tab 'no-hit)
	(setq fullfile (file-truename file))
	(let ((db (or ;; This line will pick up system databases.
		   (semanticdb-directory-loaded-p default-directory)
		   ;; this line will make a new one if needed.
		   (semanticdb-get-database default-directory))))
	  (setq tab (semanticdb-file-table db fullfile))
	  (when tab
	    (semanticdb-file-table-object-put-hash file tab)
	    (when (not (string= fullfile file))
	      (semanticdb-file-table-object-put-hash fullfile tab)
	    ))
	  ))

      (cond
       ((and tab
	     ;; Is this in a buffer?
	     ;;(find-buffer-visiting (semanticdb-full-filename tab))
	     (semanticdb-in-buffer-p tab)
	     )
	(save-excursion
	  ;;(set-buffer (find-buffer-visiting (semanticdb-full-filename tab)))
	  (semanticdb-set-buffer tab)
	  (semantic-fetch-tags)
	  ;; Return the table.
	  tab))
       ((and tab dontload)
	;; If we have table, and we don't want to load it, just return it.
	tab)
       ((and tab
	     ;; Is table fully loaded, or just a proxy?
	     (number-or-marker-p (oref tab pointmax))
	     ;; Is this table up to date with the file?
	     (not (semanticdb-needs-refresh-p tab)))
	;; A-ok!
	tab)
       ((or (and fullfile (get-file-buffer fullfile))
	    (get-file-buffer file))
	;; are these two calls this faster than `find-buffer-visiting'?

	;; If FILE is being visited, but none of the above state is
	;; true (meaning, there is no table object associated with it)
	;; then it is a file not supported by Semantic, and can be safely
	;; ignored.
	nil)
       ((not dontload) ;; We must load the file.
	;; Full file should have been set by now.  Debug why not?
	(when (and (not tab) (not fullfile))
	  ;; This case is if a 'nil is erroneously put into the hash table.  This
	  ;; would need fixing
	  (setq fullfile (file-truename file))
	  )

	;; If we have a table, but no fullfile, that's ok.  Let's get the filename
	;; from the table which is pre-truenamed.
	(when (and (not fullfile) tab)
	  (setq fullfile (semanticdb-full-filename tab)))

	(setq tab (semanticdb-create-table-for-file-not-in-buffer fullfile))

	;; Save the new table.
	(semanticdb-file-table-object-put-hash file tab)
	(when (not (string= fullfile file))
	  (semanticdb-file-table-object-put-hash fullfile tab)
	  )
	;; Done!
	tab)
       (t
	;; Full file should have been set by now.  Debug why not?
	;; One person found this.  Is it a file that failed to parse
	;; in the past?
	(when (not fullfile)
	  (setq fullfile (file-truename file)))

	;; We were asked not to load the file in and parse it.
	;; Instead just create a database table with no tags
	;; and a claim of being empty.
	;;
	;; This will give us a starting point for storing
	;; database cross-references so when it is loaded,
	;; the cross-references will fire and caches will
	;; be cleaned.
	(let ((ans (semanticdb-create-table-for-file file)))
	  (setq tab (cdr ans))

	  ;; Save the new table.
	  (semanticdb-file-table-object-put-hash file tab)
	  (when (not (string= fullfile file))
	    (semanticdb-file-table-object-put-hash fullfile tab)
	    )
	  ;; Done!
	  tab))
       )
      )))