;;; semantic/db.el --- Semantic tag database manager
-;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
-;; 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2011 Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <zappo@gnu.org>
;; Keywords: tags
"Get a cache object on TABLE of class DESIRED-CLASS.
This method will create one if none exists with no init arguments
other than :table."
- (assert (child-of-class-p desired-class 'semanticdb-abstract-cache))
+ (unless (child-of-class-p desired-class 'semanticdb-abstract-cache)
+ (error "Invalid SemanticDB cache"))
(let ((cache (oref table cache))
(obj nil))
(while (and (not obj) cache)
"Get a cache object on DB of class DESIRED-CLASS.
This method will create one if none exists with no init arguments
other than :table."
- (assert (child-of-class-p desired-class 'semanticdb-abstract-db-cache))
+ (unless (child-of-class-p desired-class 'semanticdb-abstract-cache)
+ (error "Invalid SemanticDB cache"))
(let ((cache (oref db cache))
(obj nil))
(while (and (not obj) cache)
is not in a buffer. Avoid using FORCE for most uses, as an old cache
may be sufficient for the general case. Forced updates can be slow.
This will call `semantic-fetch-tags' if that file is in memory."
- (when (or (semanticdb-in-buffer-p obj) force)
+ (cond
+ ;;
+ ;; Already in a buffer, just do it.
+ ((semanticdb-in-buffer-p obj)
+ (semanticdb-set-buffer obj)
+ (semantic-fetch-tags))
+ ;;
+ ;; Not in a buffer. Forcing a load.
+ (force
+ ;; Patch from Iain Nicol. --
+ ;; @TODO: I wonder if there is a way to recycle
+ ;; semanticdb-create-table-for-file-not-in-buffer
(save-excursion
- (semanticdb-set-buffer obj)
- (semantic-fetch-tags))))
+ (let ((buff (semantic-find-file-noselect
+ (semanticdb-full-filename obj))))
+ (set-buffer buff)
+ (semantic-fetch-tags)
+ ;; Kill off the buffer if it didn't exist when we were called.
+ (kill-buffer buff))))))
(defmethod semanticdb-needs-refresh-p ((obj semanticdb-table))
"Return non-nil of OBJ's tag list is out of date.
(defmethod semanticdb-equivalent-mode ((table semanticdb-abstract-table) &optional buffer)
"Return non-nil if TABLE's mode is equivalent to BUFFER.
-Equivalent modes are specified by by `semantic-equivalent-major-modes'
+Equivalent modes are specified by the `semantic-equivalent-major-modes'
local variable."
nil)
(defmethod semanticdb-equivalent-mode ((table semanticdb-table) &optional buffer)
"Return non-nil if TABLE's mode is equivalent to BUFFER.
-Equivalent modes are specified by by `semantic-equivalent-major-modes'
+Equivalent modes are specified by the `semantic-equivalent-major-modes'
local variable."
(save-excursion
(if buffer (set-buffer buffer))
(setq root (run-hook-with-args-until-success
'semanticdb-project-root-functions
dir))
- ;; Find roots based on strings
- (while (and roots (not root))
- (let ((r (file-truename (car roots))))
- (if (string-match (concat "^" (regexp-quote r)) dir)
- (setq root r)))
- (setq roots (cdr roots)))
+ (if root
+ (setq root (file-truename root))
+ ;; Else, Find roots based on strings
+ (while roots
+ (let ((r (file-truename (car roots))))
+ (if (string-match (concat "^" (regexp-quote r)) dir)
+ (setq root r)))
+ (setq roots (cdr roots))))
;; If no roots are found, use this directory.
(unless root (setq root dir))
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 (file-exists-p file)
+ (when (and file (file-exists-p file))
(let* ((default-directory (file-name-directory file))
(tab (semanticdb-file-table-object-from-hash file))
(fullfile nil))
;; generated-autoload-load-name: "semantic/db"
;; End:
-;; arch-tag: d9f75280-737d-494f-9f70-09a649d27433
;;; semantic/db.el ends here