Add 2012 to FSF copyright years for Emacs files
[bpt/emacs.git] / lisp / cedet / semantic / db-find.el
index e7ce7fc..ca6a8fb 100644 (file)
@@ -1,7 +1,6 @@
 ;;; semantic/db-find.el --- Searching through semantic databases.
 
-;;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
-;;; 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 2000-2012 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:
 ;;
 ;; eldoc - popup help
 ;;   => Requires basic search using default path.  (Header files ok)
 ;; tag jump - jump to a named tag
-;;   => Requires a brute search useing whole project.  (Source files only)
+;;   => Requires a brute search using whole project.  (Source files only)
 ;; completion - Completing symbol names in a smart way
 ;;   => Basic search (headers ok)
 ;; type analysis - finding type definitions for variables & fcns
 
 (defvar data-debug-thing-alist)
 (declare-function data-debug-insert-stuff-list "data-debug")
-(declare-function data-debug-insert-tag-list "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")
@@ -202,7 +201,7 @@ This class will cache data derived during various searches.")
   (when (oref idx type-cache)
     (semantic-reset (oref idx type-cache)))
   ;; Clear the scope.  Scope doesn't have the data it needs to track
-  ;; it's own reset.
+  ;; its own reset.
   (semantic-scope-reset-cache)
   )
 
@@ -211,7 +210,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)
@@ -225,7 +224,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)
@@ -235,7 +234,7 @@ 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)
@@ -262,13 +261,13 @@ This class will cache data derived during various searches.")
   "Translate PATH into a list of semantic tables.
 Path translation involves identifying the PATH input argument
 in one of the following ways:
-  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.
   find result - Search the results of a previous find.
 
 In addition, once the base path is found, there is the possibility of
@@ -281,7 +280,7 @@ identified by translating PATH.  Such searches use brute force to
 scan every available table.
 
 The return value is a list of objects of type `semanticdb-table' or
-it's children.  In the case of passing in a find result, the result
+their children.  In the case of passing in a find result, the result
 is returned unchanged.
 
 This routine uses `semanticdb-find-table-for-include' to translate
@@ -326,9 +325,8 @@ 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)))
-                   (save-excursion
-                     ;; @todo - What does this DO ??!?!
-                     (set-buffer (semantic-tag-buffer (car tt)))
+                   ;; @todo - What does this DO ??!?!
+                   (with-current-buffer (semantic-tag-buffer (car tt))
                      semanticdb-current-database))))))
     (apply
      #'nconc
@@ -366,7 +364,7 @@ Default action as described in `semanticdb-find-translate-path'."
     ans))
 
 (defun semanticdb-find-need-cache-update-p (table)
-  "Non nil if the semanticdb TABLE cache needs to be updated."
+  "Non-nil if the semanticdb TABLE cache needs to be updated."
   ;; If we were passed in something related to a TABLE,
   ;; do a caching lookup.
   (let* ((index (semanticdb-get-table-index table))
@@ -407,10 +405,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))
@@ -431,7 +429,7 @@ Default action as described in `semanticdb-find-translate-path'."
   "All include tags scanned, plus action taken on the tag.
 Each entry is an alist:
   (ACTION . TAG)
-where ACTION is one of 'scanned, 'duplicate, 'lost.
+where ACTION is one of 'scanned, 'duplicate, 'lost
 and TAG is a clone of the include tag that was found.")
 (make-variable-buffer-local 'semanticdb-find-scanned-include-tags)
 
@@ -440,7 +438,7 @@ and TAG is a clone of the include tag that was found.")
 Set this variable with `defvar-mode-local' for a particular mode so
 that any symbols that exist for all files for that mode are included.
 
-Note: This could be used as a way to write a file in a langauge
+Note: This could be used as a way to write a file in a language
 to declare all the built-ins for that language.")
 
 (defun semanticdb-find-translate-path-includes--internal (path)
@@ -469,12 +467,11 @@ a new path from the provided PATH."
                 incfname (semanticdb-full-filename path))
           )
          ((bufferp path)
-          (save-excursion
-            (set-buffer path)
+          (with-current-buffer path
             (semantic-refresh-tags-safe))
           (setq includetags (semantic-find-tags-included path)
-                curtable (save-excursion (set-buffer path)
-                                         semanticdb-current-table)
+                curtable (with-current-buffer path
+                            semanticdb-current-table)
                 incfname (buffer-file-name path)))
          (t
           (setq includetags (semantic-find-tags-included path))
@@ -578,7 +575,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))))
@@ -678,7 +675,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.
@@ -776,12 +773,12 @@ Examines the variable `semanticdb-find-lost-includes'."
                 (buffer-name))
 
       (data-debug-new-buffer "*SEMANTICDB lost-includes ADEBUG*")
-      (data-debug-insert-tag-list lost "*")
+      ;; (data-debug-insert-tag-list lost "*")
       )))
 
 (defun semanticdb-find-adebug-insert-scanned-tag-cons (consdata prefix prebuttontext)
   "Insert a button representing scanned include CONSDATA.
-PREFIX is the text that preceeds the button.
+PREFIX is the text that precedes the button.
 PREBUTTONTEXT is some text between prefix and the overlay button."
   (let* ((start (point))
         (end nil)
@@ -865,7 +862,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))
@@ -921,14 +918,14 @@ but should be good enough for debugging assertions."
                         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))))
 
 (defun semanticdb-find-result-with-nil-p (resultp)
   "Non-nil of RESULTP is in the form of a semanticdb search result.
-nil is a valid value where a TABLE usually is, but only if the TAG
+The value nil is valid where a TABLE usually is, but only if the TAG
 results include overlays.
 This query only really tests the first entry in the list that is RESULTP,
 but should be good enough for debugging assertions."
@@ -1008,9 +1005,14 @@ is still made current."
          (when norm
            ;; The normalized tags can now be found based on that
            ;; tags table.
-           (semanticdb-set-buffer (car norm))
-           ;; Now reset ans
-           (setq ans (cdr norm))
+           (condition-case foo
+               (progn
+                 (semanticdb-set-buffer (car norm))
+                 ;; Now reset ans
+                 (setq ans (cdr norm)))
+             ;; Don't error for this case, but don't store
+             ;; the thing either.
+             (no-method-definition nil))
            ))
       )
     ;; Return the tag.
