Function: srecode-auto-choose-class
srecode-auto-choose-class is a byte-compiled function defined in
getset.el.gz.
Signature
(srecode-auto-choose-class POINT)
Documentation
Choose a class based on location of POINT.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/srecode/getset.el.gz
(defun srecode-auto-choose-class (point)
"Choose a class based on location of POINT."
(save-excursion
(when point
(goto-char point))
(let ((tag (semantic-current-tag-of-class 'type)))
(when (or (not tag)
(not (string= (semantic-tag-type tag) "class")))
;; The current tag is not a class. Are we in a fcn
;; that is a method?
(setq tag (semantic-current-tag-of-class 'function))
(when (and tag
(semantic-tag-function-parent tag))
(let ((p (semantic-tag-function-parent tag)))
;; @TODO : Copied below out of semantic-analyze
;; Turn into a routine.
(let* ((searchname (cond ((stringp p) p)
((semantic-tag-p p)
(semantic-tag-name p))
((and (listp p) (stringp (car p)))
(car p))))
(ptag (semantic-analyze-find-tag searchname
'type nil)))
(when ptag (setq tag ptag ))
))))
(when (or (not tag)
(not (semantic-tag-of-class-p tag 'type))
(not (string= (semantic-tag-type tag) "class")))
;; We are not in a class that needs a get/set method.
;; Analyze the current context, and derive a class name.
(let* ((ctxt (semantic-analyze-current-context))
(pfix nil)
(ans nil))
(when ctxt
(setq pfix (reverse (oref ctxt prefix)))
(while (and (not ans) pfix)
;; Start at the end and back up to the first class.
(when (and (semantic-tag-p (car pfix))
(semantic-tag-of-class-p (car pfix) 'type)
(string= (semantic-tag-type (car pfix))
"class"))
(setq ans (car pfix)))
(setq pfix (cdr pfix))))
(setq tag ans)))
tag)))