]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/semantic/db-find.el
from trunk
[gnu-emacs] / lisp / cedet / semantic / db-find.el
index 65028545ed030301c02dc1cf1081fac3e34f362d..59b190f00735713efa30921989d2c9df98222e84 100644 (file)
@@ -1,7 +1,7 @@
 ;;; 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, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
+;;   2009, 2010 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <zappo@gnu.org>
 ;; Keywords: tags
 ;; 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
 (require 'semantic/db)
 (require 'semantic/db-ref)
 (eval-when-compile
-  (require 'eieio)
   (require 'semantic/find))
 
-(require 'semantic/tag-file)
-(require 'semantic/sort)
-
 ;;; Code:
 
 (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")
@@ -261,6 +257,7 @@ This class will cache data derived during various searches.")
 ;; These routines needed to be overloaded by specific language modes.
 ;; They are needed for translating an INCLUDE tag into a semanticdb
 ;; TABLE object.
+;;;###autoload
 (define-overloadable-function semanticdb-find-translate-path (path brutish)
   "Translate PATH into a list of semantic tables.
 Path translation involves identifying the PATH input argument
@@ -314,6 +311,7 @@ Default action as described in `semanticdb-find-translate-path'."
        (semanticdb-find-translate-path-brutish-default path)
       (semanticdb-find-translate-path-includes-default path))))
 
+;;;###autoload
 (define-overloadable-function semanticdb-find-table-for-include (includetag &optional table)
   "For a single INCLUDETAG found in TABLE, find a `semanticdb-table' object
 INCLUDETAG is a semantic TAG of class 'include.
@@ -442,7 +440,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)
@@ -471,12 +469,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))
@@ -603,6 +600,7 @@ isn't in memory yet."
   "Load an unloaded file in FILENAME using the default semanticdb loader."
   (semanticdb-file-table-object filename))
 
+;; The creation of the overload occurs above.
 (defun semanticdb-find-table-for-include-default (includetag &optional table)
   "Default implementation of `semanticdb-find-table-for-include'.
 Uses `semanticdb-current-database-list' as the search path.
@@ -721,6 +719,7 @@ Included databases are filtered based on `semanticdb-find-default-throttle'."
 \f
 ;;; Perform interactive tests on the path/search mechanisms.
 ;;
+;;;###autoload
 (defun semanticdb-find-test-translate-path (&optional arg)
   "Call and output results of `semanticdb-find-translate-path'.
 With ARG non-nil, specify a BRUTISH translation.
@@ -748,7 +747,7 @@ for details on how this list is derived."
   (semantic-fetch-tags)
   (require 'data-debug)
   (let* ((semanticdb-find-default-throttle
-         (if (featurep 'semanticdb-find)
+         (if (featurep 'semantic/db-find)
              (remq 'unloaded semanticdb-find-default-throttle)
            nil))
         (start (current-time))
@@ -761,6 +760,7 @@ for details on how this list is derived."
 
     (data-debug-insert-stuff-list p "*")))
 
+;;;###autoload
 (defun semanticdb-find-adebug-lost-includes ()
   "Translate the current path, then display the lost includes.
 Examines the variable `semanticdb-find-lost-includes'."
@@ -780,7 +780,7 @@ Examines the variable `semanticdb-find-lost-includes'."
 
 (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)
@@ -838,23 +838,13 @@ Examines the variable `semanticdb-find-lost-includes'."
       (data-debug-new-buffer "*SEMANTICDB scanned-includes ADEBUG*")
       (data-debug-insert-stuff-list scanned "*")
       )))
-\f
-;;; FIND results and edebug
-;;
-(eval-after-load "cedet-edebug"
-  '(progn
-     (cedet-edebug-add-print-override
-      '(semanticdb-find-results-p object)
-      '(semanticdb-find-result-prin1-to-string object) )
-     ))
-
-
 \f
 ;;; API Functions
 ;;
 ;; Once you have a search result, use these routines to operate
 ;; on the search results at a higher level
 
+;;;###autoload
 (defun semanticdb-strip-find-results (results &optional find-file-match)
   "Strip a semanticdb search RESULTS to exclude objects.
 This makes it appear more like the results of a `semantic-find-' call.
@@ -952,6 +942,7 @@ but should be good enough for debugging assertions."
                      (null tag-to-test))))
         )))
 
+;;;###autoload
 (defun semanticdb-find-result-length (result)
   "Number of tags found in RESULT."
   (let ((count 0))
@@ -960,6 +951,7 @@ but should be good enough for debugging assertions."
          result)
     count))
 
+;;;###autoload
 (defun semanticdb-find-result-nth (result n)
   "In RESULT, return the Nth search result.
 This is a 0 based search result, with the first match being element 0.
@@ -996,6 +988,7 @@ the TAG was found.  Sometimes TABLE can be nil."
            (error "%d entry is not a tag" i)))
       (setq i (1+ i)))))
 
+;;;###autoload
 (defun semanticdb-find-result-nth-in-buffer (result n)
   "In RESULT, return the Nth search result.
 Like `semanticdb-find-result-nth', except that only the TAG
@@ -1025,7 +1018,7 @@ 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)
@@ -1044,7 +1037,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"
@@ -1054,8 +1047,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)
       )))
 
@@ -1075,8 +1067,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)))
@@ -1084,8 +1075,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")
@@ -1160,6 +1150,7 @@ and search all tables in this project tree."
     ;; It must be reversed.
     (nreverse found)))
 
+;;;###autoload
 (defun semanticdb-find-tags-by-name (name &optional path find-file-match)
   "Search for all tags matching NAME on PATH.
 See `semanticdb-find-translate-path' for details on PATH.
@@ -1170,6 +1161,7 @@ associated with that tag should be loaded into a buffer."
      (semanticdb-find-tags-by-name-method table name tags))
    path find-file-match))
 
