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

cedet/semantic/debug.el, cedet/semantic/doc.el, cedet/semantic/tag-write.el, cedet/semantic/analyze/complete.el, cedet/semantic/analyze/debug.el, cedet/semantic/analyze/fcn.el, cedet/semantic/analyze/refs.el: New files.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 29 Aug 2009 19:45:47 +0000
parents b1ac14799f78
children da5b2513c225
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104419
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; analyze.el --- Analyze semantic tags against local context
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
3 ;;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4 ;;; Free Software Foundation, Inc.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6 ;; Author: Eric M. Ludlam <zappo@gnu.org>
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 ;; GNU Emacs is free software: you can redistribute it and/or modify
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; the Free Software Foundation, either version 3 of the License, or
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13 ;; (at your option) any later version.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18 ;; GNU General Public License for more details.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;;; Commentary:
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;; Semantic, as a tool, provides a nice list of searchable tags.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; That information can provide some very accurate answers if the current
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;; context of a position is known.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;; Semantic-ctxt provides ways of analyzing, and manipulating the
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;; semantic context of a language in code.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 ;; This library provides routines for finding intelligent answers to
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;; tough problems, such as if an argument to a function has the correct
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;; return type, or all possible tags that fit in a given local context.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 ;;; Vocabulary:
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 ;; Here are some words used to describe different things in the analyzer:
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 ;; tag - A single entity
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 ;; prefix - The beginning of a symbol, usually used to look up something
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 ;; incomplete.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 ;; type - The name of a datatype in the langauge.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 ;; metatype - If a type is named in a declaration like:
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 ;; struct moose somevariable;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 ;; that name "moose" can be turned into a concrete type.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 ;; tag sequence - In C code, a list of dereferences, such as:
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 ;; this.that.theother();
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 ;; parent - For a datatype in an OO language, another datatype
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 ;; inherited from. This excludes interfaces.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 ;; scope - A list of tags that can be dereferenced that cannot
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 ;; be found from the global namespace.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 ;; scopetypes - A list of tags which are datatype that contain
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 ;; the scope. The scopetypes need to have the scope extracted
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 ;; in a way that honors the type of inheritance.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 ;; nest/nested - When one tag is contained entirely in another.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 ;; context - A semantic datatype representing a point in a buffer.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 ;; constriant - If a context specifies a specific datatype is needed,
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 ;; that is a constraint.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 ;; constants - Some datatypes define elements of themselves as a
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 ;; constant. These need to be returned as there would be no
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 ;; other possible completions.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 (require 'eieio)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68 ;; (require 'inversion)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 ;; (eval-and-compile
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 ;; (inversion-require 'eieio "1.0"))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71 (require 'semantic)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 (require 'semantic/format)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 (require 'semantic/ctxt)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 (require 'semantic/sort)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 (eval-when-compile (require 'semantic/db)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 (require 'semantic/db-find))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78 (require 'semantic/scope)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 (require 'semantic/analyze/fcn)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 ;;; Code:
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 (defvar semantic-analyze-error-stack nil
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 "Collection of any errors thrown during analysis.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 (defun semantic-analyze-push-error (err)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 "Push the error in ERR-DATA onto the error stack.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 Argument ERR"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 (push err semantic-analyze-error-stack))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 ;;; Analysis Classes
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 ;; These classes represent what a context is. Different types
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 ;; of contexts provide differing amounts of information to help
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 ;; provide completions.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 (defclass semantic-analyze-context ()
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 ((bounds :initarg :bounds
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 :type list
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 :documentation "The bounds of this context.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 Usually bound to the dimension of a single symbol or command.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 (prefix :initarg :prefix
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 :type list
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 :documentation "List of tags defining local text.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 This can be nil, or a list where the last element can be a string
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 representing text that may be incomplete. Preceeding elements
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 must be semantic tags representing variables or functions
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 called in a dereference sequence.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 (prefixclass :initarg :prefixclass
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 :type list
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 :documentation "Tag classes expected at this context.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 These are clases for tags, such as 'function, or 'variable.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 (prefixtypes :initarg :prefixtypes
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 :type list
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 :documentation "List of tags defining types for :prefix.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 This list is one shorter than :prefix. Each element is a semantic
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 tag representing a type matching the semantic tag in the same
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 position in PREFIX.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 (scope :initarg :scope
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 :type (or null semantic-scope-cache)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 :documentation "List of tags available in scopetype.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 See `semantic-analyze-scoped-tags' for details.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 (buffer :initarg :buffer
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 :type buffer
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 :documentation "The buffer this context is derived from.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 (errors :initarg :errors
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 :documentation "Any errors thrown an caught during analysis.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 "Base analysis data for a any context.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 (defclass semantic-analyze-context-assignment (semantic-analyze-context)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 ((assignee :initarg :assignee
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 :type list
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 :documentation "A sequence of tags for an assignee.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 This is a variable into which some value is being placed. The last
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 item in the list is the variable accepting the value. Earlier
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 tags represent the variables being derefernece to get to the
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 assignee."))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 "Analysis class for a value in an assignment.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 (defclass semantic-analyze-context-functionarg (semantic-analyze-context)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 ((function :initarg :function
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 :type list
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 :documentation "A sequence of tags for a function.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 This is a function being called. The cursor will be in the position
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 of an argument.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 The last tag in :function is the function being called. Earlier
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 tags represent the variables being dereferenced to get to the
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 function.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 (index :initarg :index
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 :type integer
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 :documentation "The index of the argument for this context.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 If a function takes 4 arguments, this value should be bound to
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 the values 1 through 4.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 (argument :initarg :argument
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 :type list
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 :documentation "A sequence of tags for the :index argument.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 The argument can accept a value of some type, and this contains the
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 tag for that definition. It should be a tag, but might
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 be just a string in some circumstances.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 "Analysis class for a value as a function argument.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 (defclass semantic-analyze-context-return (semantic-analyze-context)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 () ; No extra data.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 "Analysis class for return data.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 Return data methods identify the requred type by the return value
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 of the parent function.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 ;;; METHODS
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 ;; Simple methods against the context classes.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 (defmethod semantic-analyze-type-constraint
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 ((context semantic-analyze-context) &optional desired-type)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 "Return a type constraint for completing :prefix in CONTEXT.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 Optional argument DESIRED-TYPE may be a non-type tag to analyze."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 (when (semantic-tag-p desired-type)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 ;; Convert the desired type if needed.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 (if (not (eq (semantic-tag-class desired-type) 'type))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 (setq desired-type (semantic-tag-type desired-type)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 ;; Protect against plain strings
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 (cond ((stringp desired-type)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 (setq desired-type (list desired-type 'type)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 ((and (stringp (car desired-type))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 (not (semantic-tag-p desired-type)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 (setq desired-type (list (car desired-type) 'type)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 ((semantic-tag-p desired-type)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 ;; We have a tag of some sort. Yay!
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 (t (setq desired-type nil))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 desired-type))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 (defmethod semantic-analyze-type-constraint
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 ((context semantic-analyze-context-functionarg))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 "Return a type constraint for completing :prefix in CONTEXT."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 (call-next-method context (car (oref context argument))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 (defmethod semantic-analyze-type-constraint
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 ((context semantic-analyze-context-assignment))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 "Return a type constraint for completing :prefix in CONTEXT."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 (call-next-method context (car (reverse (oref context assignee)))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 (defmethod semantic-analyze-interesting-tag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 ((context semantic-analyze-context))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206 "Return a tag from CONTEXT that would be most interesting to a user."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 (let ((prefix (reverse (oref context :prefix))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 ;; Go back through the prefix until we find a tag we can return.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 (while (and prefix (not (semantic-tag-p (car prefix))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 (setq prefix (cdr prefix)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 ;; Return the found tag, or nil.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 (car prefix)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 (defmethod semantic-analyze-interesting-tag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215 ((context semantic-analyze-context-functionarg))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 "Try the base, and if that fails, return what we are assigning into."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 (or (call-next-method) (car-safe (oref context :function))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 (defmethod semantic-analyze-interesting-tag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 ((context semantic-analyze-context-assignment))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 "Try the base, and if that fails, return what we are assigning into."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 (or (call-next-method) (car-safe (oref context :assignee))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 ;;; ANALYSIS
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 ;; Start out with routines that will calculate useful parts of
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 ;; the general analyzer function. These could be used directly
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 ;; by an application that doesn't need to calculate the full
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229 ;; context.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 (define-overloadable-function semantic-analyze-find-tag-sequence (sequence &optional
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 scope typereturn throwsym)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 "Attempt to find all tags in SEQUENCE.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 Optional argument LOCALVAR is the list of local variables to use when
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235 finding the details on the first element of SEQUENCE in case
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 it is not found in the global set of tables.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 Optional argument SCOPE are additional terminals to search which are currently
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 scoped. These are not local variables, but symbols available in a structure
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 which doesn't need to be dereferneced.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 Optional argument TYPERETURN is a symbol in which the types of all found
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 will be stored. If nil, that data is thrown away.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 Optional argument THROWSYM specifies a symbol the throw on non-recoverable error.")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 (defun semantic-analyze-find-tag-sequence-default (sequence &optional
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 scope typereturn
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 throwsym)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 "Attempt to find all tags in SEQUENCE.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 SCOPE are extra tags which are in scope.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 TYPERETURN is a symbol in which to place a list of tag classes that
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 are found in SEQUENCE.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 Optional argument THROWSYM specifies a symbol the throw on non-recoverable error."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 (let ((s sequence) ; copy of the sequence
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 (tmp nil) ; tmp find variable
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 (tag nil) ; tag return list
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 (tagtype nil) ; tag types return list
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 (fname nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 (miniscope (clone scope))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 ;; First order check. Is this wholely contained in the typecache?
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 (setq tmp (semanticdb-typecache-find sequence))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 (if tmp
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 (progn
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 ;; We are effectively done...
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 (setq s nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 (setq tag (list tmp)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 ;; For the first entry, it better be a variable, but it might
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 ;; be in the local context too.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 ;; NOTE: Don't forget c++ namespace foo::bar.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 (setq tmp (or
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 ;; Is this tag within our scope. Scopes can sometimes
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 ;; shadow other things, so it goes first.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 (and scope (semantic-scope-find (car s) nil scope))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 ;; Find the tag out there... somewhere, but not in scope
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 (semantic-analyze-find-tag (car s))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 ))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 (if (and (listp tmp) (semantic-tag-p (car tmp)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 (setq tmp (semantic-analyze-select-best-tag tmp)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 (if (not (semantic-tag-p tmp))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 (if throwsym
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 (throw throwsym "Cannot find definition")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284 (error "Cannot find definition for \"%s\"" (car s))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 (setq s (cdr s))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 (setq tag (cons tmp tag)) ; tag is nil here...
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 (setq fname (semantic-tag-file-name tmp))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 ;; For the middle entries
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 (while s
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 ;; Using the tag found in TMP, lets find the tag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 ;; representing the full typeographic information of its
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 ;; type, and use that to determine the search context for
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 ;; (car s)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 (let* ((tmptype
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 ;; In some cases the found TMP is a type,
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 ;; and we can use it directly.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 (cond ((semantic-tag-of-class-p tmp 'type)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 ;; update the miniscope when we need to analyze types directly.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 (let ((rawscope
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 (apply 'append
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 (mapcar 'semantic-tag-type-members
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 tagtype))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 (oset miniscope fullscope rawscope))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 ;; Now analayze the type to remove metatypes.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 (or (semantic-analyze-type tmp miniscope)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 tmp))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 (t
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 (semantic-analyze-tag-type tmp scope))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 (typefile
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 (when tmptype
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 (semantic-tag-file-name tmptype)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 (slots nil))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 ;; Get the children
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 (setq slots (semantic-analyze-scoped-type-parts tmptype scope))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 ;; find (car s) in the list o slots
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 (setq tmp (semantic-find-tags-by-name (car s) slots))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322 ;; If we have lots
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 (if (and (listp tmp) (semantic-tag-p (car tmp)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 (setq tmp (semantic-analyze-select-best-tag tmp)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 ;; Make sure we have a tag.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 (if (not (semantic-tag-p tmp))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 (if (cdr s)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 ;; In the middle, we need to keep seeking our types out.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 (error "Cannot find definition for \"%s\"" (car s))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 ;; Else, it's ok to end with a non-tag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 (setq tmp (car s))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 (setq fname (or typefile fname))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 (when (and fname (semantic-tag-p tmp)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 (not (semantic-tag-in-buffer-p tmp)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 (semantic--tag-put-property tmp :filename fname))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 (setq tag (cons tmp tag))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339 (setq tagtype (cons tmptype tagtype))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341 (setq s (cdr s)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 (if typereturn (set typereturn (nreverse tagtype)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 ;; Return the mess
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 (nreverse tag)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347 (defun semantic-analyze-find-tag (name &optional tagclass scope)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 "Return the first tag found with NAME or nil if not found.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349 Optional argument TAGCLASS specifies the class of tag to return, such
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 as 'function or 'variable.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 Optional argument SCOPE specifies a scope object which has
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 additional tags which are in SCOPE and do not need prefixing to
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 find.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355 This is a wrapper on top of semanticdb, semanticdb-typecache,
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
356 semantic-scope, and semantic search functions. Almost all
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
357 searches use the same arguments."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 (let ((namelst (if (consp name) name ;; test if pre-split.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 (semantic-analyze-split-name name))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 (cond
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 ;; If the splitter gives us a list, use the sequence finder
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 ;; to get the list. Since this routine is expected to return
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 ;; only one tag, return the LAST tag found from the sequence
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 ;; which is supposedly the nested reference.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 ;; Of note, the SEQUENCE function below calls this function
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 ;; (recursively now) so the names that we get from the above
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368 ;; fcn better not, in turn, be splittable.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 ((listp namelst)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 ;; If we had a split, then this is likely a c++ style namespace::name sequence,
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 ;; so take a short-cut through the typecache.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 (or (semanticdb-typecache-find namelst)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 ;; Ok, not there, try the usual...
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 (let ((seq (semantic-analyze-find-tag-sequence
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 namelst scope nil)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 (semantic-analyze-select-best-tag seq tagclass)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 )))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 ;; If NAME is solo, then do our searches for it here.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 ((stringp namelst)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380 (let ((retlist (and scope (semantic-scope-find name tagclass scope))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 (if retlist
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 (semantic-analyze-select-best-tag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 retlist tagclass)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 (if (eq tagclass 'type)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 (semanticdb-typecache-find name)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 ;; Search in the typecache. First entries in a sequence are
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 ;; often there.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 (setq retlist (semanticdb-typecache-find name))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 (if retlist
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 retlist
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 (semantic-analyze-select-best-tag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 (semanticdb-strip-find-results
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 (semanticdb-find-tags-by-name name)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 'name)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 tagclass)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 )))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 )))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 ;;; SHORT ANALYSIS
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 ;; Create a mini-analysis of just the symbol under point.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 (define-overloadable-function semantic-analyze-current-symbol
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 (analyzehookfcn &optional position)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 "Call ANALYZEHOOKFCN after analyzing the symbol under POSITION.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 The ANALYZEHOOKFCN is called with the current symbol bounds, and the
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407 analyzed prefix. It should take the arguments (START END PREFIX).
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 The ANALYZEHOOKFCN is only called if some sort of prefix with bounds was
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 found under POSITION.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411 The results of ANALYZEHOOKFCN is returned, or nil if there was nothing to
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 call it with.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 For regular analysis, you should call `semantic-analyze-current-context'
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 to calculate the context information. The purpose for this function is
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 to provide a large number of non-cached analysis for filtering symbols."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 ;; Only do this in a Semantic enabled buffer.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 (when (not (semantic-active-p))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 (error "Cannot analyze buffers not supported by Semantic."))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 ;; Always refresh out tags in a safe way before doing the
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 ;; context.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 (semantic-refresh-tags-safe)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 ;; Do the rest of the analysis.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 (save-match-data
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
425 (save-excursion
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 (:override)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 (defun semantic-analyze-current-symbol-default (analyzehookfcn position)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 "Call ANALYZEHOOKFCN on the analyzed symbol at POSITION."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431 (let* ((semantic-analyze-error-stack nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 (LLstart (current-time))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 (prefixandbounds (semantic-ctxt-current-symbol-and-bounds (or position (point))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434 (prefix (car prefixandbounds))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 (bounds (nth 2 prefixandbounds))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436 (scope (semantic-calculate-scope position))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 (end nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 ;; Only do work if we have bounds (meaning a prefix to complete)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 (when bounds
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 (if debug-on-error
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 (catch 'unfindable
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 ;; If debug on error is on, allow debugging in this fcn.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445 (setq prefix (semantic-analyze-find-tag-sequence
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 prefix scope 'prefixtypes 'unfindable)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 ;; Debug on error is off. Capture errors and move on
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448 (condition-case err
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449 ;; NOTE: This line is duplicated in
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 ;; semantic-analyzer-debug-global-symbol
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
451 ;; You will need to update both places.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 (setq prefix (semantic-analyze-find-tag-sequence
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
453 prefix scope 'prefixtypes))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
454 (error (semantic-analyze-push-error err))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
455
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
456 (setq end (current-time))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457 ;;(message "Analysis took %.2f sec" (semantic-elapsed-time LLstart end))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
460 (when prefix
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461 (prog1
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462 (funcall analyzehookfcn (car bounds) (cdr bounds) prefix)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463 ;;(setq end (current-time))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464 ;;(message "hookfcn took %.5f sec" (semantic-elapsed-time LLstart end))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
466
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
467 )))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
469 ;;; MAIN ANALYSIS
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
471 ;; Create a full-up context analysis.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
472 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473 (define-overloadable-function semantic-analyze-current-context (&optional position)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
474 "Analyze the current context at optional POSITION.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
475 If called interactively, display interesting information about POSITION
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
476 in a separate buffer.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
477 Returns an object based on symbol `semantic-analyze-context'.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
479 This function can be overriden with the symbol `analyze-context'.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
480 When overriding this function, your override will be called while
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
481 cursor is at POSITION. In addition, your function will not be called
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482 if a cached copy of the return object is found."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483 (interactive "d")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
484 ;; Only do this in a Semantic enabled buffer.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
485 (when (not (semantic-active-p))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
486 (error "Cannot analyze buffers not supported by Semantic."))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
487 ;; Always refresh out tags in a safe way before doing the
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
488 ;; context.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
489 (semantic-refresh-tags-safe)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
490 ;; Do the rest of the analysis.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
491 (if (not position) (setq position (point)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
492 (save-excursion
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
493 (goto-char position)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
494 (let* ((answer (semantic-get-cache-data 'current-context)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
495 (with-syntax-table semantic-lex-syntax-table
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
496 (when (not answer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
497 (setq answer (:override))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
498 (when (and answer (oref answer bounds))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
499 (with-slots (bounds) answer
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
500 (semantic-cache-data-to-buffer (current-buffer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
501 (car bounds)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
502 (cdr bounds)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
503 answer
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
504 'current-context
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
505 'exit-cache-zone)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
506 ;; Check for interactivity
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
507 (when (interactive-p)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
508 (if answer
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
509 (semantic-analyze-pop-to-context answer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
510 (message "No Context."))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
511 ))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
512
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
513 answer))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
514
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
515 (defun semantic-analyze-current-context-default (position)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
516 "Analyze the current context at POSITION.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
517 Returns an object based on symbol `semantic-analyze-context'."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
518 (let* ((semantic-analyze-error-stack nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
519 (context-return nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
520 (prefixandbounds (semantic-ctxt-current-symbol-and-bounds (or position (point))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
521 (prefix (car prefixandbounds))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
522 (bounds (nth 2 prefixandbounds))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
523 ;; @todo - vv too early to really know this answer! vv
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
524 (prefixclass (semantic-ctxt-current-class-list))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
525 (prefixtypes nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
526 (scope (semantic-calculate-scope position))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
527 (function nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
528 (fntag nil)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
529 arg fntagend argtag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
530 assign asstag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
531 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
532
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
533 ;; Pattern for Analysis:
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
534 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
535 ;; Step 1: Calculate DataTypes in Scope:
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
536 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
537 ;; a) Calculate the scope (above)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
538 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
539 ;; Step 2: Parse context
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
540 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
541 ;; a) Identify function being called, or variable assignment,
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
542 ;; and find source tags for those references
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
543 ;; b) Identify the prefix (text cursor is on) and find the source
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
544 ;; tags for those references.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
545 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
546 ;; Step 3: Assemble an object
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
547 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
548
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
549 ;; Step 2 a:
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
550
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
551 (setq function (semantic-ctxt-current-function))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
552
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
553 (when function
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
554 ;; Calculate the argument for the function if there is one.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
555 (setq arg (semantic-ctxt-current-argument))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
556
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
557 ;; Find a tag related to the function name.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
558 (condition-case err
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
559 (setq fntag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
560 (semantic-analyze-find-tag-sequence function scope))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
561 (error (semantic-analyze-push-error err)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
562
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
563 ;; fntag can have the last entry as just a string, meaning we
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
564 ;; could not find the core datatype. In this case, the searches
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
565 ;; below will not work.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
566 (when (stringp (car (last fntag)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
567 ;; Take a wild guess!
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
568 (setcar (last fntag) (semantic-tag (car (last fntag)) 'function))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
569 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
570
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
571 (when fntag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
572 (let ((fcn (semantic-find-tags-by-class 'function fntag)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
573 (when (not fcn)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
574 (let ((ty (semantic-find-tags-by-class 'type fntag)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
575 (when ty
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
576 ;; We might have a constructor with the same name as
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
577 ;; the found datatype.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
578 (setq fcn (semantic-find-tags-by-name
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
579 (semantic-tag-name (car ty))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
580 (semantic-tag-type-members (car ty))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
581 (if fcn
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
582 (let ((lp fcn))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
583 (while lp
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
584 (when (semantic-tag-get-attribute (car lp)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
585 :constructor)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
586 (setq fcn (cons (car lp) fcn)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
587 (setq lp (cdr lp))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
588 ;; Give up, go old school
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
589 (setq fcn fntag))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
590 )))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
591 (setq fntagend (car (reverse fcn))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
592 argtag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
593 (when (semantic-tag-p fntagend)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
594 (nth (1- arg) (semantic-tag-function-arguments fntagend)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
595 fntag fcn))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
596
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
597 ;; Step 2 b:
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
598
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
599 ;; Only do work if we have bounds (meaning a prefix to complete)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
600 (when bounds
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
601
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
602 (if debug-on-error
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
603 (catch 'unfindable
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
604 ;; If debug on error is on, allow debugging in this fcn.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
605 (setq prefix (semantic-analyze-find-tag-sequence
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
606 prefix scope 'prefixtypes 'unfindable)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
607 ;; Debug on error is off. Capture errors and move on
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
608 (condition-case err
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
609 ;; NOTE: This line is duplicated in
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
610 ;; semantic-analyzer-debug-global-symbol
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
611 ;; You will need to update both places.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
612 (setq prefix (semantic-analyze-find-tag-sequence
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
613 prefix scope 'prefixtypes))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
614 (error (semantic-analyze-push-error err))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
615 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
616
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
617 ;; Step 3:
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
618
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
619 (cond
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
620 (fntag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
621 ;; If we found a tag for our function, we can go into
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
622 ;; functional context analysis mode, meaning we have a type
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
623 ;; for the argument.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
624 (setq context-return
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
625 (semantic-analyze-context-functionarg
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
626 "functionargument"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
627 :buffer (current-buffer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
628 :function fntag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
629 :index arg
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
630 :argument (list argtag)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
631 :scope scope
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
632 :prefix prefix
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
633 :prefixclass prefixclass
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
634 :bounds bounds
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
635 :prefixtypes prefixtypes
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
636 :errors semantic-analyze-error-stack)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
637
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
638 ;; No function, try assignment
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
639 ((and (setq assign (semantic-ctxt-current-assignment))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
640 ;; We have some sort of an assignment
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
641 (condition-case err
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
642 (setq asstag (semantic-analyze-find-tag-sequence
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
643 assign scope))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
644 (error (semantic-analyze-push-error err)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
645 nil)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
646
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
647 (setq context-return
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
648 (semantic-analyze-context-assignment
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
649 "assignment"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
650 :buffer (current-buffer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
651 :assignee asstag
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
652 :scope scope
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
653 :bounds bounds
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
654 :prefix prefix
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
655 :prefixclass prefixclass
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
656 :prefixtypes prefixtypes
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
657 :errors semantic-analyze-error-stack)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
658
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
659 ;; TODO: Identify return value condition.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
660 ;;((setq return .... what to do?)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
661 ;; ...)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
662
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
663 (bounds
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
664 ;; Nothing in particular
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
665 (setq context-return
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
666 (semantic-analyze-context
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
667 "context"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
668 :buffer (current-buffer)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
669 :scope scope
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
670 :bounds bounds
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
671 :prefix prefix
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
672 :prefixclass prefixclass
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
673 :prefixtypes prefixtypes
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
674 :errors semantic-analyze-error-stack)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
675
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
676 (t (setq context-return nil))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
677 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
678
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
679 ;; Return our context.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
680 context-return))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
681
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
682
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
683 ;;; DEBUG OUTPUT
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
684 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
685 ;; Friendly output of a context analysis.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
686 ;;
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
687 (defmethod semantic-analyze-pulse ((context semantic-analyze-context))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
688 "Pulse the region that CONTEXT affects."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
689 (save-excursion
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
690 (set-buffer (oref context :buffer))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
691 (let ((bounds (oref context :bounds)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
692 (when bounds
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
693 (pulse-momentary-highlight-region (car bounds) (cdr bounds))))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
694
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
695 (defcustom semantic-analyze-summary-function 'semantic-format-tag-prototype
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
696 "*Function to use when creating items in Imenu.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
697 Some useful functions are found in `semantic-format-tag-functions'."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
698 :group 'semantic
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
699 :type semantic-format-tag-custom-list)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
700
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
701 (defun semantic-analyze-princ-sequence (sequence &optional prefix buff)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
702 "Send the tag SEQUENCE to standard out.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
703 Use PREFIX as a label.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
704 Use BUFF as a source of override methods."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
705 (while sequence
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
706 (princ prefix)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
707 (cond
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
708 ((semantic-tag-p (car sequence))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
709 (princ (funcall semantic-analyze-summary-function
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
710 (car sequence))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
711 ((stringp (car sequence))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
712 (princ "\"")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
713 (princ (semantic--format-colorize-text (car sequence) 'variable))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
714 (princ "\""))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
715 (t
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
716 (princ (format "'%S" (car sequence)))))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
717 (princ "\n")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
718 (setq sequence (cdr sequence))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
719 (setq prefix (make-string (length prefix) ? ))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
720 ))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
721
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
722 (defmethod semantic-analyze-show ((context semantic-analyze-context))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
723 "Insert CONTEXT into the current buffer in a nice way."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
724 (semantic-analyze-princ-sequence (oref context prefix) "Prefix: " )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
725 (semantic-analyze-princ-sequence (oref context prefixclass) "Prefix Classes: ")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
726 (semantic-analyze-princ-sequence (oref context prefixtypes) "Prefix Types: ")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
727 (semantic-analyze-princ-sequence (oref context errors) "Encountered Errors: ")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
728 (princ "--------\n")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
729 ;(semantic-analyze-princ-sequence (oref context scopetypes) "Scope Types: ")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
730 ;(semantic-analyze-princ-sequence (oref context scope) "Scope: ")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
731 ;(semantic-analyze-princ-sequence (oref context localvariables) "LocalVars: ")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
732 (when (oref context scope)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
733 (semantic-analyze-show (oref context scope)))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
734 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
735
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
736 (defmethod semantic-analyze-show ((context semantic-analyze-context-assignment))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
737 "Insert CONTEXT into the current buffer in a nice way."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
738 (semantic-analyze-princ-sequence (oref context assignee) "Assignee: ")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
739 (call-next-method))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
740
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
741 (defmethod semantic-analyze-show ((context semantic-analyze-context-functionarg))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
742 "Insert CONTEXT into the current buffer in a nice way."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
743 (semantic-analyze-princ-sequence (oref context function) "Function: ")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
744 (princ "Argument Index: ")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
745 (princ (oref context index))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
746 (princ "\n")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
747 (semantic-analyze-princ-sequence (oref context argument) "Argument: ")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
748 (call-next-method))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
749
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
750 (defun semantic-analyze-pop-to-context (context)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
751 "Display CONTEXT in a temporary buffer.
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
752 CONTEXT's content is described in `semantic-analyze-current-context'."
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
753 (semantic-analyze-pulse context)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
754 (with-output-to-temp-buffer "*Semantic Context Analysis*"
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
755 (princ "Context Type: ")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
756 (princ (object-name context))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
757 (princ "\n")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
758 (princ "Bounds: ")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
759 (princ (oref context bounds))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
760 (princ "\n")
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
761 (semantic-analyze-show context)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
762 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
763 (shrink-window-if-larger-than-buffer
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
764 (get-buffer-window "*Semantic Context Analysis*"))
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
765 )
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
766
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
767 (provide 'semantic/analyze)
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
768
b1ac14799f78 cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
769 ;;; semantic-analyze.el ends here