;;; semantic/find.el --- Search routines for Semantic
-;;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
-;;; Free Software Foundation, Inc.
+;; Copyright (C) 1999-2005, 2008-2011 Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <zappo@gnu.org>
;; Keywords: syntax
;; used for compatibility with the semantic 1.x search routines.
;;
;; 1.5) semantic-brute-find-first-tag-by-*
-;; Like 1, except seraching stops on the first match for the given
+;; Like 1, except searching stops on the first match for the given
;; information.
;;
;; 2) semantic-find-tag-by-*
-;; These prefered search routines attempt to scan through lists
+;; These preferred search routines attempt to scan through lists
;; in an intelligent way based on questions asked.
;;
;; 3) semantic-find-*-overlay
;;
;; 4) ...
+;;; Code:
+
(require 'semantic)
(require 'semantic/tag)
-;;; Code:
-\f
+(declare-function semantic-tag-protected-p "semantic/tag-ls")
+
;;; Overlay Search Routines
;;
;; These routines provide fast access to tokens based on a buffer that
;; has parsed tokens in it. Uses overlays to perform the hard work.
-
+;;
;;;###autoload
(defun semantic-find-tag-by-overlay (&optional positionormarker buffer)
"Find all tags covering POSITIONORMARKER by using overlays.
;;;###autoload
(defun semantic-find-tag-by-overlay-in-region (start end &optional buffer)
"Find all tags which exist in whole or in part between START and END.
-Uses overlays to determine positin.
+Uses overlays to determine position.
Optional BUFFER argument specifies the buffer to use."
(save-excursion
(if buffer (set-buffer buffer))
smallest tag. Return nil if there is no tag here."
(car (nreverse (semantic-find-tag-by-overlay))))
+;;;###autoload
(defun semantic-current-tag-parent ()
"Return the current tags parent in the current buffer.
A tag's parent would be a containing structure, such as a type
(nreverse result)))
;;; Top level Searches
-
+;;
;;;###autoload
(defun semantic-find-first-tag-by-name (name &optional table)
"Find the first tag with NAME in TABLE.
,table)))
(defmacro semantic-find-tags-for-completion (prefix &optional table)
- "Find all tags whos name begins with PREFIX in TABLE.
+ "Find all tags whose name begins with PREFIX in TABLE.
PREFIX is a string.
TABLE is a tag table. See `semantic-something-to-tag-table'.
While it would be nice to use `try-completion' or `all-completions',
(semantic-tag-type-compound-p (car tags))
,table))
+;;;###autoload
(define-overloadable-function semantic-find-tags-by-scope-protection (scopeprotection parent &optional table)
"Find all tags accessable by SCOPEPROTECTION.
SCOPEPROTECTION is a symbol which can be returned by the method
semantic-tag-class type))
(:override)))
-(declare-function semantic-tag-protected-p "semantic/tag-ls")
-
(defun semantic-find-tags-by-scope-protection-default
(scopeprotection parent &optional table)
- "Find all tags accessable by SCOPEPROTECTION.
+ "Find all tags accessible by SCOPEPROTECTION.
SCOPEPROTECTION is a symbol which can be returned by the method
`semantic-tag-protection'. A hard-coded order is used to determine a match.
PARENT is a tag representing the PARENT slot needed for
,name (semantic-flatten-tags-table ,table)))
(defmacro semantic-deep-find-tags-for-completion (prefix &optional table)
- "Find all tags whos name begins with PREFIX in TABLE.
+ "Find all tags whose name begins with PREFIX in TABLE.
Search in top level tags, and their components, in TABLE.
TABLE is a tag table. See `semantic-flatten-tags-table'.
See also `semantic-find-tags-for-completion'."
,regexp (semantic-flatten-tags-table ,table)))
;;; Specialty Searches
-;;
-(declare-function semantic-tag-external-member-parent "semantic/sort")
(defun semantic-find-tags-external-children-of-type (type &optional table)
"Find all tags in whose parent is TYPE in TABLE.
(save-excursion
(if (markerp position) (set-buffer (marker-buffer position)))
(let* ((stream (if (bufferp streamorbuffer)
- (save-excursion
- (set-buffer streamorbuffer)
+ (with-current-buffer streamorbuffer
(semantic-fetch-tags))
streamorbuffer))
(prev nil)
(semantic-tag-type-members current)
nil))))
(nreverse (cons current returnme))))
-\f
-;;; Compatibility Aliases
-(semantic-alias-obsolete 'semantic-find-nonterminal-by-overlay
- 'semantic-find-tag-by-overlay)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-by-overlay-in-region
- 'semantic-find-tag-by-overlay-in-region)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-by-overlay-next
- 'semantic-find-tag-by-overlay-next)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-by-overlay-prev
- 'semantic-find-tag-by-overlay-prev)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-parent-by-overlay
- 'semantic-find-tag-parent-by-overlay)
-
-(semantic-alias-obsolete 'semantic-current-nonterminal
- 'semantic-current-tag)
-
-(semantic-alias-obsolete 'semantic-current-nonterminal-parent
- 'semantic-current-tag-parent)
-
-(semantic-alias-obsolete 'semantic-current-nonterminal-of-type
- 'semantic-current-tag-of-class)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-by-name
- 'semantic-brute-find-first-tag-by-name)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-by-token
- 'semantic-brute-find-tag-by-class)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-standard
- 'semantic-brute-find-tag-standard)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-by-type
- 'semantic-brute-find-tag-by-type)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-by-type-regexp
- 'semantic-brute-find-tag-by-type-regexp)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-by-name-regexp
- 'semantic-brute-find-tag-by-name-regexp)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-by-property
- 'semantic-brute-find-tag-by-property)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-by-extra-spec
- 'semantic-brute-find-tag-by-attribute)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-by-extra-spec-value
- 'semantic-brute-find-tag-by-attribute-value)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-by-function
- 'semantic-brute-find-tag-by-function)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-by-function-first-match
- 'semantic-brute-find-first-tag-by-function)
-
-(semantic-alias-obsolete 'semantic-find-nonterminal-by-position
- 'semantic-brute-find-tag-by-position)
-
-(semantic-alias-obsolete 'semantic-find-innermost-nonterminal-by-position
- 'semantic-brute-find-innermost-tag-by-position)
-
-;;; TESTING
-;;
-(defun semantic-find-benchmark ()
- "Run some simple benchmarks to see how we are doing.
-Optional argument ARG is the number of iterations to run."
- (interactive)
- (require 'benchmark)
- (let ((f-name nil)
- (b-name nil)
- (f-comp)
- (b-comp)
- (f-regex)
- )
- (garbage-collect)
- (setq f-name
- (benchmark-run-compiled
- 1000 (semantic-find-first-tag-by-name "class3"
- "test/test.cpp")))
- (garbage-collect)
- (setq b-name
- (benchmark-run-compiled
- 1000 (semantic-brute-find-first-tag-by-name "class3"
- "test/test.cpp")))
- (garbage-collect)
- (setq f-comp
- (benchmark-run-compiled
- 1000 (semantic-find-tags-for-completion "method"
- "test/test.cpp")))
- (garbage-collect)
- (setq b-comp
- (benchmark-run-compiled
- 1000 (semantic-brute-find-tag-by-name-regexp "^method"
- "test/test.cpp")))
- (garbage-collect)
- (setq f-regex
- (benchmark-run-compiled
- 1000 (semantic-find-tags-by-name-regexp "^method"
- "test/test.cpp")))
-
- (message "Name [new old] [ %.3f %.3f ] Complete [newc/new old] [ %.3f/%.3f %.3f ]"
- (car f-name) (car b-name)
- (car f-comp) (car f-regex)
- (car b-comp))
- ))
(provide 'semantic/find)
;; Local variables:
;; generated-autoload-file: "loaddefs.el"
-;; generated-autoload-feature: semantic/loaddefs
+;; generated-autoload-load-name: "semantic/find"
;; End:
;;; semantic/find.el ends here