]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/semantic/db-find.el
Update copyright year to 2015
[gnu-emacs] / lisp / cedet / semantic / db-find.el
index a7335d642beeef6148bf2282ad1e7fc62bcdc419..08a22fb3b8518a4ec1c8036d634c222effdb5f31 100644 (file)
@@ -1,6 +1,6 @@
 ;;; semantic/db-find.el --- Searching through semantic databases.
 
-;; Copyright (C) 2000-2011 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2015 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Keywords: tags
 ;;  The PATH argument is then the most interesting argument.  It can
 ;;  have these values:
 ;;
-;;    nil - Take the current buffer, and use it's include list
+;;    nil - Take the current buffer, and use its include list
 ;;    buffer - Use that buffer's include list.
 ;;    filename - Use that file's include list.  If the file is not
 ;;        in a buffer, see of there is a semanticdb table for it.  If
 ;;        not, read that file into a buffer.
 ;;    tag - Get that tag's buffer of file file.  See above.
-;;    table - Search that table, and it's include list.
+;;    table - Search that table, and its include list.
 ;;
 ;; Search Results:
 ;;
 
 (defvar data-debug-thing-alist)
 (declare-function data-debug-insert-stuff-list "data-debug")
+(declare-function data-debug-new-buffer "data-debug")
 ;;;(declare-function data-debug-insert-tag-list "adebug")
 (declare-function semantic-scope-reset-cache "semantic/scope")
 (declare-function semanticdb-typecache-notify-reset "semantic/db-typecache")
 (declare-function ede-current-project "ede")
 
 (defvar semanticdb-find-throttle-custom-list
-  '(repeat (radio (const 'local)
-                 (const 'project)
-                 (const 'unloaded)
-                 (const 'system)
-                 (const 'recursive)
-                 (const 'omniscience)))
+  '(set (const local)
+       (const project)
+       (const unloaded)
+       (const system)
+       (const recursive)
+       (const omniscience))
   "Customization values for semanticdb find throttle.
 See `semanticdb-find-throttle' for details.")
 
@@ -167,6 +168,8 @@ the following keys:
   :group 'semanticdb
   :type semanticdb-find-throttle-custom-list)
 
+(make-variable-buffer-local 'semanticdb-find-default-throttle)
+
 (defun semanticdb-find-throttle-active-p (access-type)
   "Non-nil if ACCESS-TYPE is an active throttle type."
   (or (memq access-type semanticdb-find-default-throttle)
@@ -210,7 +213,7 @@ This class will cache data derived during various searches.")
   "Synchronize the search index IDX with some NEW-TAGS."
   ;; Reset our parts.
   (semantic-reset idx)
-  ;; Notify dependants by clearning their indicies.
+  ;; Notify dependants by clearing their indices.
   (semanticdb-notify-references
    (oref idx table)
    (lambda (tab me)
@@ -224,7 +227,7 @@ This class will cache data derived during various searches.")
   (if (semantic-find-tags-by-class 'include new-tags)
       (progn
        (semantic-reset idx)
-       ;; Notify dependants by clearning their indicies.
+       ;; Notify dependants by clearing their indices.
        (semanticdb-notify-references
         (oref idx table)
         (lambda (tab me)
@@ -234,14 +237,14 @@ This class will cache data derived during various searches.")
     (when (oref idx type-cache)
       (when (semanticdb-partial-synchronize (oref idx type-cache) new-tags)
        ;; If the synchronize returns true, we need to notify.
-       ;; Notify dependants by clearning their indicies.
+       ;; Notify dependants by clearing their indices.
        (semanticdb-notify-references
         (oref idx table)
         (lambda (tab me)
           (let ((tab-idx (semanticdb-get-table-index tab)))
             ;; Not a full reset?
             (when (oref tab-idx type-cache)
-              (require 'db-typecache)
+              (require 'semantic/db-typecache)
               (semanticdb-typecache-notify-reset
                (oref tab-idx type-cache)))
             )))
@@ -325,8 +328,10 @@ Default action as described in `semanticdb-find-translate-path'."
         (cond ((null path) semanticdb-current-database)
               ((semanticdb-table-p path) (oref path parent-db))
               (t (let ((tt (semantic-something-to-tag-table path)))
-                   ;; @todo - What does this DO ??!?!
-                   (with-current-buffer (semantic-tag-buffer (car tt))
+                   (if tt
+                       ;; @todo - What does this DO ??!?!
+                       (with-current-buffer (semantic-tag-buffer (car tt))
+                         semanticdb-current-database)
                      semanticdb-current-database))))))
     (apply
      #'nconc
@@ -405,10 +410,10 @@ Default action as described in `semanticdb-find-translate-path'."
        ;; do a caching lookup.
        (let ((index (semanticdb-get-table-index table)))
          (if (semanticdb-find-need-cache-update-p table)
-             ;; Lets go look up our indicies
+             ;; Let's go look up our indices.
              (let ((ans (semanticdb-find-translate-path-includes--internal path)))
                (oset index include-path ans)
-               ;; Once we have our new indicies set up, notify those
+               ;; Once we have our new indices set up, notify those
                ;; who depend on us if we found something for them to
                ;; depend on.
                (when ans (semanticdb-refresh-references table))
@@ -575,7 +580,7 @@ a new path from the provided PATH."
          (setq ans (semanticdb-file-table
                     (car systemdb)
                     ;; I would expect most omniscient to return the same
-                    ;; thing reguardless of filename, but we may have
+                    ;; thing regardless of filename, but we may have
                     ;; one that can return a table of all things the
                     ;; current file needs.
                     (buffer-file-name (current-buffer))))
@@ -675,7 +680,7 @@ Included databases are filtered based on `semanticdb-find-default-throttle'."
      ;;
      ;; NOTE: Not used if EDE is active!
      ((and (semanticdb-find-throttle-active-p 'project)
-          ;; And dont do this if it is a system include.  Not supported by all languages,
+          ;; And don't do this if it is a system include.  Not supported by all languages,
           ;; but when it is, this is a nice fast way to skip this step.
           (not (semantic-tag-include-system-p includetag))
           ;; Don't do this if we have an EDE project.
@@ -862,7 +867,7 @@ instead."
          (let ((tab (car (car tmp)))
                (tags (cdr (car tmp))))
            (dolist (T tags)
-             ;; Normilzation gives specialty database tables a chance
+             ;; Normalization gives specialty database tables a chance
              ;; to convert into a more stable tag format.
              (let* ((norm (semanticdb-normalize-one-tag tab T))
                     (ntab (car norm))
@@ -877,8 +882,9 @@ instead."
                ;; Find-file-match allows a tool to make sure the tag is
                ;; 'live', somewhere in a buffer.
                (cond ((eq find-file-match 'name)
-                      (let ((f (semanticdb-full-filename nametable)))
-                        (semantic--tag-put-property ntag :filename f)))
+                      (or (semantic--tag-get-property ntag :filename)
+                          (let ((f (semanticdb-full-filename nametable)))
+                            (semantic--tag-put-property ntag :filename f))))
                      ((and find-file-match ntab)
                       (semanticdb-get-buffer ntab))
                      )
@@ -913,12 +919,12 @@ but should be good enough for debugging assertions."
   (if (< (length result) 2)
       (concat "#<FIND RESULT "
              (mapconcat (lambda (a)
-                          (concat "(" (object-name (car a) ) " . "
+                          (concat "(" (eieio-object-name (car a) ) " . "
                                   "#<TAG LIST " (number-to-string (length (cdr a))) ">)"))
                         result
                         " ")
              ">")
-    ;; Longer results should have an abreviated form.
+    ;; Longer results should have an abbreviated form.
     (format "#<FIND RESULT %d TAGS in %d FILES>"
            (semanticdb-find-result-length result)
            (length result))))
@@ -1279,7 +1285,7 @@ associated with that tag should be loaded into a buffer."
   (semanticdb-find-tags-collector
    (lambda (table tags)
      (semanticdb-find-tags-external-children-of-type-method table type tags))
-   path find-file-match))
+   path find-file-match t))
 
 (defun semanticdb-find-tags-subclasses-of-type
   (type &optional path find-file-match)
@@ -1320,7 +1326,12 @@ Returns a table of all matching tags."
   "In TABLE, find all occurrences of tags of CLASS.
 Optional argument TAGS is a list of tags to search.
 Returns a table of all matching tags."
-  (semantic-find-tags-by-class class (or tags (semanticdb-get-tags table))))
+  ;; Delegate 'include' to the overridable
+  ;; `semantic-find-tags-included', which by default will just call
+  ;; `semantic-find-tags-by-class'.
+  (if (eq class 'include)
+      (semantic-find-tags-included (or tags (semanticdb-get-tags table)))
+    (semantic-find-tags-by-class class (or tags (semanticdb-get-tags table)))))
 
 (defmethod semanticdb-find-tags-external-children-of-type-method ((table semanticdb-abstract-table) parent &optional tags)
    "In TABLE, find all occurrences of tags whose parent is the PARENT type.