Function: semantic-analyze-select-best-tag
semantic-analyze-select-best-tag is a byte-compiled function defined
in fcn.el.gz.
Signature
(semantic-analyze-select-best-tag SEQUENCE &optional TAGCLASS)
Documentation
For a SEQUENCE of tags, all with good names, pick the best one.
If SEQUENCE is made up of namespaces, merge the namespaces together. If SEQUENCE has several prototypes, find the non-prototype. If SEQUENCE has some items w/ no type information, find the one with a type. If SEQUENCE is all prototypes, or has no prototypes, get the first one. Optional TAGCLASS indicates to restrict the return to only tags of TAGCLASS.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/semantic/analyze/fcn.el.gz
;;; SELECTING
;;
;; If you narrow things down to a list of tags that all mean
;; the same thing, how to you pick one? Select or merge.
;;
(defun semantic-analyze-select-best-tag (sequence &optional tagclass)
"For a SEQUENCE of tags, all with good names, pick the best one.
If SEQUENCE is made up of namespaces, merge the namespaces together.
If SEQUENCE has several prototypes, find the non-prototype.
If SEQUENCE has some items w/ no type information, find the one with a type.
If SEQUENCE is all prototypes, or has no prototypes, get the first one.
Optional TAGCLASS indicates to restrict the return to only
tags of TAGCLASS."
;; If there is a srew up and we get just one tag.. massage over it.
(when (semantic-tag-p sequence)
(setq sequence (list sequence)))
;; Filter out anything not of TAGCLASS
(when tagclass
(setq sequence (semantic-find-tags-by-class tagclass sequence)))
(if (< (length sequence) 2)
;; If the remaining sequence is 1 tag or less, just return it
;; and skip the rest of this mumbo-jumbo.
(car sequence)
;; 1)
;; This step will eliminate a vast majority of the types,
;; in addition to merging namespaces together.
;;
;; 2)
;; It will also remove prototypes.
(require 'semantic/db-typecache)
(setq sequence (semanticdb-typecache-merge-streams sequence nil))
(if (< (length sequence) 2)
;; If the remaining sequence after the merge is 1 tag or less,
;; just return it and skip the rest of this mumbo-jumbo.
(car sequence)
(let ((best nil)
(notypeinfo nil)
)
(while (and (not best) sequence)
;; 3) select a non-prototype.
(if (not (semantic-tag-type (car sequence)))
(setq notypeinfo (car sequence))
(setq best (car sequence))
)
(setq sequence (cdr sequence)))
;; Select the best, or at least the prototype.
(or best notypeinfo)))))