annotate lisp/cedet/semantic/analyze/fcn.el @ 104421:b66bb908c129

cedet/semantic/debug.el, cedet/semantic/doc.el, cedet/semantic/tag-write.el, cedet/semantic/analyze/complete.el, cedet/semantic/analyze/debug.el, cedet/semantic/analyze/fcn.el, cedet/semantic/analyze/refs.el: New files.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 29 Aug 2009 19:45:47 +0000
parents
children 2bf481006ba4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; semantic/analyze/fcn.el --- Analyzer support functions.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
3 ;; Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5 ;; Author: Eric M. Ludlam <zappo@gnu.org>
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; the Free Software Foundation, either version 3 of the License, or
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; (at your option) any later version.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; GNU General Public License for more details.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;;; Commentary:
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;; Analyzer support functions.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;;; Code:
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;;; Small Mode Specific Options
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;; These queries allow a major mode to help the analyzer make decisions.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 (define-overloadable-function semantic-analyze-tag-prototype-p (tag)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 "Non-nil if TAG is a prototype."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 (defun semantic-analyze-tag-prototype-p-default (tag)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 "Non-nil if TAG is a prototype."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 (let ((p (semantic-tag-get-attribute tag :prototype-flag)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 (cond
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 ;; Trust the parser author.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 (p p)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 ;; Empty types might be a prototype.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 ((eq (semantic-tag-class tag) 'type)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 (not (semantic-tag-type-members tag)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 ;; No other heuristics.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 (t nil))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 ))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 ;;------------------------------------------------------------
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 (define-overloadable-function semantic-analyze-split-name (name)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 "Split a tag NAME into a sequence.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 Sometimes NAMES are gathered from the parser that are compounded,
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 such as in C++ where foo::bar means:
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 \"The class BAR in the namespace FOO.\"
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 Return the string NAME for no change, or a list if it needs to be split.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 (defun semantic-analyze-split-name-default (name)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 "Don't split up NAME by default."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 name)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 (define-overloadable-function semantic-analyze-unsplit-name (namelist)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 "Assemble a NAMELIST into a string representing a compound name.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 Return the string representing the compound name.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 (defun semantic-analyze-unsplit-name-default (namelist)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 "Concatenate the names in NAMELIST with a . between."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 (mapconcat 'identity namelist "."))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 ;;; SELECTING
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 ;; If you narrow things down to a list of tags that all mean
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 ;; the same thing, how to you pick one? Select or merge.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 (defun semantic-analyze-select-best-tag (sequence &optional tagclass)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 "For a SEQUENCE of tags, all with good names, pick the best one.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 If SEQUENCE is made up of namespaces, merge the namespaces together.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 If SEQUENCE has several prototypes, find the non-prototype.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 If SEQUENCE has some items w/ no type information, find the one with a type.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 If SEQUENCE is all prototypes, or has no prototypes, get the first one.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 Optional TAGCLASS indicates to restrict the return to only
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 tags of TAGCLASS."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 ;; If there is a srew up and we get just one tag.. massage over it.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 (when (semantic-tag-p sequence)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 (setq sequence (list sequence)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 ;; Filter out anything not of TAGCLASS
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 (when tagclass
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 (setq sequence (semantic-find-tags-by-class tagclass sequence)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 (if (< (length sequence) 2)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 ;; If the remaining sequence is 1 tag or less, just return it
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 ;; and skip the rest of this mumbo-jumbo.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 (car sequence)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 ;; 1)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 ;; This step will eliminate a vast majority of the types,
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 ;; in addition to merging namespaces together.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 ;; 2)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 ;; It will also remove prototypes.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 (setq sequence (semanticdb-typecache-merge-streams sequence nil))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 (if (< (length sequence) 2)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 ;; If the remaining sequence after the merge is 1 tag or less,
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 ;; just return it and skip the rest of this mumbo-jumbo.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 (car sequence)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 (let ((best nil)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 (notypeinfo nil)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 (while (and (not best) sequence)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 ;; 3) select a non-prototype.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 (if (not (semantic-tag-type (car sequence)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 (setq notypeinfo (car sequence))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 (setq best (car sequence))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 (setq sequence (cdr sequence)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 ;; Select the best, or at least the prototype.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 (or best notypeinfo)))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 ;;; Tag Finding
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 ;; Mechanism for lookup up tags by name.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 (defun semantic-analyze-find-tags-by-prefix (prefix)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 ;; @todo - only used in semantic-complete. Find something better?
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 "Attempt to find a tag with PREFIX.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 This is a wrapper on top of semanticdb, and semantic search functions.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 Almost all searches use the same arguments."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 (if (and (fboundp 'semanticdb-minor-mode-p)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 (semanticdb-minor-mode-p))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 ;; Search the database & concatenate all matches together.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 (semanticdb-strip-find-results
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 (semanticdb-find-tags-for-completion prefix)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 'name)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 ;; Search just this file because there is no DB available.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 (semantic-find-tags-for-completion
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 prefix (current-buffer))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 ;;; Finding Datatypes
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 ;; Finding a data type by name within a project.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 (defun semantic-analyze-type-to-name (type)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 "Get the name of TAG's type.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 The TYPE field in a tag can be nil (return nil)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 or a string, or a non-positional tag."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 (cond ((semantic-tag-p type)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 (semantic-tag-name type))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 ((stringp type)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 type)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 ((listp type)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 (car type))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 (t nil)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 (defun semantic-analyze-tag-type (tag &optional scope nometaderef)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 "Return the semantic tag for a type within the type of TAG.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 TAG can be a variable, function or other type of tag.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 The behavior of TAG's type is defined by `semantic-analyze-type'.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 Optional SCOPE represents a calculated scope in which the
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 types might be found. This can be nil.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 If NOMETADEREF, then do not dereference metatypes. This is
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 used by the analyzer debugger."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 (semantic-analyze-type (semantic-tag-type tag) scope nometaderef))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 (defun semantic-analyze-type (type-declaration &optional scope nometaderef)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 "Return the semantic tag for TYPE-DECLARATION.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 TAG can be a variable, function or other type of tag.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 The type of tag (such as a class or struct) is a name.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 Lookup this name in database, and return all slots/fields
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 within that types field. Also handles anonymous types.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 Optional SCOPE represents a calculated scope in which the
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 types might be found. This can be nil.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 If NOMETADEREF, then do not dereference metatypes. This is
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 used by the analyzer debugger."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 (let ((name nil)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 (typetag nil)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 ;; Is it an anonymous type?
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 (if (and type-declaration
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 (semantic-tag-p type-declaration)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 (semantic-tag-of-class-p type-declaration 'type)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 (not (semantic-analyze-tag-prototype-p type-declaration))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 ;; We have an anonymous type for TAG with children.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 ;; Use this type directly.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 (if nometaderef
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 type-declaration
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 (semantic-analyze-dereference-metatype-stack
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 type-declaration scope type-declaration))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 ;; Not an anonymous type. Look up the name of this type
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 ;; elsewhere, and report back.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 (setq name (semantic-analyze-type-to-name type-declaration))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 (if (and name (not (string= name "")))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 (progn
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 ;; Find a type of that name in scope.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 (setq typetag (and scope (semantic-scope-find name 'type scope)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 ;; If no typetag, try the typecache
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 (when (not typetag)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 (setq typetag (semanticdb-typecache-find name))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 ;; No name to look stuff up with.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 (error "Semantic tag %S has no type information"
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 (semantic-tag-name type-declaration)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 ;; Handle lists of tags.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 (when (and (consp typetag) (semantic-tag-p (car typetag)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 (setq typetag (semantic-analyze-select-best-tag typetag 'type))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 ;; We now have a tag associated with the type. We need to deref it.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 ;; If we were asked not to (ie - debugger) push the typecache anyway.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 (if nometaderef
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 typetag
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 (unwind-protect
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 (progn
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 (semantic-scope-set-typecache
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229 scope (semantic-scope-tag-get-scope typetag))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 (semantic-analyze-dereference-metatype-stack typetag scope type-declaration)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 (semantic-scope-set-typecache scope nil)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 )))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235 (defun semantic-analyze-dereference-metatype-stack (type scope &optional type-declaration)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 "Dereference metatypes repeatedly until we hit a real TYPE.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 Uses `semantic-analyze-dereference-metatype'.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 Argument SCOPE is the scope object with additional items in which to search.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 Optional argument TYPE-DECLARATION is how TYPE was found referenced."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 (let ((lasttype type)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 (lasttypedeclaration type-declaration)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 (nexttype (semantic-analyze-dereference-metatype type scope type-declaration))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 (idx 0))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 (catch 'metatype-recursion
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 (while (and nexttype (not (eq (car nexttype) lasttype)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 (setq lasttype (car nexttype)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 lasttypedeclaration (cadr nexttype))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 (setq nexttype (semantic-analyze-dereference-metatype lasttype scope lasttypedeclaration))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 (setq idx (1+ idx))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 (when (> idx 20) (message "Possible metatype recursion for %S"
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 (semantic-tag-name lasttype))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 (throw 'metatype-recursion nil))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 ))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 lasttype))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 (define-overloadable-function semantic-analyze-dereference-metatype (type scope &optional type-declaration)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 ;; todo - move into typecahe!!
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 "Return a concrete type tag based on input TYPE tag.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 A concrete type is an actual declaration of a memory description,
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 such as a structure, or class. A meta type is an alias,
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 or a typedef in C or C++. If TYPE is concrete, it
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 is returned. If it is a meta type, it will return the concrete
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 type defined by TYPE.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 The default behavior always returns TYPE.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 Override functions need not return a real semantic tag.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 Just a name, or short tag will be ok. It will be expanded here.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 SCOPE is the scope object with additional items in which to search for names."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 (catch 'default-behavior
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 (let* ((ans-tuple (:override
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 ;; Nothing fancy, just return type by default.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 (throw 'default-behavior (list type type-declaration))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 (ans-type (car ans-tuple))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 (ans-type-declaration (cadr ans-tuple)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 (list (semantic-analyze-dereference-metatype-1 ans-type scope) ans-type-declaration))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 ;; @ TODO - the typecache can also return a stack of scope names.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 (defun semantic-analyze-dereference-metatype-1 (ans scope)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 "Do extra work after dereferencing a metatype.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 ANS is the answer from the the language specific query.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 SCOPE is the current scope."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 ;; If ANS is a string, or if ANS is a short tag, we
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 ;; need to do some more work to look it up.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284 (if (stringp ans)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 ;; The metatype is just a string... look it up.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 (or (and scope (car-safe
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 ;; @todo - should this be `find the best one'?
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 (semantic-scope-find ans 'type scope)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 (let ((tcsans nil))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 (prog1
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 (setq tcsans
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 (semanticdb-typecache-find ans))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 ;; While going through the metatype, if we have
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 ;; a scope, push our new cache in.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 (when scope
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 (semantic-scope-set-typecache
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 scope (semantic-scope-tag-get-scope tcsans))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 ))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 ))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 (when (and (semantic-tag-p ans)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 (eq (semantic-tag-class ans) 'type))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 ;; We have a tag.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 (if (semantic-analyze-tag-prototype-p ans)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 ;; It is a prototype.. find the real one.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 (or (and scope
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 (car-safe
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 (semantic-scope-find (semantic-tag-name ans)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 'type scope)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 (let ((tcsans nil))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 (prog1
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 (setq tcsans
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 (semanticdb-typecache-find (semantic-tag-name ans)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 ;; While going through the metatype, if we have
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 ;; a scope, push our new cache in.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 (when scope
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 (semantic-scope-set-typecache
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 scope (semantic-scope-tag-get-scope tcsans))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 ))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 ;; We have a tag, and it is not a prototype.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 ans))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 ))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 (provide 'semantic/analyze/fcn)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 ;;; semantic/analyze/fcn.el ends here