@@ -1019,12 +1021,12 @@ is still made current."
 (defun semanticdb-find-result-mapc (fcn result)
   "Apply FCN to each element of find RESULT for side-effects only.
 FCN takes two arguments.  The first is a TAG, and the
-second is a DB from wence TAG originated.
+second is a DB from whence TAG originated.
 Returns result."
-  (mapc (lambda (sublst)
-         (mapc (lambda (tag)
-                 (funcall fcn tag (car sublst)))
-               (cdr sublst)))
+  (mapc (lambda (sublst-icky)
+         (mapc (lambda (tag-icky)
+                 (funcall fcn tag-icky (car sublst-icky)))
+               (cdr sublst-icky)))
        result)
   result)
 
@@ -1038,7 +1040,7 @@ Returns result."
   "The name of the logging buffer.")
 
 (defun semanticdb-find-toggle-logging ()
-  "Toggle sematnicdb logging."
+  "Toggle semanticdb logging."
   (interactive)
   (setq semanticdb-find-log-flag (null semanticdb-find-log-flag))
   (message "Semanticdb find logging is %sabled"
@@ -1048,8 +1050,7 @@ Returns result."
   "Reset the log buffer."
   (interactive)
   (when semanticdb-find-log-flag
-    (save-excursion
-      (set-buffer (get-buffer-create semanticdb-find-log-buffer-name))
+    (with-current-buffer (get-buffer-create semanticdb-find-log-buffer-name)
       (erase-buffer)
       )))
 
@@ -1069,8 +1070,7 @@ Returns result."
 (defun semanticdb-find-log-new-search (forwhat)
   "Start a new search FORWHAT."
   (when semanticdb-find-log-flag
-    (save-excursion
-      (set-buffer (get-buffer-create semanticdb-find-log-buffer-name))
+    (with-current-buffer (get-buffer-create semanticdb-find-log-buffer-name)
       (insert (format "New Search: %S\n" forwhat))
       )
     (semanticdb-find-log-move-to-end)))
@@ -1078,8 +1078,7 @@ Returns result."
 (defun semanticdb-find-log-activity (table result)
   "Log that TABLE has been searched and RESULT was found."
   (when semanticdb-find-log-flag
-    (save-excursion
-      (set-buffer semanticdb-find-log-buffer-name)
+    (with-current-buffer semanticdb-find-log-buffer-name
       (insert "Table: " (object-print table)
              " Result: " (int-to-string (length result)) " tags"
              "\n")
@@ -1094,8 +1093,8 @@ Returns result."
   "Collect all tags returned by FUNCTION over PATH.
 The FUNCTION must take two arguments.  The first is TABLE,
 which is a semanticdb table containing tags.  The second argument
-to FUNCTION is TAGS.  TAGS may be a list of tags.  If TAGS is non-nil, then
-FUNCTION should search the TAG list, not through TABLE.
+to FUNCTION is TAGS.  TAGS may be a list of tags.  If TAGS is non-nil,
+then FUNCTION should search the TAG list, not through TABLE.
 
 See `semanticdb-find-translate-path' for details on PATH.
 FIND-FILE-MATCH indicates that any time a match is found, the file
@@ -1239,7 +1238,7 @@ associated with that tag should be loaded into a buffer."
 See `semanticdb-find-translate-path' for details on PATH.
 The argument BRUTISH will be set so that searching includes all tables
 in the current project.
-FIND-FILE-MATCH indicates that any time a matchi is found, the file
+FIND-FILE-MATCH indicates that any time a match is found, the file
 associated wit that tag should be loaded into a buffer."
   (semanticdb-find-tags-collector
    (lambda (table tags)
@@ -1251,7 +1250,7 @@ associated wit that tag should be loaded into a buffer."
 See `semanticdb-find-translate-path' for details on PATH.
 The argument BRUTISH will be set so that searching includes all tables
 in the current project.
-FIND-FILE-MATCH indicates that any time a matchi is found, the file
+FIND-FILE-MATCH indicates that any time a match is found, the file
 associated wit that tag should be loaded into a buffer."
   (semanticdb-find-tags-collector
    (lambda (table tags)
@@ -1300,38 +1299,38 @@ associated with that tag should be loaded into a buffer."
 
 ;;; Top level Searches
 (defmethod semanticdb-find-tags-by-name-method ((table semanticdb-abstract-table) name &optional tags)
-  "In TABLE, find all occurances of tags with NAME.
+  "In TABLE, find all occurrences of tags with NAME.
 Optional argument TAGS is a list of tags to search.
 Returns a table of all matching tags."
   (semantic-find-tags-by-name name (or tags (semanticdb-get-tags table))))
 
 (defmethod semanticdb-find-tags-by-name-regexp-method ((table semanticdb-abstract-table) regexp &optional tags)
-  "In TABLE, find all occurances of tags matching REGEXP.
+  "In TABLE, find all occurrences of tags matching REGEXP.
 Optional argument TAGS is a list of tags to search.
 Returns a table of all matching tags."
   (semantic-find-tags-by-name-regexp regexp (or tags (semanticdb-get-tags table))))
 
 (defmethod semanticdb-find-tags-for-completion-method ((table semanticdb-abstract-table) prefix &optional tags)
-  "In TABLE, find all occurances of tags matching PREFIX.
+  "In TABLE, find all occurrences of tags matching PREFIX.
 Optional argument TAGS is a list of tags to search.
 Returns a table of all matching tags."
   (semantic-find-tags-for-completion prefix (or tags (semanticdb-get-tags table))))
 
 (defmethod semanticdb-find-tags-by-class-method ((table semanticdb-abstract-table) class &optional tags)
-  "In TABLE, find all occurances of tags of CLASS.
+  "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))))
 
 (defmethod semanticdb-find-tags-external-children-of-type-method ((table semanticdb-abstract-table) parent &optional tags)
-   "In TABLE, find all occurances of tags whose parent is the PARENT type.
+   "In TABLE, find all occurrences of tags whose parent is the PARENT type.
 Optional argument TAGS is a list of tags to search.
 Returns a table of all matching tags."
    (require 'semantic/find)
    (semantic-find-tags-external-children-of-type parent (or tags (semanticdb-get-tags table))))
 
 (defmethod semanticdb-find-tags-subclasses-of-type-method ((table semanticdb-abstract-table) parent &optional tags)
-   "In TABLE, find all occurances of tags whose parent is the PARENT type.
+   "In TABLE, find all occurrences of tags whose parent is the PARENT type.
 Optional argument TAGS is a list of tags to search.
 Returns a table of all matching tags."
    (require 'semantic/find)
@@ -1339,7 +1338,7 @@ Returns a table of all matching tags."
 
 ;;; Deep Searches
 (defmethod semanticdb-deep-find-tags-by-name-method ((table semanticdb-abstract-table) name &optional tags)
-  "In TABLE, find all occurances of tags with NAME.
+  "In TABLE, find all occurrences of tags with NAME.
 Search in all tags in TABLE, and all components of top level tags in
 TABLE.
 Optional argument TAGS is a list of tags to search.
@@ -1347,7 +1346,7 @@ Return a table of all matching tags."
   (semantic-find-tags-by-name name (semantic-flatten-tags-table (or tags (semanticdb-get-tags table)))))
 
 (defmethod semanticdb-deep-find-tags-by-name-regexp-method ((table semanticdb-abstract-table) regexp &optional tags)
-  "In TABLE, find all occurances of tags matching REGEXP.
+  "In TABLE, find all occurrences of tags matching REGEXP.
 Search in all tags in TABLE, and all components of top level tags in
 TABLE.
 Optional argument TAGS is a list of tags to search.
@@ -1355,7 +1354,7 @@ Return a table of all matching tags."
   (semantic-find-tags-by-name-regexp regexp (semantic-flatten-tags-table (or tags (semanticdb-get-tags table)))))
 
 (defmethod semanticdb-deep-find-tags-for-completion-method ((table semanticdb-abstract-table) prefix &optional tags)
-  "In TABLE, find all occurances of tags matching PREFIX.
+  "In TABLE, find all occurrences of tags matching PREFIX.
 Search in all tags in TABLE, and all components of top level tags in
 TABLE.
 Optional argument TAGS is a list of tags to search.
@@ -1366,7 +1365,6 @@ Return a table of all matching tags."
 
 ;; Local variables:
 ;; generated-autoload-file: "loaddefs.el"
-;; generated-autoload-feature: semantic/loaddefs
 ;; generated-autoload-load-name: "semantic/db-find"
 ;; End: