annotate lisp/cedet/semantic/scope.el @ 112441:2097405cdc11

Merge: Check return values of some library calls.
author Paul Eggert <eggert@cs.ucla.edu>
date Sat, 22 Jan 2011 23:32:08 -0800
parents ef719132ddfa
children
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
112218
376148b31b5e Add 2011 to FSF/AIST copyright years.
Glenn Morris <rgm@gnu.org>
parents: 110523
diff changeset
3 ;; Copyright (C) 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
104435
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
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 104488
diff changeset
27 ;; per-file basis and recycled between different occurrences of
104435
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
104470
6ccad1511df1 Minor whitespace changes and `require' fixes.
Chong Yidong <cyd@stupidchicken.com>
parents: 104464
diff changeset
52 (eval-when-compile (require 'semantic/find))
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104435
diff changeset
53
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104435
diff changeset
54 (declare-function data-debug-show "eieio-datadebug")
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104435
diff changeset
55 (declare-function semantic-analyze-find-tag "semantic/analyze")
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104435
diff changeset
56 (declare-function semantic-analyze-princ-sequence "semantic/analyze")
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104435
diff changeset
57 (declare-function semanticdb-typecache-merge-streams "semantic/db-typecache")
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104435
diff changeset
58 (declare-function semanticdb-typecache-add-dependant "semantic/db-typecache")
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 ;;; Code:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 (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
63 ((tag :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 "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
66 (scopetypes :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 "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
69 For C++, this would contain anonymous namespaces known, and
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
70 anything labeled by a `using' statement.")
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 (parents :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 "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
74 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
75 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
76 (parentinheritance :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 :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
78 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
79 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
80 (scope :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 "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
83 (fullscope :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 "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
86 (localargs :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 "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
89 (localvar :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 "The local variables.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 (typescope :initform nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 :documentation
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 "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
95 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 "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
97 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
98
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 ;;; METHODS
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 ;; 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
102 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 (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
104 "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
105 (oset obj tag nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 (oset obj scopetypes nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 (oset obj parents nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 (oset obj parentinheritance nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 (oset obj scope nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 (oset obj fullscope nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 (oset obj localargs nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 (oset obj localvar nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 (oset obj typescope nil)
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
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 (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
117 new-tags)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 "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
119 (semantic-reset cache))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 (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
123 new-tags)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 "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
125 ;; 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
126 (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
127 (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
128 (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
129 (semantic-reset cache))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 )
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 (defun semantic-scope-reset-cache ()
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 "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
134 (when semanticdb-current-table
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 (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
136 semantic-scope-cache)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 (semantic-reset co))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 (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
140 types-in-scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 "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
142 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
143 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
144 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
145 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
146 (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
147 (dolist (onetype types-in-scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 (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
149 newts))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 (oset cache typescope newts)))
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 ;;; TAG SCOPES
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 ;; 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
156 ;; 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
157 ;; 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
158 ;; 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
159
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 (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
161 "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
162 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
163 (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
164 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 (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
166 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 (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
169 "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
170 (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
171
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 ;;; SCOPE UTILITIES
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 ;; 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
175
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 (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
178 "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
179 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
180 types available.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 (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
183 "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
184 Use `semantic-ctxt-scoped-types' to find types."
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104435
diff changeset
185 (require 'semantic/db-typecache)
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 (save-excursion
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 (goto-char position)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 (let ((code-scoped-types nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 ;; 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
190 ;; 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
191 ;; 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
192 (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
193 (while sp
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 ;; 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
195 (let ((tmp (cond
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 ((stringp (car sp))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 (semanticdb-typecache-find (car sp)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 ;(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
199 ((semantic-tag-p (car sp))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 (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
201 (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
202 ;;(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
203 (car sp)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 (t nil))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 (when tmp
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 (setq code-scoped-types
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 (cons tmp code-scoped-types))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 (setq sp (cdr sp))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 (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
210
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 (when code-scoped-types
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 (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
213
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 )))
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 ;;------------------------------------------------------------
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 (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
218 "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
219 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
220 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
221 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
222 be found.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 (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
225 "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
226 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
227 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
228 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
229 be found.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 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
231 are from nesting data types."
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104435
diff changeset
232 (require 'semantic/analyze)
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 (save-excursion
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 (if position (goto-char position))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235 (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
236 (tag (car stack))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 (pparent (car (cdr stack)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 (returnlist nil)
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 ;; 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
241 (while (and stack (not (semantic-tag-of-class-p pparent 'type)))
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
242 (setq stack (cdr stack) pparent (car (cdr stack))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
243
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
244 ;; Remove duplicates
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
245 (while (member pparent scopetypes)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
246 (setq stack (cdr stack) pparent (car (cdr stack))))
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 ;; Step 1:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 ;; 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
250 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 ;; 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
253 ;; 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
254 (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
255 (semantic-go-to-tag pparent)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 (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
257 ;; 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
258 (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
259 (tc nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 ;; @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
262 ;; 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
263 (while (and stacknames
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 (setq tc (semanticdb-typecache-find
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 (reverse stacknames))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 (setq returnlist (cons tc returnlist)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 stacknames (cdr stacknames)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 (when (not returnlist)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 ;; 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
270 ;; use what's right here.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 (setq stack (reverse stack))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 ;; 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
273 (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
274 ;; 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
275 (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
276 (setq stack (cdr stack)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 (setq returnlist (nreverse returnlist))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 ;; 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
283 (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
284 ;; Step 2:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 ;; 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
286 ;; 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
287 ;; up now.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 (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
290 (when p
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 ;; 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
292 (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
293 ((semantic-tag-p p)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 (semantic-tag-name p))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 ((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
296 (car p))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 (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
298 (snlist (if (consp searchname)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 searchname
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 (list searchname)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 (fullsearchname nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 (miniscope (semantic-scope-cache "mini"))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 ptag)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 ;; 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
307 ;; 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
308 ;; returnlist is empty.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 (while snlist
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 (setq fullsearchname
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 (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
312 (list (car snlist)))) ;; Next one
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 (setq ptag
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 (semanticdb-typecache-find fullsearchname))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 (when (or (not ptag)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 (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
318 (let ((rawscope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 (apply 'append
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 (mapcar 'semantic-tag-type-members
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 (cons (car returnlist) scopetypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 (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
325 (oset miniscope scope rawscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 (oset miniscope fullscope rawscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 (setq ptag
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 (semantic-analyze-find-tag searchnameraw
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 'type
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 miniscope
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
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 (when ptag
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 (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
336 (semantic-tag-p (car ptag)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 (setq ptag (car ptag)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 (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
339 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341 (setq snlist (cdr snlist)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 (setq returnlist returnlist)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 returnlist
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 (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
349 "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
350 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
351 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
352 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
353 be found.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355 (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
356 "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
357 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
358 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
359 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
360 be found."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 (let ((lineage nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 (miniscope (semantic-scope-cache "mini"))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 (oset miniscope parents parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 (oset miniscope scope scopetypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 (oset miniscope fullscope scopetypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368 (dolist (slp parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 (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
370 slp (lambda (newparent)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 (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
372 (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
373 (effectiveprot (cond ((eq prot 'public)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 ;; 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
375 'protected)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 (t prot))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 (push (cons newparent effectiveprot) lineage)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 miniscope))
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 lineage))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 ;;------------------------------------------------------------
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 (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
387 "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
388 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
389 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
390 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
391 implicit \"object\".")
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 (defun semantic-analyze-scoped-tags-default (typelist halfscope)
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 104488
diff changeset
394 "Return accessible tags when TYPELIST and HALFSCOPE is in scope.
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 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
396 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
397 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
398 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
399 implicit \"object\"."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 (let ((typelist2 nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 (currentscope nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 (parentlist (oref halfscope parents))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 (miniscope halfscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 ;; 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
406 ;; the names in typelist.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407 (while typelist
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 (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
409 (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
410 ;; 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
411 (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
412 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413 (setq typelist (cdr typelist)))
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 ;; 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
416 ;; 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
417 ;; for additional searching!
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 (while typelist2
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 (oset miniscope scope currentscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 (oset miniscope fullscope currentscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 (setq currentscope (append
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 (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
423 miniscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 currentscope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
425 (setq typelist2 (cdr typelist2)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 ;; 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
428 ;; 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
429 ;; 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
430 ;; 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
431 (while parentlist
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 (oset miniscope scope currentscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 (oset miniscope fullscope currentscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434 (setq currentscope (append
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 (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
436 miniscope)
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 (setq parentlist (cdr parentlist)))
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 ;; 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
441 (let ((constants nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 (dolist (T currentscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 (setq constants (append constants
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 (semantic-analyze-type-constants T)))
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
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 (setq currentscope (append currentscope constants)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449 currentscope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450
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 (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
453 "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
454 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
455 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
456 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
457
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 (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
459 "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
460 (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
461 (let ((parents (oref scope parents))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462 (parentsi (oref scope parentinheritance))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464 (catch 'moose
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 ;; 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
466 ;; 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
467 (dolist (p parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468 (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
469 (throw 'moose 'private))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
471 ;; 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
472 (dolist (pi parentsi)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473 ;; 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
474 (let ((pip (car pi))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
475 (piprot (cdr pi)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
476 (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
477 (throw 'moose
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478 ;; 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
479 ;; 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
480 (cdr (assoc piprot
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
481 '((public . private)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482 (protected . protected)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483 (private . public))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
484 )))
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 ;; 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
487 (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
488 (dolist (F friends)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
489 (dolist (pi parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
490 (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
491 (throw 'moose 'private))
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 ;; Found nothing, return public
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
494 'public)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
495 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
496 (t 'public)))
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 (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
499 "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
500 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
501 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
502 (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
503 (leftover nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
504 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
505 (dolist (S allslots)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
506 (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
507 (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
508 (setq leftover (cons S leftover)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
509 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
510 (nreverse leftover)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
511
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
512 (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
513 "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
514 SCOPE is the scope object.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
515 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
516 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
517 (if (not type)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
518 nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
519 (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
520 ;; 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
521 (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
522 (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
523 access
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
524 type allslots))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
525 (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
526 ;; 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
527 ;; a part of this class.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
528
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
529 ;; @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
530 ;; @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
531 ;; 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
532 (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
533
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
534 ;; 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
535 ;; 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
536 (inherited (when (not noinherit)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
537 (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
538 access)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
539 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
540 (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
541 (let ((copyslots nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
542 (dolist (TAG slots)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
543 ;;(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
544 (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
545 ;; 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
546 (setq copyslots (cons TAG copyslots))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
547 ;; 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
548 (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
549 copyslots)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
550 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
551 (setq slots (nreverse copyslots))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
552 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
553 ;; Flatten the database output.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
554 (append slots extmeth inherited)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
555 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
556
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
557 (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
558 "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
559 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
560 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
561 ACCESS is the level of access we filter on child supplied tags.
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 104488
diff changeset
562 For languages with protection on specific methods or slots,
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 104488
diff changeset
563 it should strip out those not accessible by methods of TYPE.
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
564 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
565 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
566 type."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
567 (let ((ret nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
568 (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
569 type (lambda (p)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
570 (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
571 (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
572 type pname))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
573 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
574 (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
575 nil ;; Don't do it.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
576
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
577 ;; 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
578 (setq ret (nconc ret
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
579 ;; 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
580 ;; 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
581 (semantic-analyze-scoped-type-parts
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
582 p scope t protection))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
583 ))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
584 scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
585 ret))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
586
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
587 (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
588 "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
589 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
590 whose tags can be searched when needed, OR it may be a scope object."
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104435
diff changeset
591 (require 'semantic/analyze)
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
592 (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
593 ;; 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
594 ;; 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
595 (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
596 ps pt
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
597 (tmpscope scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
598 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
599 (save-excursion
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
600
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
601 ;; 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
602 ;; the parent came from.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
603 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
604 ;; @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
605 ;; 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
606 ;; extra routine?
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
607 (when (and parents (semantic-tag-with-position-p type))
105652
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
608 (save-excursion
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
609 ;; If TYPE has a position, go there and get the scope.
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
610 (semantic-go-to-tag type)
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
611
105652
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
612 ;; We need to make a mini scope, and only include the misc bits
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
613 ;; that will help in finding the parent. We don't really need
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
614 ;; to do any of the stuff related to variables and what-not.
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
615 (setq tmpscope (semantic-scope-cache "mini"))
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
616 (let* ( ;; Step 1:
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
617 (scopetypes (cons type (semantic-analyze-scoped-types (point))))
105652
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
618 (parents (semantic-analyze-scope-nested-tags (point) scopetypes))
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
619 ;;(parentinherited (semantic-analyze-scope-lineage-tags parents scopetypes))
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
620 (lscope nil)
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
621 )
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
622 (oset tmpscope scopetypes scopetypes)
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
623 (oset tmpscope parents parents)
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
624 ;;(oset tmpscope parentinheritance parentinherited)
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
625
105652
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
626 (when (or scopetypes parents)
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
627 (setq lscope (semantic-analyze-scoped-tags scopetypes tmpscope))
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
628 (oset tmpscope scope lscope))
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
629 (oset tmpscope fullscope (append scopetypes lscope parents))
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
630 )))
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
631 ;; END creating tmpscope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
632
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
633 ;; 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
634 (dolist (p parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
635 (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
636 ((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
637 (semantic-tag-name p))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
638 ((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
639 p))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
640 pt (condition-case nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
641 (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
642 ;; A backup hack.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
643 (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
644 (error nil)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
645
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
646 (when pt
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
647 (funcall fcn pt)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
648 ;; 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
649 ;; 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
650 (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
651 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
652 nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
653
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
654 ;;; ANALYZER
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
655 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
656 ;; 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
657 ;;
104464
ee7637f5d6de lisp/cedet/semantic/scope.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104446
diff changeset
658 ;;;###autoload
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
659 (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
660 "Calculate the scope at POINT.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
661 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
662 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
663 `semantic-scope-cache'."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
664 (interactive)
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104435
diff changeset
665 (if (not (and (featurep 'semantic/db) semanticdb-current-database))
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
666 nil ;; Don't do anything...
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104435
diff changeset
667 (require 'semantic/db-typecache)
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
668 (if (not point) (setq point (point)))
106197
019d906c8f48 * cedet/srecode/map.el (srecode-get-maps):
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
669 (when (called-interactively-p 'any)
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
670 (semantic-fetch-tags)
106197
019d906c8f48 * cedet/srecode/map.el (srecode-get-maps):
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
671 (semantic-scope-reset-cache))
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
672 (save-excursion
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
673 (goto-char point)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
674 (let* ((TAG (semantic-current-tag))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
675 (scopecache
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
676 (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
677 semantic-scope-cache))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
678 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
679 (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
680 (semantic-reset scopecache))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
681 (if (oref scopecache tag)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
682 ;; 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
683 ;; 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
684 ;; 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
685 (condition-case nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
686 (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
687 (error nil))
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 (let* (;; Step 1:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
690 (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
691 (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
692 (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
693 parents scopetypes))
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 (oset scopecache tag TAG)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
696 (oset scopecache scopetypes scopetypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
697 (oset scopecache parents parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
698 (oset scopecache parentinheritance parentinherited)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
699
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
700 (let* (;; Step 2:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
701 (scope (when (or scopetypes parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
702 (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
703 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
704 ;; Step 3:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
705 (localargs (semantic-get-local-arguments))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
706 (localvar (condition-case nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
707 (semantic-get-all-local-variables)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
708 (error nil)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
709 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
710
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
711 ;; Try looking for parents again.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
712 (when (not parentinherited)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
713 (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
714 parents (append scopetypes scope)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
715 (when parentinherited
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
716 (oset scopecache parentinheritance parentinherited)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
717 ;; 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
718 (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
719 (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
720 )))
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 ;; Fill out the scope.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
723 (oset scopecache scope scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
724 (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
725 (oset scopecache localargs localargs)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
726 (oset scopecache localvar localvar)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
727 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
728 ;; 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
729 (semanticdb-typecache-add-dependant scopecache)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
730 ;; Handy debug output.
106197
019d906c8f48 * cedet/srecode/map.el (srecode-get-maps):
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
731 (when (called-interactively-p 'any)
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104435
diff changeset
732 (require 'eieio-datadebug)
106197
019d906c8f48 * cedet/srecode/map.el (srecode-get-maps):
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
733 (data-debug-show scopecache))
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
734 ;; Return ourselves
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
735 scopecache))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
736
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
737 (defun semantic-scope-find (name &optional class scope-in)
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 104488
diff changeset
738 "Find the tag with NAME, and optional CLASS in the current SCOPE-IN.
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
739 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
740 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
741 (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
742 (ans nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
743 ;; 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
744 ;; the options in that scope.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
745 (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
746 (let* ((la
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
747 ;; 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
748 ;; 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
749 ;; 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
750 (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
751 (lv
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
752 (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
753 (fullscoperaw (oref scope fullscope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
754 (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
755 (typescoperaw (oref scope typescope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
756 (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
757 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
758 (setq ans
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
759 (if class
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
760 ;; 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
761 (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
762 (append la lv sc tsc))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
763 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
764
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
765 (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
766 (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
767 (when (consp namesplit)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
768 ;; 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
769 (while namesplit
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
770 (setq ans (append
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
771 (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
772 typescoperaw)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
773 (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
774 fullscoperaw)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
775 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
776 (if (not ans)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
777 (setq typescoperaw nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
778 (when (cdr namesplit)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
779 (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
780 (car ans)))))
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 (setq namesplit (cdr namesplit)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
783 ;; 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
784 (oset scope typescope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
785 (append typescoperaw (oref scope typescope)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
786 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
787 ;; Return it.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
788 ans)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
789 ;; 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
790 ;; 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
791 ;; 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
792 (if class
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
793 (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
794 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
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
797 ;;; DUMP
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
798 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
799 (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
800 "Insert CONTEXT into the current buffer in a nice way."
104488
7042156f9f43 lisp/cedet/semantic/scope.el (semantic-analyze-show): Fix require.
Chong Yidong <cyd@stupidchicken.com>
parents: 104470
diff changeset
801 (require 'semantic/analyze)
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
802 (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
803 (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
804 (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
805 ;;(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
806 (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
807 (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
808 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
809
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
810 (provide 'semantic/scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
811
104464
ee7637f5d6de lisp/cedet/semantic/scope.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104446
diff changeset
812 ;; Local variables:
ee7637f5d6de lisp/cedet/semantic/scope.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104446
diff changeset
813 ;; generated-autoload-file: "loaddefs.el"
ee7637f5d6de lisp/cedet/semantic/scope.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104446
diff changeset
814 ;; generated-autoload-load-name: "semantic/scope"
ee7637f5d6de lisp/cedet/semantic/scope.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104446
diff changeset
815 ;; End:
ee7637f5d6de lisp/cedet/semantic/scope.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104446
diff changeset
816
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
817 ;;; semantic/scope.el ends here