annotate lisp/cedet/semantic/analyze/refs.el @ 110534:826d60163924

Merge changes from emacs-23 branch.
author Chong Yidong <cyd@stupidchicken.com>
date Thu, 23 Sep 2010 22:10:54 -0400
parents a5ad4f188e19
children 376148b31b5e
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/refs.el --- Analysis of the references between tags.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 105842
diff changeset
3 ;; Copyright (C) 2008, 2009, 2010 Free Software Foundation, Inc.
104421
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 ;; Analyze the references between tags.
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 ;; The original purpose of these analysis is to provide a way to jump
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;; between a prototype and implementation.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;; Finding all prototype/impl matches is hard because you have to search
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;; through the entire set of allowed databases to capture all possible
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;; refs. The core analysis class stores basic starting point, and then
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 ;; entire raw search data, which is expensive to calculate.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;; Once the raw data is available, queries for impl, prototype, or
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 ;; perhaps other things become cheap.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36
104456
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
37 (require 'semantic)
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
38 (require 'semantic/analyze)
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
39 (require 'semantic/db-find)
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
40 (eval-when-compile (require 'semantic/find))
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
41
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
42 (declare-function data-debug-new-buffer "data-debug")
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
43 (declare-function data-debug-insert-object-slots "eieio-datadebug")
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
44 (declare-function semantic-momentary-highlight-tag "semantic/decorate")
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
45
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 ;;; Code:
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 (defclass semantic-analyze-references ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 ((tag :initarg :tag
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 :type semantic-tag
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 :documentation
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 "The starting TAG we are providing references analysis for.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 (tagdb :initarg :tagdb
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 :documentation
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 "The database that tag can be found in.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 (scope :initarg :scope
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 :documentation "A Scope object.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 (rawsearchdata :initarg :rawsearchdata
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 :documentation
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 "The raw search data for TAG's name across all databases.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 ;; Note: Should I cache queried data here? I expect that searching
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 ;; through rawsearchdata will be super-fast, so why bother?
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 "Class containing data from a semantic analysis.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 (define-overloadable-function semantic-analyze-tag-references (tag &optional db)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 "Analyze the references for TAG.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 Returns a class with information about TAG.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 Optional argument DB is a database. It will be used to help
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 locate TAG.
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 Use `semantic-analyze-current-tag' to debug this fcn.")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 (defun semantic-analyze-tag-references-default (tag &optional db)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 "Analyze the references for TAG.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 Returns a class with information about TAG.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 Optional argument DB is a database. It will be used to help
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 locate TAG.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 Use `semantic-analyze-current-tag' to debug this fcn."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 (when (not (semantic-tag-p tag)) (signal 'wrong-type-argument (list 'semantic-tag-p tag)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 (let ((allhits nil)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 (scope nil)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 (save-excursion
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 (semantic-go-to-tag tag db)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 (setq scope (semantic-calculate-scope))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 (setq allhits (semantic--analyze-refs-full-lookup tag scope))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 (semantic-analyze-references (semantic-tag-name tag)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 :tag tag
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 :tagdb db
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 :scope scope
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 :rawsearchdata allhits)
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
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 ;;; METHODS
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 ;; These accessor methods will calculate the useful bits from the context, and cache values
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 ;; into the context.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 (defmethod semantic-analyze-refs-impl ((refs semantic-analyze-references) &optional in-buffer)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 "Return the implementations derived in the reference analyzer REFS.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 Optional argument IN-BUFFER indicates that the returned tag should be in an active buffer."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 (let ((allhits (oref refs rawsearchdata))
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
107 (tag (oref refs :tag))
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 (impl nil)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 (semanticdb-find-result-mapc
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 (lambda (T DB)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 "Examine T in the database DB, and sont it."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 (let* ((ans (semanticdb-normalize-one-tag DB T))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 (aT (cdr ans))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 (aDB (car ans))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 )
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
117 (when (and (not (semantic-tag-prototype-p aT))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
118 (semantic-tag-similar-p tag aT :prototype-flag :parent))
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 (when in-buffer (save-excursion (semantic-go-to-tag aT aDB)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 (push aT impl))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 allhits)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 impl))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 (defmethod semantic-analyze-refs-proto ((refs semantic-analyze-references) &optional in-buffer)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 "Return the prototypes derived in the reference analyzer REFS.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 Optional argument IN-BUFFER indicates that the returned tag should be in an active buffer."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 (let ((allhits (oref refs rawsearchdata))
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
128 (tag (oref refs :tag))
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 (proto nil))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 (semanticdb-find-result-mapc
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 (lambda (T DB)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 "Examine T in the database DB, and sort it."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 (let* ((ans (semanticdb-normalize-one-tag DB T))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 (aT (cdr ans))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 (aDB (car ans))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 )
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
137 (when (and (semantic-tag-prototype-p aT)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
138 (semantic-tag-similar-p tag aT :prototype-flag :parent))
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 (when in-buffer (save-excursion (semantic-go-to-tag aT aDB)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 (push aT proto))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 allhits)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 proto))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 ;;; LOOKUP
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 ;;
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 (defun semantic--analyze-refs-full-lookup (tag scope)
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 104470
diff changeset
147 "Perform a full lookup for all occurrences of TAG in the current project.
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 TAG should be the tag currently under point.
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
149 SCOPE is the scope the cursor is in. From this a list of parents is
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
150 derived. If SCOPE does not have parents, then only a simple lookup is done."
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 (if (not (oref scope parents))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 ;; If this tag has some named parent, but is not
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 (semantic--analyze-refs-full-lookup-simple tag)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 ;; We have some sort of lineage we need to consider when we do
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 ;; our side lookup of tags.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 (semantic--analyze-refs-full-lookup-with-parents tag scope)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 ))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 (defun semantic--analyze-refs-find-child-in-find-results (find-results name class)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 "Find in FIND-RESULT a tag NAME which is a child of a tag in FIND-RESULTS.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 CLASS is the class of the tag that ought to be returned."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 (let ((ans nil)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 (subans nil))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 ;; Loop over each segment of the find results.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 (dolist (FDB find-results)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 (setq subans nil)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 ;; Loop over each tag in the find results.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 (dolist (T (cdr FDB))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 ;; For each tag, get the children.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 (let* ((chil (semantic-tag-type-members T))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 (match (semantic-find-tags-by-name name chil)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 ;; Go over the matches, looking for matching tag class.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 (dolist (M match)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 (when (semantic-tag-of-class-p M class)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 (push M subans)))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 ;; Store current matches into a new find results.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 (when subans
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 (push (cons (car FDB) subans) ans))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 ans))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 (defun semantic--analyze-refs-find-tags-with-parent (find-results parents)
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
184 "Find in FIND-RESULTS all tags with PARENTS.
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 NAME is the name of the tag needing finding.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 PARENTS is a list of names."
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
187 (let ((ans nil) (usingnames nil))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
188 ;; Loop over the find-results passed in.
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 (semanticdb-find-result-mapc
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 (lambda (tag db)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 (let* ((p (semantic-tag-named-parent tag))
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
192 (ps (when (stringp p) (semantic-analyze-split-name p))))
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 (when (stringp ps) (setq ps (list ps)))
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
194 (when ps
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
195 ;; If there is a perfect match, then use it.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
196 (if (equal ps parents)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
197 (push (list db tag) ans))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
198 ;; No match, find something from our list of using names.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
199 ;; Do we need to split UN?
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
200 (save-excursion
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
201 (semantic-go-to-tag tag db)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
202 (setq usingnames nil)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
203 (let ((imports (semantic-ctxt-imported-packages)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
204 ;; Derive the names from all the using statements.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
205 (mapc (lambda (T)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
206 (setq usingnames
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
207 (cons (semantic-format-tag-name-from-anything T) usingnames)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
208 imports))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
209 (dolist (UN usingnames)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
210 (when (equal (cons UN ps) parents)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
211 (push (list db tag) ans)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
212 (setq usingnames (cdr usingnames))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
213 ))))
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 find-results)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215 ans))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 (defun semantic--analyze-refs-full-lookup-with-parents (tag scope)
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 104470
diff changeset
218 "Perform a lookup for all occurrences of TAG based on TAG's SCOPE.
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 TAG should be the tag currently under point."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 (let* ((classmatch (semantic-tag-class tag))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 (plist (mapcar (lambda (T) (semantic-tag-name T)) (oref scope parents)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 ;; The first item in the parent list
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 (name (car plist))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 ;; Stuff from the simple list.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 (simple (semantic--analyze-refs-full-lookup-simple tag t))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 ;; Find all hits for the first parent name.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 (brute (semanticdb-find-tags-collector
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 (lambda (table tags)
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
229 (semanticdb-deep-find-tags-by-name-method table name tags)
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 nil nil t))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 ;; Prime the answer.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 (answer (semantic--analyze-refs-find-tags-with-parent simple plist))
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 ;; First parent is already search to initialize "brute".
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 (setq plist (cdr plist))
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
237
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 ;; Go through the list of parents, and try to find matches.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 ;; As we cycle through plist, for each level look for NAME,
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 ;; and compare the named-parent, and also dive into the next item of
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 ;; plist.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 (while (and plist brute)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 ;; Find direct matches
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 (let* ((direct (semantic--analyze-refs-find-child-in-find-results
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 brute (semantic-tag-name tag) classmatch))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 (pdirect (semantic--analyze-refs-find-tags-with-parent
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 direct plist)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 (setq answer (append pdirect answer)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 ;; The next set of search items.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 (setq brute (semantic--analyze-refs-find-child-in-find-results
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 brute (car plist) 'type))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 (setq plist (cdr plist)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 ;; Brute now has the children from the very last match.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 (let* ((direct (semantic--analyze-refs-find-child-in-find-results
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 brute (semantic-tag-name tag) classmatch))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 (setq answer (append direct answer)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 answer))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 (defun semantic--analyze-refs-full-lookup-simple (tag &optional noerror)
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 104470
diff changeset
266 "Perform a simple lookup for occurrences of TAG in the current project.
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 TAG should be the tag currently under point.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 Optional NOERROR means don't throw errors on failure to find something.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 This only compares the tag name, and does not infer any matches in namespaces,
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 or parts of some other data structure.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 Only works for tags in the global namespace."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 (let* ((name (semantic-tag-name tag))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 (brute (semanticdb-find-tags-collector
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 (lambda (table tags)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 (semanticdb-find-tags-by-name-method table name tags)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 )
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
277 nil ;; This may need to be the entire project??
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
278 nil t))
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 (when (and (not brute) (not noerror))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 ;; An error, because tag under point ought to be found.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 (error "Cannot find any references to %s in wide search" name))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 (let* ((classmatch (semantic-tag-class tag))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 (RES
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 (semanticdb-find-tags-collector
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 (lambda (table tags)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 (semantic-find-tags-by-class classmatch tags)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 ;; @todo - Add parent check also.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 brute nil)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 (when (and (not RES) (not noerror))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 (error "Cannot find any definitions for %s in wide search"
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 (semantic-tag-name tag)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 ;; Return the matching tags and databases.
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 RES)))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 ;;; USER COMMANDS
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 ;;
104456
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
304 ;;;###autoload
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 (defun semantic-analyze-current-tag ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 "Analyze the tag under point."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 (interactive)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 (let* ((tag (semantic-current-tag))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 (start (current-time))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 (sac (semantic-analyze-tag-references tag))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 (end (current-time))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 (message "Analysis took %.2f seconds." (semantic-elapsed-time start end))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 (if sac
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 (progn
104456
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
316 (require 'eieio-datadebug)
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 (data-debug-new-buffer "*Analyzer Reference ADEBUG*")
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 (data-debug-insert-object-slots sac "]"))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 (message "No Context to analyze here."))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320
104456
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
321 ;;;###autoload
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322 (defun semantic-analyze-proto-impl-toggle ()
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 "Toggle between the implementation, and a prototype of tag under point."
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 (interactive)
104456
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
325 (require 'semantic/decorate)
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 (semantic-fetch-tags)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 (let* ((tag (semantic-current-tag))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 (sar (if tag
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 (semantic-analyze-tag-references tag)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 (error "Point must be in a declaration")))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 (target (if (semantic-tag-prototype-p tag)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 (car (semantic-analyze-refs-impl sar t))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333 (car (semantic-analyze-refs-proto sar t))))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 (when (not target)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 (error "Could not find suitable %s"
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 (if (semantic-tag-prototype-p tag) "implementation" "prototype")))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 (push-mark)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341 (semantic-go-to-tag target)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 (switch-to-buffer (current-buffer))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 (semantic-momentary-highlight-tag target))
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 )
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346 (provide 'semantic/analyze/refs)
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347
104456
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
348 ;; Local variables:
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
349 ;; generated-autoload-file: "../loaddefs.el"
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
350 ;; generated-autoload-load-name: "semantic/analyze/refs"
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
351 ;; End:
6065d66f0c99 lisp/cedet/semantic/db-ref.el: Require semantic/db.
Chong Yidong <cyd@stupidchicken.com>
parents: 104421
diff changeset
352
105377
7f4c7f5c0eba Add arch tagline
Miles Bader <miles@gnu.org>
parents: 105340
diff changeset
353 ;; arch-tag: f8c59a91-1829-42b3-b083-437c6881841c
104421
b66bb908c129 cedet/semantic/debug.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 ;;; semantic/analyze/refs.el ends here