Function: srecode-find-prototype-for-expansion

srecode-find-prototype-for-expansion is a byte-compiled function defined in expandproto.el.gz.

Signature

(srecode-find-prototype-for-expansion)

Documentation

Find a prototype to use for expanding into an implementation.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/srecode/expandproto.el.gz
(defun srecode-find-prototype-for-expansion ()
  "Find a prototype to use for expanding into an implementation."
  ;; We may find a prototype tag in one of several places.
  ;; Search in order of logical priority.
  (let ((proto nil)
	)

    ;; 1) A class full of prototypes under point.
    (let ((tag (semantic-current-tag)))
      (when tag
	(when (not (semantic-tag-of-class-p tag 'type))
	  (setq tag (semantic-current-tag-parent))))
      (when (and tag (semantic-tag-of-class-p tag 'type))
	;; If the current class has prototype members, then
	;; we will do the whole class!
	(require 'semantic/find)
	(if (semantic-brute-find-tag-by-attribute-value
	     :prototype t
	     (semantic-tag-type-members tag))
	    (setq proto tag)))
      )

    ;; 2) A prototype under point.
    (when (not proto)
      (let ((tag (semantic-current-tag)))
	(when (and tag
		   (and
		    (semantic-tag-of-class-p tag 'function)
		    (semantic-tag-get-attribute tag :prototype)))
	  (setq proto tag))))

    ;; 3) A tag in the kill ring that is a prototype
    (when (not proto)
      (if (ring-empty-p senator-tag-ring)
	  nil  ;; Not for us.
	(let ((tag (ring-ref senator-tag-ring 0))
	      )
	  (when
	      (and tag
		   (or
		    (and
		     (semantic-tag-of-class-p tag 'function)
		     (semantic-tag-get-attribute tag :prototype))
		    (and
		     (semantic-tag-of-class-p tag 'type)
		     (require 'semantic/find)
		     (semantic-brute-find-tag-by-attribute-value
		      :prototype t
		      (semantic-tag-type-members tag))))
		   )
	    (setq proto tag))
	  )))

    proto))