Function: semantic-scope-find

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

Signature

(semantic-scope-find NAME &optional CLASS SCOPE-IN)

Documentation

Find the tag with NAME, and optional CLASS in the current SCOPE-IN.

Searches various elements of the scope for NAME. Return ALL the hits in order, with the first tag being in the closest scope.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/scope.el.gz
(defun semantic-scope-find (name &optional class scope-in)
  "Find the tag with NAME, and optional CLASS in the current SCOPE-IN.
Searches various elements of the scope for NAME.  Return ALL the
hits in order, with the first tag being in the closest scope."
  (let ((scope (or scope-in (semantic-calculate-scope)))
	(ans nil))
    ;; Is the passed in scope really a scope?  if so, look through
    ;; the options in that scope.
    (if (semantic-scope-cache-p scope)
	(let* ((la
		;; This should be first, but bugs in the
		;; C parser will turn function calls into
		;; assumed int return function prototypes.  Yuck!
		(semantic-find-tags-by-name name (oref scope localargs)))
	       (lv
		(semantic-find-tags-by-name name (oref scope localvar)))
	       (fullscoperaw (oref scope fullscope))
	       (sc (semantic-find-tags-by-name name fullscoperaw))
	       (typescoperaw  (oref scope typescope))
	       (tsc (semantic-find-tags-by-name name typescoperaw))
	       )
	  (setq ans
		(if class
		    ;; Scan out things not of the right class.
		    (semantic-find-tags-by-class class (append la lv sc tsc))
		  (append la lv sc tsc))
		)

	  (when (and (not ans) (or typescoperaw fullscoperaw))
	    (let ((namesplit (semantic-analyze-split-name name)))
	      (when (consp namesplit)
		;; It may be we need to hack our way through type typescope.
		(while namesplit
		  (setq ans (append
			     (semantic-find-tags-by-name (car namesplit)
							 typescoperaw)
			     (semantic-find-tags-by-name (car namesplit)
							 fullscoperaw)
			     ))
		  (if (not ans)
		      (setq typescoperaw nil)
		    (when (cdr namesplit)
		      (setq typescoperaw (semantic-tag-type-members
					  (car ans)))))

		  (setq namesplit (cdr namesplit)))
		;; Once done, store the current typecache lookup
		(oset scope typescope
		      (append typescoperaw (oref scope typescope)))
		)))
	  ;; Return it.
	  ans)
      ;; Not a real scope.  Our scope calculation analyze parts of
      ;; what it finds, and needs to pass lists through to do it's work.
      ;; Tread that list as a singly entry.
      (if class
	  (semantic-find-tags-by-class class scope)
	scope)
      )))