Function: semantic-analyze-find-tag

semantic-analyze-find-tag is a byte-compiled function defined in analyze.el.gz.

Signature

(semantic-analyze-find-tag NAME &optional TAGCLASS SCOPE)

Documentation

Return the first tag found with NAME or nil if not found.

Optional argument TAGCLASS specifies the class of tag to return, such as function or variable. Optional argument SCOPE specifies a scope object which has additional tags which are in SCOPE and do not need prefixing to find.

This is a wrapper on top of semanticdb, semanticdb typecache, semantic-scope, and semantic search functions. Almost all searches use the same arguments.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/analyze.el.gz
(defun semantic-analyze-find-tag (name &optional tagclass scope)
  "Return the first tag found with NAME or nil if not found.
Optional argument TAGCLASS specifies the class of tag to return,
such as `function' or `variable'.
Optional argument SCOPE specifies a scope object which has
additional tags which are in SCOPE and do not need prefixing to
find.

This is a wrapper on top of semanticdb, semanticdb typecache,
semantic-scope, and semantic search functions.  Almost all
searches use the same arguments."
  (let ((namelst (if (consp name) name ;; test if pre-split.
		   (semantic-analyze-split-name name))))
    (cond
     ;; If the splitter gives us a list, use the sequence finder
     ;; to get the list.  Since this routine is expected to return
     ;; only one tag, return the LAST tag found from the sequence
     ;; which is supposedly the nested reference.
     ;;
     ;; Of note, the SEQUENCE function below calls this function
     ;; (recursively now) so the names that we get from the above
     ;; fcn better not, in turn, be splittable.
     ((listp namelst)
      ;; If we had a split, then this is likely a c++ style namespace::name sequence,
      ;; so take a short-cut through the typecache.
      (or (semanticdb-typecache-find namelst)
	  ;; Ok, not there, try the usual...
	  (let ((seq (semantic-analyze-find-tag-sequence
		      namelst scope nil)))
	    (semantic-analyze-select-best-tag seq tagclass)
	    )))
     ;; If NAME is solo, then do our searches for it here.
     ((stringp namelst)
      (let ((retlist (and scope (semantic-scope-find name tagclass scope))))
	(if retlist
	    (semantic-analyze-select-best-tag
	     retlist tagclass)
	  (if (eq tagclass 'type)
	      (semanticdb-typecache-find name)
	    ;; Search in the typecache.  First entries in a sequence are
	    ;; often there.
	    (setq retlist (semanticdb-typecache-find name))
	    (if (and retlist (or (not tagclass)
				 (semantic-tag-of-class-p retlist 'tagclass)))
		retlist
	      (semantic-analyze-select-best-tag
	       (semanticdb-strip-find-results
		(semanticdb-find-tags-by-name name)
		'name)
	       tagclass)
	      )))))
     )))