+;;;###autoload
 (defun semanticdb-find-tags-by-name-regexp (regexp &optional path find-file-match)
   "Search for all tags matching REGEXP on PATH.
 See `semanticdb-find-translate-path' for details on PATH.
@@ -1180,6 +1172,7 @@ associated with that tag should be loaded into a buffer."
      (semanticdb-find-tags-by-name-regexp-method table regexp tags))
    path find-file-match))
 
+;;;###autoload
 (defun semanticdb-find-tags-for-completion (prefix &optional path find-file-match)
   "Search for all tags matching PREFIX on PATH.
 See `semanticdb-find-translate-path' for details on PATH.
@@ -1190,6 +1183,7 @@ associated with that tag should be loaded into a buffer."
      (semanticdb-find-tags-for-completion-method table prefix tags))
    path find-file-match))
 
+;;;###autoload
 (defun semanticdb-find-tags-by-class (class &optional path find-file-match)
   "Search for all tags of CLASS on PATH.
 See `semanticdb-find-translate-path' for details on PATH.
@@ -1235,12 +1229,13 @@ associated with that tag should be loaded into a buffer."
    path find-file-match))
 
 ;;; Brutish Search Routines
+;;
 (defun semanticdb-brute-deep-find-tags-by-name (name &optional path find-file-match)
   "Search for all tags matching NAME on PATH.
 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)
@@ -1252,7 +1247,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)
@@ -1328,12 +1323,14 @@ Returns a table of all matching tags."
    "In TABLE, find all occurances 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.
 Optional argument TAGS is a list of tags to search.
 Returns a table of all matching tags."
+   (require 'semantic/find)
    (semantic-find-tags-subclasses-of-type parent (or tags (semanticdb-get-tags table))))
 
 ;;; Deep Searches
@@ -1363,4 +1360,10 @@ Return a table of all matching tags."
 
 (provide 'semantic/db-find)
 
+;; Local variables:
+;; generated-autoload-file: "loaddefs.el"
+;; generated-autoload-load-name: "semantic/db-find"
+;; End:
+
+;; arch-tag: 5d4162f5-5092-46d7-beed-55c78aab4116
 ;;; semantic/db-find.el ends here