annotate lisp/cedet/semantic/scope.el @ 106095:32eb9a991725

(Fbyteorder, init_font, Ffont_get_system_font): Declare.
author Andreas Schwab <schwab@linux-m68k.org>
date Tue, 17 Nov 2009 19:11:53 +0000
parents 83dde921cc1b
children 019d906c8f48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; semantic/scope.el --- Analyzer Scope Calculations
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
3 ;; Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; the Free Software Foundation, either version 3 of the License, or
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; (at your option) any later version.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; GNU General Public License for more details.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;;; Commentary:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;; Calculate information about the current scope.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; Manages the current scope as a structure that can be cached on a
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
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 anything labled by a `using' statement.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
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)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 (setq stack (cdr stack)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 pparent (car (cdr stack))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 ;; Step 1:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 ;; 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
247 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 ;; 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
250 ;; 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
251 (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
252 (semantic-go-to-tag pparent)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 (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
254 ;; 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
255 (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
256 (tc nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 ;; @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
259 ;; 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
260 (while (and stacknames
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 (setq tc (semanticdb-typecache-find
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 (reverse stacknames))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 (setq returnlist (cons tc returnlist)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 stacknames (cdr stacknames)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 (when (not returnlist)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 ;; 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
267 ;; use what's right here.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 (setq stack (reverse stack))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 ;; 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
270 (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
271 ;; 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
272 (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
273 (setq stack (cdr stack)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 (setq returnlist (nreverse returnlist))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 ;; 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
280 (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
281 ;; Step 2:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 ;; 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
283 ;; 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
284 ;; up now.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 (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
287 (when p
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 ;; 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
289 (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
290 ((semantic-tag-p p)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 (semantic-tag-name p))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 ((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
293 (car p))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 (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
295 (snlist (if (consp searchname)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 searchname
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 (list searchname)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 (fullsearchname nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 (miniscope (semantic-scope-cache "mini"))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 ptag)
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 ;; 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
304 ;; 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
305 ;; returnlist is empty.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 (while snlist
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 (setq fullsearchname
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 (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
309 (list (car snlist)))) ;; Next one
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 (setq ptag
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 (semanticdb-typecache-find fullsearchname))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 (when (or (not ptag)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 (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
315 (let ((rawscope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 (apply 'append
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 (mapcar 'semantic-tag-type-members
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 (cons (car returnlist) scopetypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 (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
322 (oset miniscope scope rawscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 (oset miniscope fullscope rawscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 (setq ptag
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 (semantic-analyze-find-tag searchnameraw
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 'type
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 miniscope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 (when ptag
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 (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
333 (semantic-tag-p (car ptag)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 (setq ptag (car ptag)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 (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
336 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 (setq snlist (cdr snlist)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339 (setq returnlist returnlist)
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 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 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 (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
346 "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
347 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
348 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
349 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
350 be found.")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 (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
353 "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
354 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
355 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
356 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
357 be found."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 (let ((lineage nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 (miniscope (semantic-scope-cache "mini"))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 (oset miniscope parents parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 (oset miniscope scope scopetypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 (oset miniscope fullscope scopetypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 (dolist (slp parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 (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
367 slp (lambda (newparent)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368 (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
369 (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
370 (effectiveprot (cond ((eq prot 'public)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 ;; 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
372 'protected)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 (t prot))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 (push (cons newparent effectiveprot) lineage)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 miniscope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 lineage))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379
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 ;;------------------------------------------------------------
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 (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
384 "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
385 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
386 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
387 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
388 implicit \"object\".")
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 (defun semantic-analyze-scoped-tags-default (typelist halfscope)
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 104488
diff changeset
391 "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
392 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
393 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
394 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
395 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
396 implicit \"object\"."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 (let ((typelist2 nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 (currentscope nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 (parentlist (oref halfscope parents))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 (miniscope halfscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 ;; 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
403 ;; the names in typelist.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 (while typelist
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 (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
406 (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
407 ;; 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
408 (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
409 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 (setq typelist (cdr typelist)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 ;; 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
413 ;; 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
414 ;; for additional searching!
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 (while typelist2
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 (oset miniscope scope currentscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 (oset miniscope fullscope currentscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 (setq currentscope (append
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 (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
420 miniscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 currentscope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 (setq typelist2 (cdr typelist2)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 ;; 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
425 ;; 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
426 ;; 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
427 ;; 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
428 (while parentlist
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 (oset miniscope scope currentscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 (oset miniscope fullscope currentscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431 (setq currentscope (append
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 (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
433 miniscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434 currentscope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 (setq parentlist (cdr parentlist)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 ;; 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
438 (let ((constants nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 (dolist (T currentscope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 (setq constants (append constants
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441 (semantic-analyze-type-constants T)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 (setq currentscope (append currentscope constants)))
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 currentscope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447
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 (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
450 "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
451 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
452 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
453 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
454
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
455 (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
456 "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
457 (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
458 (let ((parents (oref scope parents))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 (parentsi (oref scope parentinheritance))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
460 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461 (catch 'moose
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462 ;; 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
463 ;; 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
464 (dolist (p parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 (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
466 (throw 'moose 'private))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
467 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468 ;; 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
469 (dolist (pi parentsi)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 ;; 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
471 (let ((pip (car pi))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
472 (piprot (cdr pi)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473 (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
474 (throw 'moose
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
475 ;; 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
476 ;; 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
477 (cdr (assoc piprot
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478 '((public . private)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
479 (protected . protected)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
480 (private . public))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
481 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483 ;; 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
484 (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
485 (dolist (F friends)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
486 (dolist (pi parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
487 (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
488 (throw 'moose 'private))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
489 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
490 ;; Found nothing, return public
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
491 'public)
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 (t 'public)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
494
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
495 (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
496 "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
497 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
498 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
499 (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
500 (leftover nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
501 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
502 (dolist (S allslots)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
503 (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
504 (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
505 (setq leftover (cons S leftover)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
506 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
507 (nreverse leftover)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
508
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
509 (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
510 "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
511 SCOPE is the scope object.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
512 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
513 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
514 (if (not type)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
515 nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
516 (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
517 ;; 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
518 (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
519 (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
520 access
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
521 type allslots))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
522 (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
523 ;; 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
524 ;; a part of this class.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
525
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
526 ;; @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
527 ;; @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
528 ;; 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
529 (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
530
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
531 ;; 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
532 ;; 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
533 (inherited (when (not noinherit)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
534 (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
535 access)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
536 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
537 (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
538 (let ((copyslots nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
539 (dolist (TAG slots)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
540 ;;(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
541 (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
542 ;; 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
543 (setq copyslots (cons TAG copyslots))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
544 ;; 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
545 (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
546 copyslots)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
547 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
548 (setq slots (nreverse copyslots))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
549 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
550 ;; Flatten the database output.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
551 (append slots extmeth inherited)
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
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
554 (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
555 "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
556 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
557 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
558 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
559 For languages with protection on specific methods or slots,
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 104488
diff changeset
560 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
561 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
562 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
563 type."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
564 (let ((ret nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
565 (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
566 type (lambda (p)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
567 (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
568 (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
569 type pname))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
570 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
571 (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
572 nil ;; Don't do it.
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 ;; 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
575 (setq ret (nconc ret
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
576 ;; 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
577 ;; 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
578 (semantic-analyze-scoped-type-parts
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
579 p scope t protection))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
580 ))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
581 scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
582 ret))
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 (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
585 "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
586 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
587 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
588 (require 'semantic/analyze)
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
589 (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
590 ;; 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
591 ;; 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
592 (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
593 ps pt
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
594 (tmpscope scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
595 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
596 (save-excursion
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
597
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
598 ;; 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
599 ;; the parent came from.
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 ;; @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
602 ;; 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
603 ;; extra routine?
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
604 (when (and parents (semantic-tag-with-position-p type))
105652
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
605 (save-excursion
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
606 ;; 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
607 (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
608
105652
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
609 ;; 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
610 ;; 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
611 ;; 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
612 (setq tmpscope (semantic-scope-cache "mini"))
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
613 (let* ( ;; Step 1:
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
614 (scopetypes (semantic-analyze-scoped-types (point)))
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
615 (parents (semantic-analyze-scope-nested-tags (point) scopetypes))
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
616 ;;(parentinherited (semantic-analyze-scope-lineage-tags parents scopetypes))
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
617 (lscope nil)
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
618 )
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
619 (oset tmpscope scopetypes scopetypes)
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
620 (oset tmpscope parents parents)
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
621 ;;(oset tmpscope parentinheritance parentinherited)
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
622
105652
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
623 (when (or scopetypes parents)
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
624 (setq lscope (semantic-analyze-scoped-tags scopetypes tmpscope))
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
625 (oset tmpscope scope lscope))
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
626 (oset tmpscope fullscope (append scopetypes lscope parents))
51bc239bdc37 * cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents: 105377
diff changeset
627 )))
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
628 ;; END creating tmpscope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
629
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
630 ;; 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
631 (dolist (p parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
632 (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
633 ((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
634 (semantic-tag-name p))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
635 ((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
636 p))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
637 pt (condition-case nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
638 (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
639 ;; A backup hack.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
640 (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
641 (error nil)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
642
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
643 (when pt
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
644 (funcall fcn pt)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
645 ;; 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
646 ;; 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
647 (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
648 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
649 nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
650
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
651 ;;; ANALYZER
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
652 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
653 ;; 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
654 ;;
104464
ee7637f5d6de lisp/cedet/semantic/scope.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104446
diff changeset
655 ;;;###autoload
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
656 (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
657 "Calculate the scope at POINT.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
658 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
659 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
660 `semantic-scope-cache'."
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
661 (interactive)
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104435
diff changeset
662 (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
663 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
664 (require 'semantic/db-typecache)
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
665 (if (not point) (setq point (point)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
666 (when (interactive-p)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
667 (semantic-fetch-tags)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
668 (semantic-scope-reset-cache)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
669 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
670 (save-excursion
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
671 (goto-char point)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
672 (let* ((TAG (semantic-current-tag))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
673 (scopecache
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
674 (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
675 semantic-scope-cache))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
676 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
677 (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
678 (semantic-reset scopecache))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
679 (if (oref scopecache tag)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
680 ;; 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
681 ;; 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
682 ;; 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
683 (condition-case nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
684 (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
685 (error nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
686
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
687 (let* (;; Step 1:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
688 (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
689 (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
690 (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
691 parents scopetypes))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
692 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
693 (oset scopecache tag TAG)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
694 (oset scopecache scopetypes scopetypes)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
695 (oset scopecache parents parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
696 (oset scopecache parentinheritance parentinherited)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
697
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
698 (let* (;; Step 2:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
699 (scope (when (or scopetypes parents)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
700 (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
701 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
702 ;; Step 3:
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
703 (localargs (semantic-get-local-arguments))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
704 (localvar (condition-case nil
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
705 (semantic-get-all-local-variables)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
706 (error nil)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
707 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
708
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
709 ;; Try looking for parents again.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
710 (when (not parentinherited)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
711 (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
712 parents (append scopetypes scope)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
713 (when parentinherited
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
714 (oset scopecache parentinheritance parentinherited)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
715 ;; 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
716 (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
717 (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
718 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
719
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
720 ;; Fill out the scope.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
721 (oset scopecache scope scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
722 (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
723 (oset scopecache localargs localargs)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
724 (oset scopecache localvar localvar)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
725 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
726 ;; 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
727 (semanticdb-typecache-add-dependant scopecache)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
728 ;; Handy debug output.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
729 (when (interactive-p)
104446
df08b7ab0ba0 lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104435
diff changeset
730 (require 'eieio-datadebug)
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
731 (data-debug-show scopecache)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
732 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
733 ;; Return ourselves
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
734 scopecache))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
735
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
736 (defun semantic-scope-find (name &optional class scope-in)
105340
118ad0cdd9a8 Doc/message fixes.
Glenn Morris <rgm@gnu.org>
parents: 104488
diff changeset
737 "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
738 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
739 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
740 (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
741 (ans nil))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
742 ;; 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
743 ;; the options in that scope.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
744 (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
745 (let* ((la
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
746 ;; 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
747 ;; 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
748 ;; 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
749 (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
750 (lv
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
751 (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
752 (fullscoperaw (oref scope fullscope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
753 (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
754 (typescoperaw (oref scope typescope))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
755 (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
756 )
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
757 (setq ans
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
758 (if class
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
759 ;; 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
760 (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
761 (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 )
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 (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
765 (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
766 (when (consp namesplit)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
767 ;; 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
768 (while namesplit
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
769 (setq ans (append
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
770 (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
771 typescoperaw)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
772 (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
773 fullscoperaw)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
774 ))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
775 (if (not ans)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
776 (setq typescoperaw nil)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
777 (when (cdr namesplit)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
778 (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
779 (car ans)))))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
780
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
781 (setq namesplit (cdr namesplit)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
782 ;; 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
783 (oset scope typescope
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
784 (append typescoperaw (oref scope typescope)))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
785 )))
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
786 ;; Return it.
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
787 ans)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
788 ;; 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
789 ;; 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
790 ;; 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
791 (if class
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
792 (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
793 scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
794 )))
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 ;;; DUMP
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
797 ;;
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
798 (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
799 "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
800 (require 'semantic/analyze)
104435
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
801 (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
802 (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
803 (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
804 ;;(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
805 (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
806 (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
807 )
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 (provide 'semantic/scope)
52067a6bf088 semantic/cedet/db-global.el, semantic/cedet/ia-sb.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
810
104464
ee7637f5d6de lisp/cedet/semantic/scope.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104446
diff changeset
811 ;; Local variables:
ee7637f5d6de lisp/cedet/semantic/scope.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104446
diff changeset
812 ;; 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
813 ;; 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
814 ;; End:
ee7637f5d6de lisp/cedet/semantic/scope.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104446
diff changeset
815
105377
7f4c7f5c0eba Add arch tagline
Miles Bader <miles@gnu.org>
parents: 105340
diff changeset
816 ;; arch-tag: 056ab514-3e28-4d6e-84ed-9283dce5a01e
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