Function: semantic-adopt-external-members
semantic-adopt-external-members is a byte-compiled function defined in
sort.el.gz.
Signature
(semantic-adopt-external-members TAGS)
Documentation
Rebuild TAGS so that externally defined members are regrouped.
Some languages such as C++ and CLOS permit the declaration of member functions outside the definition of the class. It is easier to study the structure of a program when such methods are grouped together more logically.
This function uses semantic-tag-external-member-p to
determine when a potential child is an externally defined member.
Note: Applications which use this function must account for token types which do not have a position, but have children which *do* have positions.
Applications should use semantic-mark-external-member-function
to modify all tags which are found as externally defined to some
type. For example, changing the token type for generating extra
buckets with the bucket function.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/semantic/sort.el.gz
(defun semantic-adopt-external-members (tags)
"Rebuild TAGS so that externally defined members are regrouped.
Some languages such as C++ and CLOS permit the declaration of member
functions outside the definition of the class. It is easier to study
the structure of a program when such methods are grouped together
more logically.
This function uses `semantic-tag-external-member-p' to
determine when a potential child is an externally defined member.
Note: Applications which use this function must account for token
types which do not have a position, but have children which *do*
have positions.
Applications should use `semantic-mark-external-member-function'
to modify all tags which are found as externally defined to some
type. For example, changing the token type for generating extra
buckets with the bucket function."
(let ((parent-buckets nil)
(decent-list nil)
(out nil)
(tmp nil)
)
;; Rebuild the output list, stripping out all parented
;; external entries
(while tags
(cond
((setq tmp (semantic-tag-external-member-parent (car tags)))
(let ((tagcopy (semantic-tag-clone (car tags)))
(a (assoc tmp parent-buckets)))
(semantic--tag-put-property-no-side-effect tagcopy 'adopted t)
(if a
;; If this parent is already in the list, append.
(setcdr (nthcdr (1- (length a)) a) (list tagcopy))
;; If not, prepend this new parent bucket into our list
(setq parent-buckets
(cons (cons tmp (list tagcopy)) parent-buckets)))
))
((eq (semantic-tag-class (car tags)) 'type)
;; Types need to be rebuilt from scratch so we can add in new
;; children to the child list. Only the top-level cons
;; cells need to be duplicated so we can hack out the
;; child list later.
(setq out (cons (semantic-tag-clone (car tags)) out))
(setq decent-list (cons (car out) decent-list))
)
(t
;; Otherwise, append this tag to our new output list.
(setq out (cons (car tags) out)))
)
(setq tags (cdr tags)))
;; Rescan out, by descending into all types and finding parents
;; for all entries moved into the parent-buckets.
(while decent-list
(let* ((bucket (assoc (semantic-tag-name (car decent-list))
parent-buckets))
(bucketkids (cdr bucket)))
(when bucket
;; Run our secondary marking function on the children
(if semantic-mark-external-member-function
(setq bucketkids
(mapcar (lambda (tok)
(funcall semantic-mark-external-member-function
tok (car decent-list)))
bucketkids)))
;; We have some extra kids. Merge.
(semantic-tag-put-attribute
(car decent-list) :members
(append (semantic-tag-type-members (car decent-list))
bucketkids))
;; Nuke the bucket label so it is not found again.
(setcar bucket nil))
(setq decent-list
(append (cdr decent-list)
;; get embedded types to scan and make copies
;; of them.
(mapcar
;; Must use lambda because `semantic-tag-clone' is a defsubst.
(lambda (tok) (semantic-tag-clone tok))
(semantic-find-tags-by-class 'type
(semantic-tag-type-members (car decent-list)))))
)))
;; Scan over all remaining lost external methods, and tack them
;; onto the end.
(while parent-buckets
(if (car (car parent-buckets))
(let* ((tmp (car parent-buckets))
(fauxtag (semantic-tag-new-type
(car tmp)
semantic-orphaned-member-metaparent-type
nil ;; Part list
nil ;; parents (unknown)
))
(bucketkids (cdr tmp)))
(semantic-tag-set-faux fauxtag) ;; properties
(if semantic-mark-external-member-function
(setq bucketkids
(mapcar (lambda (tok)
(funcall semantic-mark-external-member-function
tok fauxtag))
bucketkids)))
(semantic-tag-put-attribute fauxtag :members bucketkids)
;; We have a bunch of methods with no parent in this file.
;; Create a meta-type to hold it.
(setq out (cons fauxtag out))
))
(setq parent-buckets (cdr parent-buckets)))
;; Return the new list.
(nreverse out)))