;;; 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")
;; 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
(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.
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)
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))
"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.
\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.
(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))
(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'."
(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)
(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.
(null tag-to-test))))
)))
+;;;###autoload
(defun semanticdb-find-result-length (result)
"Number of tags found in RESULT."
(let ((count 0))
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.
(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
(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)
"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"
"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)
)))
(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)))
(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")
;; 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.
(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.
(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.
(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.
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)
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)
"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
(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