annotate lisp/cedet/semantic/scope.el @ 104437:11587959f51d

cedet/semantic/decorate.el: New file.
author Chong Yidong <cyd@stupidchicken.com>
date Sun, 30 Aug 2009 14:39:12 +0000
parents 52067a6bf088
children df08b7ab0ba0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; semantic/scope.el --- Analyzer Scope Calculations
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
3 ;; Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; the Free Software Foundation, either version 3 of the License, or
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; (at your option) any later version.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; GNU General Public License for more details.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;;; Commentary:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;; Calculate information about the current scope.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; Manages the current scope as a structure that can be cached on a
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;; per-file basis and recycled between different occurances of
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;; analysis on different parts of a file.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;; Pattern for Scope Calculation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 ;; Step 1: Calculate DataTypes in Scope:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;; a) What is in scope via using statements or local namespaces
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 ;; b) Lineage of current context. Some names drawn from step 1.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 ;; Step 2: Convert type names into lists of concrete tags
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 ;; a) Convert each datatype into the real datatype tag
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 ;; b) Convert namespaces into the list of contents of the namespace.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 ;; c) Merge all existing scopes together into one search list.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 ;; Step 3: Local variables
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 ;; a) Local variables are in the master search list.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 (require 'semantic/db)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 (require 'semantic/analyze/fcn)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 (require 'semantic/ctxt)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 ;;; Code:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 (defclass semantic-scope-cache (semanticdb-abstract-cache)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 ((tag :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 "The tag this scope was calculated for.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 (scopetypes :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 "The list of types currently in scope.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 For C++, this would contain anonymous namespaces known, and
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 anything labled by a `using' statement.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 (parents :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 "List of parents in scope w/in the body of this function.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 Presumably, the members of these parent classes are available for access
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 based on private:, or public: style statements.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 (parentinheritance :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 :documentation "Alist of parents by inheritance.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 Each entry is ( PARENT . PROTECTION ), where PARENT is a type, and
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 PROTECTION is a symbol representing the level of inheritance, such as 'private, or 'protected.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 (scope :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 "Items in scope due to the scopetypes or parents.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 (fullscope :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 "All the other stuff on one master list you can search.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 (localargs :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 "The arguments to the function tag.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 (localvar :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 "The local variables.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 (typescope :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 "Slot to save intermediate scope while metatypes are dereferenced.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 "Cache used for storage of the current scope by the Semantic Analyzer.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 Saves scoping information between runs of the analyzer.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 ;;; METHODS
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 ;; Methods for basic management of the structure in semanticdb.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 (defmethod semantic-reset ((obj semantic-scope-cache))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 "Reset OBJ back to it's empty settings."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 (oset obj tag nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 (oset obj scopetypes nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 (oset obj parents nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 (oset obj parentinheritance nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 (oset obj scope nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 (oset obj fullscope nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 (oset obj localargs nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 (oset obj localvar nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 (oset obj typescope nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 (defmethod semanticdb-synchronize ((cache semantic-scope-cache)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 new-tags)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 "Synchronize a CACHE with some NEW-TAGS."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 (semantic-reset cache))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 (defmethod semanticdb-partial-synchronize ((cache semantic-scope-cache)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 new-tags)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 "Synchronize a CACHE with some changed NEW-TAGS."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 ;; If there are any includes or datatypes changed, then clear.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 (if (or (semantic-find-tags-by-class 'include new-tags)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 (semantic-find-tags-by-class 'type new-tags)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 (semantic-find-tags-by-class 'using new-tags))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 (semantic-reset cache))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 (defun semantic-scope-reset-cache ()
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 "Get the current cached scope, and reset it."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 (when semanticdb-current-table
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 (let ((co (semanticdb-cache-get semanticdb-current-table
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 semantic-scope-cache)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 (semantic-reset co))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 (defmethod semantic-scope-set-typecache ((cache semantic-scope-cache)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 types-in-scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 "Set the :typescope property on CACHE to some types.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 TYPES-IN-SCOPE is a list of type tags whos members are
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 currently in scope. For each type in TYPES-IN-SCOPE,
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 add those members to the types list.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 If nil, then the typescope is reset."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 (let ((newts nil)) ;; New Type Scope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 (dolist (onetype types-in-scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 (setq newts (append (semantic-tag-type-members onetype)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 newts))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 (oset cache typescope newts)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 ;;; TAG SCOPES
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 ;; These fcns should be used by search routines that return a single
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 ;; tag which, in turn, may have come from a deep scope. The scope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 ;; will be attached to the tag. Thus, in future scope based calls, a
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 ;; tag can be passed in and a scope derived from it.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 (defun semantic-scope-tag-clone-with-scope (tag scopetags)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 "Close TAG, and return it. Add SCOPETAGS as a tag-local scope.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 Stores the SCOPETAGS as a set of tag properties on the cloned tag."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 (let ((clone (semantic-tag-clone tag))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 (semantic--tag-put-property clone 'scope scopetags)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 (defun semantic-scope-tag-get-scope (tag)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 "Get from TAG the list of tags comprising the scope from TAG."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 (semantic--tag-get-property tag 'scope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 ;;; SCOPE UTILITIES
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 ;; Functions that do the main scope calculations
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 (define-overloadable-function semantic-analyze-scoped-types (position)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 "Return a list of types currently in scope at POSITION.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 This is based on what tags exist at POSITION, and any associated
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 types available.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 (defun semantic-analyze-scoped-types-default (position)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 "Return a list of types currently in scope at POSITION.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 Use `semantic-ctxt-scoped-types' to find types."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 (save-excursion
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 (goto-char position)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 (let ((code-scoped-types nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 ;; Lets ask if any types are currently scoped. Scoped
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 ;; classes and types provide their public methods and types
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 ;; in source code, but are unrelated hierarchically.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 (let ((sp (semantic-ctxt-scoped-types)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 (while sp
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 ;; Get this thing as a tag
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 (let ((tmp (cond
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 ((stringp (car sp))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 (semanticdb-typecache-find (car sp)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 ;(semantic-analyze-find-tag (car sp) 'type))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 ((semantic-tag-p (car sp))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 (if (semantic-analyze-tag-prototype-p (car sp))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 (semanticdb-typecache-find (semantic-tag-name (car sp)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 ;;(semantic-analyze-find-tag (semantic-tag-name (car sp)) 'type)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 (car sp)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 (t nil))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 (when tmp
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 (setq code-scoped-types
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 (cons tmp code-scoped-types))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 (setq sp (cdr sp))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 (setq code-scoped-types (nreverse code-scoped-types))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203 (when code-scoped-types
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 (semanticdb-typecache-merge-streams code-scoped-types nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 ;;------------------------------------------------------------
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 (define-overloadable-function semantic-analyze-scope-nested-tags (position scopedtypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 "Return a list of types in order of nesting for the context of POSITION.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 If POSITION is in a method with a named parent, find that parent, and
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 identify it's scope via overlay instead.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 Optional SCOPETYPES are additional scoped entities in which our parent might
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 be found.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 (defun semantic-analyze-scope-nested-tags-default (position scopetypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 "Return a list of types in order of nesting for the context of POSITION.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 If POSITION is in a method with a named parent, find that parent, and
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 identify it's scope via overlay instead.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 Optional SCOPETYPES are additional scoped entities in which our parent might
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 be found.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 This only finds ONE immediate parent by name. All other parents returned
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 are from nesting data types."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 (save-excursion
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 (if position (goto-char position))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 (let* ((stack (reverse (semantic-find-tag-by-overlay (point))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 (tag (car stack))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 (pparent (car (cdr stack)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229 (returnlist nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 ;; In case of arg lists or some-such, throw out non-types.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 (while (and stack (not (semantic-tag-of-class-p pparent 'type)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 (setq stack (cdr stack)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 pparent (car (cdr stack))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 ;; Step 1:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 ;; Analyze the stack of tags we are nested in as parents.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 ;; If we have a pparent tag, lets go there
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 ;; an analyze that stack of tags.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 (when (and pparent (semantic-tag-with-position-p pparent))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 (semantic-go-to-tag pparent)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 (setq stack (semantic-find-tag-by-overlay (point)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 ;; Step one, find the merged version of stack in the typecache.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 (let* ((stacknames (reverse (mapcar 'semantic-tag-name stack)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 (tc nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 ;; @todo - can we use the typecache ability to
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 ;; put a scope into a tag to do this?
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 (while (and stacknames
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 (setq tc (semanticdb-typecache-find
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 (reverse stacknames))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 (setq returnlist (cons tc returnlist)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 stacknames (cdr stacknames)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 (when (not returnlist)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 ;; When there was nothing from the typecache, then just
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 ;; use what's right here.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 (setq stack (reverse stack))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 ;; Add things to STACK until we cease finding tags of class type.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 (while (and stack (eq (semantic-tag-class (car stack)) 'type))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 ;; Otherwise, just add this to the returnlist.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 (setq returnlist (cons (car stack) returnlist))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 (setq stack (cdr stack)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 (setq returnlist (nreverse returnlist))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 ;; Only do this level of analysis for functions.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 (when (eq (semantic-tag-class tag) 'function)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 ;; Step 2:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 ;; If the function tag itself has a "parent" by name, then that
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 ;; parent will exist in the scope we just calculated, so look it
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 ;; up now.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 (let ((p (semantic-tag-function-parent tag)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 (when p
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 ;; We have a parent, search for it.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 (let* ((searchnameraw (cond ((stringp p) p)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 ((semantic-tag-p p)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 (semantic-tag-name p))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 ((and (listp p) (stringp (car p)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284 (car p))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 (searchname (semantic-analyze-split-name searchnameraw))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 (snlist (if (consp searchname)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 searchname
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 (list searchname)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 (fullsearchname nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 (miniscope (semantic-scope-cache "mini"))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 ptag)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 ;; Find the next entry in the refereneced type for
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 ;; our function, and append to return list till our
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 ;; returnlist is empty.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 (while snlist
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 (setq fullsearchname
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 (append (mapcar 'semantic-tag-name returnlist)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 (list (car snlist)))) ;; Next one
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 (setq ptag
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 (semanticdb-typecache-find fullsearchname))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 (when (or (not ptag)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 (not (semantic-tag-of-class-p ptag 'type)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 (let ((rawscope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 (apply 'append
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 (mapcar 'semantic-tag-type-members
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 (cons (car returnlist) scopetypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 (oset miniscope parents returnlist) ;; Not really accurate, but close
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 (oset miniscope scope rawscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 (oset miniscope fullscope rawscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 (setq ptag
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 (semantic-analyze-find-tag searchnameraw
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 'type
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 miniscope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322 (when ptag
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 (when (and (not (semantic-tag-p ptag))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 (semantic-tag-p (car ptag)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 (setq ptag (car ptag)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 (setq returnlist (append returnlist (list ptag)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 (setq snlist (cdr snlist)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 (setq returnlist returnlist)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333 returnlist
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 (define-overloadable-function semantic-analyze-scope-lineage-tags (parents scopedtypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 "Return the full lineage of tags from PARENTS.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 The return list is of the form ( TAG . PROTECTION ), where TAG is a tag,
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339 and PROTECTION is the level of protection offered by the relationship.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 Optional SCOPETYPES are additional scoped entities in which our parent might
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341 be found.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 (defun semantic-analyze-scope-lineage-tags-default (parents scopetypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 "Return the full lineage of tags from PARENTS.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 The return list is of the form ( TAG . PROTECTION ), where TAG is a tag,
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346 and PROTECTION is the level of protection offered by the relationship.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347 Optional SCOPETYPES are additional scoped entities in which our parent might
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 be found."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349 (let ((lineage nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 (miniscope (semantic-scope-cache "mini"))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 (oset miniscope parents parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 (oset miniscope scope scopetypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 (oset miniscope fullscope scopetypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
356 (dolist (slp parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
357 (semantic-analyze-scoped-inherited-tag-map
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 slp (lambda (newparent)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 (let* ((pname (semantic-tag-name newparent))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 (prot (semantic-tag-type-superclass-protection slp pname))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 (effectiveprot (cond ((eq prot 'public)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 ;; doesn't provide access to private slots?
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 'protected)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 (t prot))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 (push (cons newparent effectiveprot) lineage)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 miniscope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 lineage))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 ;;------------------------------------------------------------
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 (define-overloadable-function semantic-analyze-scoped-tags (typelist parentlist)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 "Return accessable tags when TYPELIST and PARENTLIST is in scope.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 Tags returned are not in the global name space, but are instead
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 scoped inside a class or namespace. Such items can be referenced
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 without use of \"object.function()\" style syntax due to an
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 implicit \"object\".")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 (defun semantic-analyze-scoped-tags-default (typelist halfscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 "Return accessable tags when TYPELIST and HALFSCOPE is in scope.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 HALFSCOPE is the current scope partially initialized.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 Tags returned are not in the global name space, but are instead
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 scoped inside a class or namespace. Such items can be referenced
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 without use of \"object.function()\" style syntax due to an
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 implicit \"object\"."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 (let ((typelist2 nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 (currentscope nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 (parentlist (oref halfscope parents))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 (miniscope halfscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 ;; Loop over typelist, and find and merge all namespaces matching
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 ;; the names in typelist.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 (while typelist
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 (let ((tt (semantic-tag-type (car typelist))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 (when (and (stringp tt) (string= tt "namespace"))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 ;; By using the typecache, our namespaces are pre-merged.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 (setq typelist2 (cons (car typelist) typelist2))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 (setq typelist (cdr typelist)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 ;; Loop over the types (which should be sorted by postion
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 ;; adding to the scopelist as we go, and using the scopelist
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 ;; for additional searching!
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 (while typelist2
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407 (oset miniscope scope currentscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 (oset miniscope fullscope currentscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 (setq currentscope (append
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 (semantic-analyze-scoped-type-parts (car typelist2)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411 miniscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 currentscope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413 (setq typelist2 (cdr typelist2)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 ;; Collect all the types (class, etc) that are in our heratage.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 ;; These are types that we can extract members from, not those
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 ;; delclared in using statements, or the like.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 ;; Get the PARENTS including nesting scope for this location.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 (while parentlist
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 (oset miniscope scope currentscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 (oset miniscope fullscope currentscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 (setq currentscope (append
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 (semantic-analyze-scoped-type-parts (car parentlist)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 miniscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
425 currentscope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 (setq parentlist (cdr parentlist)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428 ;; Loop over all the items, and collect any type constants.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 (let ((constants nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 (dolist (T currentscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431 (setq constants (append constants
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 (semantic-analyze-type-constants T)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 (setq currentscope (append currentscope constants)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 currentscope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 ;;------------------------------------------------------------
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 (define-overloadable-function semantic-analyze-scope-calculate-access (type scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441 "Calculate the access class for TYPE as defined by the current SCOPE.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 Access is related to the :parents in SCOPE. If type is a member of SCOPE
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 then access would be 'private. If TYPE is inherited by a member of SCOPE,
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 the access would be 'protected. Otherwise, access is 'public")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 (defun semantic-analyze-scope-calculate-access-default (type scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 "Calculate the access class for TYPE as defined by the current SCOPE."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448 (cond ((semantic-scope-cache-p scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449 (let ((parents (oref scope parents))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 (parentsi (oref scope parentinheritance))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
451 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 (catch 'moose
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
453 ;; Investigate the parent, and see how it relates to type.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
454 ;; If these tags are basically the same, then we have full access.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
455 (dolist (p parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
456 (when (semantic-tag-similar-p type p)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457 (throw 'moose 'private))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 ;; Look to see if type is in our list of inherited parents.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
460 (dolist (pi parentsi)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461 ;; pi is a cons cell ( PARENT . protection)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462 (let ((pip (car pi))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 (piprot (cdr pi)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464 (when (semantic-tag-similar-p type pip)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 (throw 'moose
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
466 ;; protection via inheritance means to pull out different
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
467 ;; bits based on protection labels in an opposite way.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468 (cdr (assoc piprot
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
469 '((public . private)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 (protected . protected)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
471 (private . public))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
472 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
474 ;; Not in our parentage. Is type a FRIEND?
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
475 (let ((friends (semantic-find-tags-by-class 'friend (semantic-tag-type-members type))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
476 (dolist (F friends)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
477 (dolist (pi parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478 (if (string= (semantic-tag-name F) (semantic-tag-name pi))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
479 (throw 'moose 'private))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
480 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
481 ;; Found nothing, return public
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482 'public)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
484 (t 'public)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
485
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
486 (defun semantic-completable-tags-from-type (type)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
487 "Return a list of slots that are valid completions from the list of SLOTS.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
488 If a tag in SLOTS has a named parent, then that implies that the
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
489 tag is not something you can complete from within TYPE."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
490 (let ((allslots (semantic-tag-components type))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
491 (leftover nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
492 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
493 (dolist (S allslots)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
494 (when (or (not (semantic-tag-of-class-p S 'function))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
495 (not (semantic-tag-function-parent S)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
496 (setq leftover (cons S leftover)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
497 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
498 (nreverse leftover)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
499
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
500 (defun semantic-analyze-scoped-type-parts (type &optional scope noinherit protection)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
501 "Return all parts of TYPE, a tag representing a TYPE declaration.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
502 SCOPE is the scope object.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
503 NOINHERIT turns off searching of inherited tags.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
504 PROTECTION specifies the type of access requested, such as 'public or 'private."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
505 (if (not type)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
506 nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
507 (let* ((access (semantic-analyze-scope-calculate-access type scope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
508 ;; SLOTS are the slots directly a part of TYPE.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
509 (allslots (semantic-completable-tags-from-type type))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
510 (slots (semantic-find-tags-by-scope-protection
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
511 access
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
512 type allslots))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
513 (fname (semantic-tag-file-name type))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
514 ;; EXTMETH are externally defined methods that are still
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
515 ;; a part of this class.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
516
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
517 ;; @TODO - is this line needed?? Try w/out for a while
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
518 ;; @note - I think C++ says no. elisp might, but methods
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
519 ;; look like defuns, so it makes no difference.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
520 (extmeth nil) ; (semantic-tag-external-member-children type t))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
521
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
522 ;; INHERITED are tags found in classes that our TYPE tag
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
523 ;; inherits from. Do not do this if it was not requested.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
524 (inherited (when (not noinherit)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
525 (semantic-analyze-scoped-inherited-tags type scope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
526 access)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
527 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
528 (when (not (semantic-tag-in-buffer-p type))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
529 (let ((copyslots nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
530 (dolist (TAG slots)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
531 ;;(semantic--tag-put-property TAG :filename fname)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
532 (if (semantic-tag-file-name TAG)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
533 ;; If it has a filename, just go with it...
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
534 (setq copyslots (cons TAG copyslots))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
535 ;; Otherwise, copy the tag w/ the guessed filename.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
536 (setq copyslots (cons (semantic-tag-copy TAG nil fname)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
537 copyslots)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
538 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
539 (setq slots (nreverse copyslots))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
540 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
541 ;; Flatten the database output.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
542 (append slots extmeth inherited)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
543 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
544
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
545 (defun semantic-analyze-scoped-inherited-tags (type scope access)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
546 "Return all tags that TYPE inherits from.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
547 Argument SCOPE specify additional tags that are in scope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
548 whose tags can be searched when needed, OR it may be a scope object.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
549 ACCESS is the level of access we filter on child supplied tags.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
550 For langauges with protection on specific methods or slots,
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
551 it should strip out those not accessable by methods of TYPE.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
552 An ACCESS of 'public means not in a method of a subclass of type.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
553 A value of 'private means we can access private parts of the originating
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
554 type."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
555 (let ((ret nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
556 (semantic-analyze-scoped-inherited-tag-map
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
557 type (lambda (p)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
558 (let* ((pname (semantic-tag-name p))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
559 (protection (semantic-tag-type-superclass-protection
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
560 type pname))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
561 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
562 (if (and (eq access 'public) (not (eq protection 'public)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
563 nil ;; Don't do it.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
564
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
565 ;; We can get some parts of this type.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
566 (setq ret (nconc ret
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
567 ;; Do not pull in inherited parts here. Those
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
568 ;; will come via the inherited-tag-map fcn
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
569 (semantic-analyze-scoped-type-parts
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
570 p scope t protection))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
571 ))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
572 scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
573 ret))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
574
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
575 (defun semantic-analyze-scoped-inherited-tag-map (type fcn scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
576 "Map all parents of TYPE to FCN. Return tags of all the types.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
577 Argument SCOPE specify additional tags that are in scope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
578 whose tags can be searched when needed, OR it may be a scope object."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
579 (let* (;; PARENTS specifies only the superclasses and not
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
580 ;; interfaces. Inheriting from an interfaces implies
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
581 ;; you have a copy of all methods locally. I think.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
582 (parents (semantic-tag-type-superclasses type))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
583 ps pt
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
584 (tmpscope scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
585 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
586 (save-excursion
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
587
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
588 ;; Create a SCOPE just for looking up the parent based on where
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
589 ;; the parent came from.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
590 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
591 ;; @TODO - Should we cache these mini-scopes around in Emacs
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
592 ;; for recycling later? Should this become a helpful
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
593 ;; extra routine?
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
594 (when (and parents (semantic-tag-with-position-p type))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
595 ;; If TYPE has a position, go there and get the scope.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
596 (semantic-go-to-tag type)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
597
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
598 ;; We need to make a mini scope, and only include the misc bits
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
599 ;; that will help in finding the parent. We don't really need
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
600 ;; to do any of the stuff related to variables and what-not.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
601 (setq tmpscope (semantic-scope-cache "mini"))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
602 (let* (;; Step 1:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
603 (scopetypes (semantic-analyze-scoped-types (point)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
604 (parents (semantic-analyze-scope-nested-tags (point) scopetypes))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
605 ;;(parentinherited (semantic-analyze-scope-lineage-tags parents scopetypes))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
606 (lscope nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
607 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
608 (oset tmpscope scopetypes scopetypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
609 (oset tmpscope parents parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
610 ;;(oset tmpscope parentinheritance parentinherited)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
611
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
612 (when (or scopetypes parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
613 (setq lscope (semantic-analyze-scoped-tags scopetypes tmpscope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
614 (oset tmpscope scope lscope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
615 (oset tmpscope fullscope (append scopetypes lscope parents))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
616 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
617 ;; END creating tmpscope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
618
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
619 ;; Look up each parent one at a time.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
620 (dolist (p parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
621 (setq ps (cond ((stringp p) p)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
622 ((and (semantic-tag-p p) (semantic-tag-prototype-p p))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
623 (semantic-tag-name p))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
624 ((and (listp p) (stringp (car p)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
625 p))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
626 pt (condition-case nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
627 (or (semantic-analyze-find-tag ps 'type tmpscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
628 ;; A backup hack.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
629 (semantic-analyze-find-tag ps 'type scope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
630 (error nil)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
631
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
632 (when pt
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
633 (funcall fcn pt)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
634 ;; Note that we pass the original SCOPE in while recursing.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
635 ;; so that the correct inheritance model is passed along.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
636 (semantic-analyze-scoped-inherited-tag-map pt fcn scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
637 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
638 nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
639
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
640 ;;; ANALYZER
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
641 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
642 ;; Create the scope structure for use in the Analyzer.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
643 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
644 (defun semantic-calculate-scope (&optional point)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
645 "Calculate the scope at POINT.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
646 If POINT is not provided, then use the current location of point.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
647 The class returned from the scope calculation is variable
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
648 `semantic-scope-cache'."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
649 (interactive)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
650 (if (not (and (featurep 'semanticdb) semanticdb-current-database))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
651 nil ;; Don't do anything...
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
652 (if (not point) (setq point (point)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
653 (when (interactive-p)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
654 (semantic-fetch-tags)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
655 (semantic-scope-reset-cache)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
656 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
657 (save-excursion
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
658 (goto-char point)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
659 (let* ((TAG (semantic-current-tag))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
660 (scopecache
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
661 (semanticdb-cache-get semanticdb-current-table
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
662 semantic-scope-cache))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
663 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
664 (when (not (semantic-equivalent-tag-p TAG (oref scopecache tag)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
665 (semantic-reset scopecache))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
666 (if (oref scopecache tag)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
667 ;; Even though we can recycle most of the scope, we
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
668 ;; need to redo the local variables since those change
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
669 ;; as you move about the tag.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
670 (condition-case nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
671 (oset scopecache localvar (semantic-get-all-local-variables))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
672 (error nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
673
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
674 (let* (;; Step 1:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
675 (scopetypes (semantic-analyze-scoped-types point))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
676 (parents (semantic-analyze-scope-nested-tags point scopetypes))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
677 (parentinherited (semantic-analyze-scope-lineage-tags
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
678 parents scopetypes))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
679 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
680 (oset scopecache tag TAG)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
681 (oset scopecache scopetypes scopetypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
682 (oset scopecache parents parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
683 (oset scopecache parentinheritance parentinherited)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
684
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
685 (let* (;; Step 2:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
686 (scope (when (or scopetypes parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
687 (semantic-analyze-scoped-tags scopetypes scopecache))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
688 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
689 ;; Step 3:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
690 (localargs (semantic-get-local-arguments))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
691 (localvar (condition-case nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
692 (semantic-get-all-local-variables)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
693 (error nil)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
694 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
695
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
696 ;; Try looking for parents again.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
697 (when (not parentinherited)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
698 (setq parentinherited (semantic-analyze-scope-lineage-tags
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
699 parents (append scopetypes scope)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
700 (when parentinherited
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
701 (oset scopecache parentinheritance parentinherited)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
702 ;; Try calculating the scope again with the new inherited parent list.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
703 (setq scope (when (or scopetypes parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
704 (semantic-analyze-scoped-tags scopetypes scopecache))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
705 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
706
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
707 ;; Fill out the scope.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
708 (oset scopecache scope scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
709 (oset scopecache fullscope (append scopetypes scope parents))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
710 (oset scopecache localargs localargs)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
711 (oset scopecache localvar localvar)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
712 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
713 ;; Make sure we become dependant on the typecache.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
714 (semanticdb-typecache-add-dependant scopecache)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
715 ;; Handy debug output.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
716 (when (interactive-p)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
717 (data-debug-show scopecache)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
718 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
719 ;; Return ourselves
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
720 scopecache))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
721
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
722 (defun semantic-scope-find (name &optional class scope-in)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
723 "Find the tag with NAME, and optinal CLASS in the current SCOPE-IN.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
724 Searches various elements of the scope for NAME. Return ALL the
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
725 hits in order, with the first tag being in the closest scope."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
726 (let ((scope (or scope-in (semantic-calculate-scope)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
727 (ans nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
728 ;; Is the passed in scope really a scope? if so, look through
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
729 ;; the options in that scope.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
730 (if (semantic-scope-cache-p scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
731 (let* ((la
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
732 ;; This should be first, but bugs in the
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
733 ;; C parser will turn function calls into
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
734 ;; assumed int return function prototypes. Yuck!
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
735 (semantic-find-tags-by-name name (oref scope localargs)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
736 (lv
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
737 (semantic-find-tags-by-name name (oref scope localvar)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
738 (fullscoperaw (oref scope fullscope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
739 (sc (semantic-find-tags-by-name name fullscoperaw))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
740 (typescoperaw (oref scope typescope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
741 (tsc (semantic-find-tags-by-name name typescoperaw))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
742 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
743 (setq ans
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
744 (if class
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
745 ;; Scan out things not of the right class.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
746 (semantic-find-tags-by-class class (append la lv sc tsc))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
747 (append la lv sc tsc))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
748 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
749
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
750 (when (and (not ans) (or typescoperaw fullscoperaw))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
751 (let ((namesplit (semantic-analyze-split-name name)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
752 (when (consp namesplit)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
753 ;; It may be we need to hack our way through type typescope.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
754 (while namesplit
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
755 (setq ans (append
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
756 (semantic-find-tags-by-name (car namesplit)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
757 typescoperaw)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
758 (semantic-find-tags-by-name (car namesplit)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
759 fullscoperaw)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
760 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
761 (if (not ans)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
762 (setq typescoperaw nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
763 (when (cdr namesplit)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
764 (setq typescoperaw (semantic-tag-type-members
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
765 (car ans)))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
766
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
767 (setq namesplit (cdr namesplit)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
768 ;; Once done, store the current typecache lookup
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
769 (oset scope typescope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
770 (append typescoperaw (oref scope typescope)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
771 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
772 ;; Return it.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
773 ans)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
774 ;; Not a real scope. Our scope calculation analyze parts of
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
775 ;; what it finds, and needs to pass lists through to do it's work.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
776 ;; Tread that list as a singly entry.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
777 (if class
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
778 (semantic-find-tags-by-class class scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
779 scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
780 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
781
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
782 ;;; DUMP
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
783 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
784 (defmethod semantic-analyze-show ((context semantic-scope-cache))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
785 "Insert CONTEXT into the current buffer in a nice way."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
786 (semantic-analyze-princ-sequence (oref context scopetypes) "-> ScopeTypes: " )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
787 (semantic-analyze-princ-sequence (oref context parents) "-> Parents: " )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
788 (semantic-analyze-princ-sequence (oref context scope) "-> Scope: " )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
789 ;;(semantic-analyze-princ-sequence (oref context fullscope) "Fullscope: " )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
790 (semantic-analyze-princ-sequence (oref context localargs) "-> Local Args: " )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
791 (semantic-analyze-princ-sequence (oref context localvar) "-> Local Vars: " )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
792 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
793
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
794 (provide 'semantic/scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
795
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
796 ;;; semantic/scope.el ends here