Mercurial > emacs
annotate lisp/cedet/semantic/analyze.el @ 106032:42cdafa98c50
(mode-line-buffer-identification): Do not purecopy.
author | Dan Nicolaescu <dann@ics.uci.edu> |
---|---|
date | Sun, 15 Nov 2009 20:25:55 +0000 |
parents | 83dde921cc1b |
children | 019d906c8f48 |
rev | line source |
---|---|
104439
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
1 ;;; semantic/analyze.el --- Analyze semantic tags against local context |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2 |
105340 | 3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 |
4 ;; Free Software Foundation, Inc. | |
104419
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. |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104490
diff
changeset
|
66 |
105652
51bc239bdc37
* cedet/srecode/srt.el:
Chong Yidong <cyd@stupidchicken.com>
parents:
105377
diff
changeset
|
67 (eval-when-compile (require 'cl)) |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
68 (require 'semantic) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
69 (require 'semantic/format) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
70 (require 'semantic/ctxt) |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104490
diff
changeset
|
71 (require 'semantic/scope) |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
72 (require 'semantic/sort) |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104490
diff
changeset
|
73 (require 'semantic/analyze/fcn) |
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104490
diff
changeset
|
74 |
104439
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
75 (eval-when-compile (require 'semantic/find)) |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
76 |
104490
7811201f57f2
* cedet/semantic/analyze/fcn.el (semantic-analyze-dereference-metatype-1)
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
77 (declare-function data-debug-new-buffer "data-debug") |
7811201f57f2
* cedet/semantic/analyze/fcn.el (semantic-analyze-dereference-metatype-1)
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
78 (declare-function data-debug-insert-object-slots "eieio-datadebug") |
7811201f57f2
* cedet/semantic/analyze/fcn.el (semantic-analyze-dereference-metatype-1)
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
79 |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
80 ;;; Code: |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 (defvar semantic-analyze-error-stack nil |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
82 "Collection of any errors thrown during analysis.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
83 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
84 (defun semantic-analyze-push-error (err) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
85 "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
|
86 Argument ERR" |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
87 (push err semantic-analyze-error-stack)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
88 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
89 ;;; Analysis Classes |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
90 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
91 ;; 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
|
92 ;; 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
|
93 ;; provide completions. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
94 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
95 (defclass semantic-analyze-context () |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
96 ((bounds :initarg :bounds |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
97 :type list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
98 :documentation "The bounds of this context. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
99 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
|
100 (prefix :initarg :prefix |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
101 :type list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
102 :documentation "List of tags defining local text. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
103 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
|
104 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
|
105 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
|
106 called in a dereference sequence.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
107 (prefixclass :initarg :prefixclass |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
108 :type list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
109 :documentation "Tag classes expected at this context. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
110 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
|
111 (prefixtypes :initarg :prefixtypes |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
112 :type list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
113 :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
|
114 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
|
115 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
|
116 position in PREFIX.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
117 (scope :initarg :scope |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
118 :type (or null semantic-scope-cache) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
119 :documentation "List of tags available in scopetype. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
120 See `semantic-analyze-scoped-tags' for details.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
121 (buffer :initarg :buffer |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
122 :type buffer |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
123 :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
|
124 (errors :initarg :errors |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
125 :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
|
126 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
127 "Base analysis data for a any context.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
128 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
129 (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
|
130 ((assignee :initarg :assignee |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
131 :type list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
132 :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
|
133 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
|
134 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
|
135 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
|
136 assignee.")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
137 "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
|
138 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
139 (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
|
140 ((function :initarg :function |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
141 :type list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
142 :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
|
143 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
|
144 of an argument. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
145 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
|
146 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
|
147 function.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
148 (index :initarg :index |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
149 :type integer |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
150 :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
|
151 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
|
152 the values 1 through 4.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
153 (argument :initarg :argument |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
154 :type list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
155 :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
|
156 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
|
157 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
|
158 be just a string in some circumstances.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
159 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
160 "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
|
161 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
162 (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
|
163 () ; No extra data. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
164 "Analysis class for return data. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
165 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
|
166 of the parent function.") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
167 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
168 ;;; METHODS |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
169 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
170 ;; Simple methods against the context classes. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
171 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
172 (defmethod semantic-analyze-type-constraint |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
173 ((context semantic-analyze-context) &optional desired-type) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
174 "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
|
175 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
|
176 (when (semantic-tag-p desired-type) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
177 ;; Convert the desired type if needed. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
178 (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
|
179 (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
|
180 ;; Protect against plain strings |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
181 (cond ((stringp desired-type) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
182 (setq desired-type (list desired-type 'type))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
183 ((and (stringp (car desired-type)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
184 (not (semantic-tag-p desired-type))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
185 (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
|
186 ((semantic-tag-p desired-type) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
187 ;; 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
|
188 nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
189 (t (setq desired-type nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
190 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
191 desired-type)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
192 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
193 (defmethod semantic-analyze-type-constraint |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
194 ((context semantic-analyze-context-functionarg)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
195 "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
|
196 (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
|
197 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
198 (defmethod semantic-analyze-type-constraint |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
199 ((context semantic-analyze-context-assignment)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
200 "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
|
201 (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
|
202 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
203 (defmethod semantic-analyze-interesting-tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
204 ((context semantic-analyze-context)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
205 "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
|
206 (let ((prefix (reverse (oref context :prefix)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
207 ;; 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
|
208 (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
|
209 (setq prefix (cdr prefix))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
210 ;; Return the found tag, or nil. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
211 (car prefix))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
212 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
213 (defmethod semantic-analyze-interesting-tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
214 ((context semantic-analyze-context-functionarg)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
215 "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
|
216 (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
|
217 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
218 (defmethod semantic-analyze-interesting-tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
219 ((context semantic-analyze-context-assignment)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
220 "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
|
221 (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
|
222 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
223 ;;; ANALYSIS |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
224 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
225 ;; 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
|
226 ;; 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
|
227 ;; 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
|
228 ;; context. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
229 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
230 (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
|
231 scope typereturn throwsym) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
232 "Attempt to find all tags in SEQUENCE. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
233 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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 which doesn't need to be dereferneced. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
239 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
|
240 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
|
241 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
|
242 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
243 (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
|
244 scope typereturn |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
245 throwsym) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
246 "Attempt to find all tags in SEQUENCE. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
247 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
|
248 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
|
249 are found in SEQUENCE. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
250 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
|
251 (let ((s sequence) ; copy of the sequence |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
252 (tmp nil) ; tmp find variable |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
253 (tag nil) ; tag return list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
254 (tagtype nil) ; tag types return list |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
255 (fname nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
256 (miniscope (clone scope)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
257 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
258 ;; 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
|
259 (setq tmp (semanticdb-typecache-find sequence)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
260 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
261 (if tmp |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
262 (progn |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
263 ;; We are effectively done... |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
264 (setq s nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
265 (setq tag (list tmp))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
266 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
267 ;; 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
|
268 ;; be in the local context too. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
269 ;; 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
|
270 (setq tmp (or |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
271 ;; 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
|
272 ;; shadow other things, so it goes first. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
273 (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
|
274 ;; 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
|
275 (semantic-analyze-find-tag (car s)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
276 )) |
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 (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
|
279 (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
|
280 (if (not (semantic-tag-p tmp)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
281 (if throwsym |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
282 (throw throwsym "Cannot find definition") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
283 (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
|
284 (setq s (cdr s)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
285 (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
|
286 (setq fname (semantic-tag-file-name tmp)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
287 ) |
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 ;; For the middle entries |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
290 (while s |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
291 ;; 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
|
292 ;; representing the full typeographic information of its |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
293 ;; 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
|
294 ;; (car s) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
295 (let* ((tmptype |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
296 ;; 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
|
297 ;; and we can use it directly. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
298 (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
|
299 ;; 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
|
300 (let ((rawscope |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
301 (apply 'append |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
302 (mapcar 'semantic-tag-type-members |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
303 tagtype)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
304 (oset miniscope fullscope rawscope)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
305 ;; Now analayze the type to remove metatypes. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
306 (or (semantic-analyze-type tmp miniscope) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
307 tmp)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
308 (t |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
309 (semantic-analyze-tag-type tmp scope)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
310 (typefile |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
311 (when tmptype |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
312 (semantic-tag-file-name tmptype))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
313 (slots nil)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
314 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
315 ;; Get the children |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
316 (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
|
317 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
318 ;; 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
|
319 (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
|
320 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
321 ;; If we have lots |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
322 (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
|
323 (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
|
324 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
325 ;; Make sure we have a tag. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
326 (if (not (semantic-tag-p tmp)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
327 (if (cdr s) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
328 ;; 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
|
329 (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
|
330 ;; 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
|
331 (setq tmp (car s)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
332 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
333 (setq fname (or typefile fname)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
334 (when (and fname (semantic-tag-p tmp) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
335 (not (semantic-tag-in-buffer-p tmp))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
336 (semantic--tag-put-property tmp :filename fname)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
337 (setq tag (cons tmp tag)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
338 (setq tagtype (cons tmptype tagtype)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
339 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
340 (setq s (cdr s))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
341 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
342 (if typereturn (set typereturn (nreverse tagtype))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
343 ;; Return the mess |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
344 (nreverse tag))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
345 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
346 (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
|
347 "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
|
348 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
|
349 as 'function or 'variable. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
350 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
|
351 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
|
352 find. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
353 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
354 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
|
355 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
|
356 searches use the same arguments." |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
357 (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
|
358 (semantic-analyze-split-name name)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
359 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
360 ;; 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
|
361 ;; 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
|
362 ;; 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
|
363 ;; which is supposedly the nested reference. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
364 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
365 ;; 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
|
366 ;; (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
|
367 ;; fcn better not, in turn, be splittable. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
368 ((listp namelst) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
369 ;; 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
|
370 ;; 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
|
371 (or (semanticdb-typecache-find namelst) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
372 ;; Ok, not there, try the usual... |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
373 (let ((seq (semantic-analyze-find-tag-sequence |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
374 namelst scope nil))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
375 (semantic-analyze-select-best-tag seq tagclass) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
376 ))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
377 ;; 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
|
378 ((stringp namelst) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
379 (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
|
380 (if retlist |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
381 (semantic-analyze-select-best-tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
382 retlist tagclass) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
383 (if (eq tagclass 'type) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
384 (semanticdb-typecache-find name) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
385 ;; 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
|
386 ;; often there. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
387 (setq retlist (semanticdb-typecache-find name)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
388 (if retlist |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
389 retlist |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
390 (semantic-analyze-select-best-tag |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
391 (semanticdb-strip-find-results |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
392 (semanticdb-find-tags-by-name name) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
393 'name) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
394 tagclass) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
395 ))))) |
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 ;;; SHORT ANALYSIS |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
399 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
400 ;; 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
|
401 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
402 (define-overloadable-function semantic-analyze-current-symbol |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
403 (analyzehookfcn &optional position) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
404 "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
|
405 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
|
406 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
|
407 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
|
408 found under POSITION. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
409 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
410 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
|
411 call it with. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
412 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
413 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
|
414 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
|
415 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
|
416 ;; 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
|
417 (when (not (semantic-active-p)) |
105340 | 418 (error "Cannot analyze buffers not supported by Semantic")) |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
419 ;; 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
|
420 ;; context. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
421 (semantic-refresh-tags-safe) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
422 ;; Do the rest of the analysis. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
423 (save-match-data |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
424 (save-excursion |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
425 (:override))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
426 ) |
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 (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
|
429 "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
|
430 (let* ((semantic-analyze-error-stack nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
431 (LLstart (current-time)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
432 (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
|
433 (prefix (car prefixandbounds)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
434 (bounds (nth 2 prefixandbounds)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
435 (scope (semantic-calculate-scope position)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
436 (end nil) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
437 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
438 ;; 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
|
439 (when bounds |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
440 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
441 (if debug-on-error |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
442 (catch 'unfindable |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
443 ;; 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
|
444 (setq prefix (semantic-analyze-find-tag-sequence |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
445 prefix scope 'prefixtypes 'unfindable))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
446 ;; 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
|
447 (condition-case err |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
448 ;; NOTE: This line is duplicated in |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
449 ;; semantic-analyzer-debug-global-symbol |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
450 ;; You will need to update both places. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
451 (setq prefix (semantic-analyze-find-tag-sequence |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
452 prefix scope 'prefixtypes)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
453 (error (semantic-analyze-push-error err)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
454 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
455 (setq end (current-time)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
456 ;;(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
|
457 |
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 (when prefix |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
460 (prog1 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
461 (funcall analyzehookfcn (car bounds) (cdr bounds) prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
462 ;;(setq end (current-time)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
463 ;;(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
|
464 ) |
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 ;;; MAIN ANALYSIS |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
469 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
470 ;; Create a full-up context analysis. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
471 ;; |
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
472 ;;;###autoload |
104419
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)) |
105340 | 486 (error "Cannot analyze buffers not supported by Semantic")) |
104419
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 |
104489
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
683 (defun semantic-adebug-analyze (&optional ctxt) |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
684 "Perform `semantic-analyze-current-context'. |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
685 Display the results as a debug list. |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
686 Optional argument CTXT is the context to show." |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
687 (interactive) |
104490
7811201f57f2
* cedet/semantic/analyze/fcn.el (semantic-analyze-dereference-metatype-1)
Chong Yidong <cyd@stupidchicken.com>
parents:
104489
diff
changeset
|
688 (require 'data-debug) |
104489
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
689 (let ((start (current-time)) |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
690 (ctxt (or ctxt (semantic-analyze-current-context))) |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
691 (end (current-time))) |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
692 (if (not ctxt) |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
693 (message "No Analyzer Results") |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
694 (message "Analysis took %.2f seconds." |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
695 (semantic-elapsed-time start end)) |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
696 (semantic-analyze-pulse ctxt) |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
697 (if ctxt |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
698 (progn |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
699 (data-debug-new-buffer "*Analyzer ADEBUG*") |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
700 (data-debug-insert-object-slots ctxt "]")) |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
701 (message "No Context to analyze here."))))) |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
702 |
25e047f7f6a2
Synch to Eric Ludlam's upstream CEDET repository.
Chong Yidong <cyd@stupidchicken.com>
parents:
104470
diff
changeset
|
703 |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
704 ;;; DEBUG OUTPUT |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
705 ;; |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
706 ;; Friendly output of a context analysis. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
707 ;; |
104439
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
708 (declare-function pulse-momentary-highlight-region "pulse") |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
709 |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
710 (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
|
711 "Pulse the region that CONTEXT affects." |
104439
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
712 (require 'pulse) |
105799
3fe6da4a95a9
* cedet/srecode/srt-mode.el (semantic-analyze-possible-completions):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
105652
diff
changeset
|
713 (with-current-buffer (oref context :buffer) |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
714 (let ((bounds (oref context :bounds))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
715 (when bounds |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
716 (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
|
717 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
718 (defcustom semantic-analyze-summary-function 'semantic-format-tag-prototype |
105260
bbd7017a25d9
CEDET (development tools) package merged.
Chong Yidong <cyd@stupidchicken.com>
parents:
104490
diff
changeset
|
719 "Function to use when creating items in Imenu. |
104419
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
720 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
|
721 :group 'semantic |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
722 :type semantic-format-tag-custom-list) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
723 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
724 (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
|
725 "Send the tag SEQUENCE to standard out. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
726 Use PREFIX as a label. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
727 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
|
728 (while sequence |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
729 (princ prefix) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
730 (cond |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
731 ((semantic-tag-p (car sequence)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
732 (princ (funcall semantic-analyze-summary-function |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
733 (car sequence)))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
734 ((stringp (car sequence)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
735 (princ "\"") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
736 (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
|
737 (princ "\"")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
738 (t |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
739 (princ (format "'%S" (car sequence))))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
740 (princ "\n") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
741 (setq sequence (cdr sequence)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
742 (setq prefix (make-string (length prefix) ? )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
743 )) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
744 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
745 (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
|
746 "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
|
747 (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
|
748 (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
|
749 (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
|
750 (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
|
751 (princ "--------\n") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
752 ;(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
|
753 ;(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
|
754 ;(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
|
755 (when (oref context scope) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
756 (semantic-analyze-show (oref context scope))) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
757 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
758 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
759 (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
|
760 "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
|
761 (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
|
762 (call-next-method)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
763 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
764 (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
|
765 "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
|
766 (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
|
767 (princ "Argument Index: ") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
768 (princ (oref context index)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
769 (princ "\n") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
770 (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
|
771 (call-next-method)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
772 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
773 (defun semantic-analyze-pop-to-context (context) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
774 "Display CONTEXT in a temporary buffer. |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
775 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
|
776 (semantic-analyze-pulse context) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
777 (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
|
778 (princ "Context Type: ") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
779 (princ (object-name context)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
780 (princ "\n") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
781 (princ "Bounds: ") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
782 (princ (oref context bounds)) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
783 (princ "\n") |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
784 (semantic-analyze-show context) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
785 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
786 (shrink-window-if-larger-than-buffer |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
787 (get-buffer-window "*Semantic Context Analysis*")) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
788 ) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
789 |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
790 (provide 'semantic/analyze) |
b1ac14799f78
cedet/semantic/analyze.el, cedet/semantic/complete.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
791 |
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
792 ;; Local variables: |
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
793 ;; generated-autoload-file: "loaddefs.el" |
104447
273e528a9f9b
* emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents:
104446
diff
changeset
|
794 ;; generated-autoload-load-name: "semantic/analyze" |
104446
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
795 ;; End: |
df08b7ab0ba0
lisp/cedet/semantic/analyze.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents:
104444
diff
changeset
|
796 |
105377 | 797 ;; arch-tag: 1102143a-1c05-4631-83e8-45aafc6b4a59 |
104439
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104419
diff
changeset
|
798 ;;; semantic/analyze.el ends here |