annotate lisp/cedet/semantic/ia.el @ 111191:ed5bac97776a

* term/ns-win.el (ns-new-frame, ns-show-prefs): Don't add to global map. * term/common-win.el (x-setup-function-keys): Remove most of the keymappings. Comment on the remaining ones.
author Adrian Robert <Adrian.B.Robert@gmail.com>
date Tue, 26 Oct 2010 16:20:00 +0300
parents b799d38f522a
children 417b1e4d63cd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104461
c89254e41c98 lisp/cedet/semantic/ia.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
1 ;;; semantic/ia.el --- Interactive Analysis functions
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
3 ;;; Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
106815
1d1d5d9bd884 Add 2010 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 106444
diff changeset
4 ;;; 2008, 2009, 2010 Free Software Foundation, Inc.
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6 ;; Author: Eric M. Ludlam <zappo@gnu.org>
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; Keywords: syntax
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13 ;; the Free Software Foundation, either version 3 of the License, or
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; (at your option) any later version.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; GNU General Public License for more details.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;;; Commentary:
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; Interactive access to `semantic-analyze'.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;; These routines are fairly simple, and show how to use the Semantic
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;; analyzer to provide things such as completion lists, summaries,
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;; locations, or documentation.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;;; TODO
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 ;; fast-jump. For a virtual method, offer some of the possible
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 ;; implementations in various sub-classes.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 (require 'semantic/analyze)
104447
273e528a9f9b * emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
39 (require 'semantic/format)
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 (require 'pulse)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 (eval-when-compile
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 (require 'semantic/analyze)
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
43 (require 'semantic/analyze/refs)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
44 (require 'semantic/find))
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
46 (declare-function imenu--mouse-menu "imenu")
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
47
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 ;;; Code:
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 ;;; COMPLETION
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 ;; This set of routines provides some simplisting completion
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 ;; functions.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 (defcustom semantic-ia-completion-format-tag-function
106196
2721ecb2b07c * cedet/semantic/ia.el (semantic-ia-completion-format-tag-function):
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
56 'semantic-format-tag-prototype
2721ecb2b07c * cedet/semantic/ia.el (semantic-ia-completion-format-tag-function):
Chong Yidong <cyd@stupidchicken.com>
parents: 105842
diff changeset
57 "Function used to convert a tag to a string during completion."
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 :group 'semantic
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 :type semantic-format-tag-custom-list)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
61 ;;; COMPLETION HELPER
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
62 ;;
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
63 ;; This overload function handles inserting a tag
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
64 ;; into a buffer for these local completion routines.
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
65 ;;
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
66 ;; By creating the functions as overloadable, it can be
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
67 ;; customized. For example, the default will put a paren "("
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
68 ;; character after function names. For Lisp, it might check
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
69 ;; to put a "(" in front of a function name.
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
70
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
71 (define-overloadable-function semantic-ia-insert-tag (tag)
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
72 "Insert TAG into the current buffer based on completion.")
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
73
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
74 (defun semantic-ia-insert-tag-default (tag)
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
75 "Insert TAG into the current buffer based on completion."
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
76 (insert (semantic-tag-name tag))
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
77 (let ((tt (semantic-tag-class tag)))
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
78 (cond ((eq tt 'function)
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
79 (insert "("))
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
80 (t nil))))
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
81
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
82 (defalias 'semantic-ia-get-completions 'semantic-ia-get-completions-deprecated
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
83 "`Semantic-ia-get-completions' is obsolete.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
84 Use `semantic-analyze-possible-completions' instead.")
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
85
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
86 (defun semantic-ia-get-completions-deprecated (context point)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
87 "A function to help transition away from `semantic-ia-get-completions'.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
88 Return completions based on CONTEXT at POINT.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
89 You should not use this, nor the aliased version.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
90 Use `semantic-analyze-possible-completions' instead."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
91 (semantic-analyze-possible-completions context))
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92
104461
c89254e41c98 lisp/cedet/semantic/ia.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
93 ;;;###autoload
106444
a72f79f89185 * bindings.el (complete-symbol): Call semantic-ia-complete-symbol if
Chong Yidong <cyd@stupidchicken.com>
parents: 106196
diff changeset
94 (defun semantic-ia-complete-symbol (&optional pos)
a72f79f89185 * bindings.el (complete-symbol): Call semantic-ia-complete-symbol if
Chong Yidong <cyd@stupidchicken.com>
parents: 106196
diff changeset
95 "Complete the current symbol at POS.
a72f79f89185 * bindings.el (complete-symbol): Call semantic-ia-complete-symbol if
Chong Yidong <cyd@stupidchicken.com>
parents: 106196
diff changeset
96 If POS is nil, default to point.
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 Completion options are calculated with `semantic-analyze-possible-completions'."
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 (interactive "d")
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
99 (when (semantic-active-p)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
100 (or pos (setq pos (point)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
101 ;; Calculating completions is a two step process.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
102 ;;
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
103 ;; The first analyzer the current context, which finds tags for
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
104 ;; all the stuff that may be references by the code around POS.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
105 ;;
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
106 ;; The second step derives completions from that context.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
107 (let* ((a (semantic-analyze-current-context pos))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
108 (syms (semantic-analyze-possible-completions a))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
109 (pre (car (reverse (oref a prefix)))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
110 ;; If PRE was actually an already completed symbol, it doesn't
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
111 ;; come in as a string, but as a tag instead.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
112 (if (semantic-tag-p pre)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
113 ;; We will try completions on it anyway.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
114 (setq pre (semantic-tag-name pre)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
115 ;; Complete this symbol.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
116 (if (null syms)
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 (if (semantic-analyze-context-p a)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 ;; This is a clever hack. If we were unable to find any
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 ;; smart completions, lets divert to how senator derives
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 ;; completions.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 ;;
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
122 ;; This is a way of making this fcn more useful since
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
123 ;; the smart completion engine sometimes failes.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
124 (semantic-complete-symbol))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
125 ;; Use try completion to seek a common substring.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
126 (let ((tc (try-completion (or pre "") syms)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
127 (if (and (stringp tc) (not (string= tc (or pre ""))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
128 (let ((tok (semantic-find-first-tag-by-name
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
129 tc syms)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
130 ;; Delete what came before...
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
131 (when (and (car (oref a bounds)) (cdr (oref a bounds)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
132 (delete-region (car (oref a bounds))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
133 (cdr (oref a bounds)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
134 (goto-char (car (oref a bounds))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
135 ;; We have some new text. Stick it in.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
136 (if tok
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
137 (semantic-ia-insert-tag tok)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
138 (insert tc)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
139 ;; We don't have new text. Show all completions.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
140 (when (cdr (oref a bounds))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
141 (goto-char (cdr (oref a bounds))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
142 (with-output-to-temp-buffer "*Completions*"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
143 (display-completion-list
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
144 (mapcar semantic-ia-completion-format-tag-function syms)))))))))
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 (defcustom semantic-ia-completion-menu-format-tag-function
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 'semantic-uml-concise-prototype-nonterminal
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 "*Function used to convert a tag to a string during completion."
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 :group 'semantic
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 :type semantic-format-tag-custom-list)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 ;;; Completions Tip
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 ;; This functions shows how to get the list of completions,
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 ;; to place in a tooltip. It doesn't actually do any completion.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156
104461
c89254e41c98 lisp/cedet/semantic/ia.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
157 ;;;###autoload
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 (defun semantic-ia-complete-tip (point)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 "Pop up a tooltip for completion at POINT."
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 (interactive "d")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 (let* ((a (semantic-analyze-current-context point))
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
162 (syms (semantic-analyze-possible-completions a))
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 (x (mod (- (current-column) (window-hscroll))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 (window-width)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 (y (save-excursion
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 (save-restriction
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 (widen)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168 (narrow-to-region (window-start) (point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 (goto-char (point-min))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 (1+ (vertical-motion (buffer-size))))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 (str (mapconcat #'semantic-tag-name
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 syms
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 "\n"))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 (cond ((fboundp 'x-show-tip)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 (x-show-tip str
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 (selected-frame)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 nil
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 nil
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 x y)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 (t (message str))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 )))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 ;;; Summary
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 ;; Like idle-summary-mode, this shows how to get something to
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 ;; show a summary on.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189
104461
c89254e41c98 lisp/cedet/semantic/ia.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
190 ;;;###autoload
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 (defun semantic-ia-show-summary (point)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 "Display a summary for the symbol under POINT."
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 (interactive "P")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 (let* ((ctxt (semantic-analyze-current-context point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 (pf (when ctxt
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 ;; The CTXT is an EIEIO object. The below
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 ;; method will attempt to pick the most interesting
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 ;; tag associated with the current context.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 (semantic-analyze-interesting-tag ctxt)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 )
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
201 (if pf
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
202 (message "%s" (semantic-format-tag-summarize pf nil t))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
203 (message "No summary info availalble"))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
204
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
205 ;;; Variants
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
206 ;;
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
207 ;; Show all variants for the symbol under point.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
208
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
209 ;;;###autoload
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
210 (defun semantic-ia-show-variants (point)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
211 "Display a list of all variants for the symbol under POINT."
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
212 (interactive "P")
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
213 (let* ((ctxt (semantic-analyze-current-context point))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
214 (comp nil))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
215
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
216 ;; We really want to look at the function if we are on an
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
217 ;; argument. Are there some additional rules we care about for
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
218 ;; changing the CTXT we look at?
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
219 (when (semantic-analyze-context-functionarg-p ctxt)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
220 (goto-char (cdr (oref ctxt bounds)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
221 (setq ctxt (semantic-analyze-current-context (point))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
222
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
223 ;; Get the "completion list", but remove ALL filters to get the master list
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
224 ;; of all the possible things.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
225 (setq comp (semantic-analyze-possible-completions ctxt 'no-unique 'no-tc))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
226
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
227 ;; Special case for a single type. List the constructors?
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
228 (when (and (= (length comp) 1) (semantic-tag-of-class-p (car comp) 'type))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
229 (setq comp (semantic-find-tags-by-name (semantic-tag-name (car comp))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
230 (semantic-tag-type-members (car comp)))))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
231
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
232 ;; Display the results.
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
233 (cond ((= (length comp) 0)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
234 (message "No Variants found."))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
235 ((= (length comp) 1)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
236 (message "%s" (semantic-format-tag-summarize (car comp) nil t)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
237 (t
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
238 (with-output-to-temp-buffer "*Symbol Variants*"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
239 (semantic-analyze-princ-sequence comp "" (current-buffer)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
240 (shrink-window-if-larger-than-buffer
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
241 (get-buffer-window "*Symbol Variants*")))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
242 )))
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244 ;;; FAST Jump
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 ;; Jump to a destination based on the local context.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 ;; This shows how to use the analyzer context, and the
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 ;; analyer references objects to choose a good destination.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 (defun semantic-ia--fast-jump-helper (dest)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 "Jump to DEST, a Semantic tag.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 This helper manages the mark, buffer switching, and pulsing."
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 ;; We have a tag, but in C++, we usually get a prototype instead
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 ;; because of header files. Lets try to find the actual
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 ;; implementaion instead.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 (when (semantic-tag-prototype-p dest)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 (let* ((refs (semantic-analyze-tag-references dest))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 (impl (semantic-analyze-refs-impl refs t))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 (when impl (setq dest (car impl)))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 ;; Make sure we have a place to go...
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 (if (not (and (or (semantic-tag-with-position-p dest)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 (semantic-tag-get-attribute dest :line))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 (semantic-tag-file-name dest)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 (error "Tag %s has no buffer information"
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 (semantic-format-tag-name dest)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 ;; Once we have the tag, we can jump to it. Here
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 ;; are the key bits to the jump:
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 ;; 1) Push the mark, so you can pop global mark back, or
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 ;; use semantic-mru-bookmark mode to do so.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 (push-mark)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 (when (fboundp 'push-tag-mark)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 (push-tag-mark))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 ;; 2) Visits the tag.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 (semantic-go-to-tag dest)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 ;; 3) go-to-tag doesn't switch the buffer in the current window,
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 ;; so it is like find-file-noselect. Bring it forward.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 (switch-to-buffer (current-buffer))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 ;; 4) Fancy pulsing.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284 (pulse-momentary-highlight-one-line (point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
287 (declare-function semantic-decoration-include-visit "semantic/decorate/include")
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
288
104461
c89254e41c98 lisp/cedet/semantic/ia.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
289 ;;;###autoload
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 (defun semantic-ia-fast-jump (point)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 "Jump to the tag referred to by the code at POINT.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 Uses `semantic-analyze-current-context' output to identify an accurate
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 origin of the code at point."
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294 (interactive "d")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 (let* ((ctxt (semantic-analyze-current-context point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 (pf (and ctxt (reverse (oref ctxt prefix))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 ;; In the analyzer context, the PREFIX is the list of items
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 ;; that makes up the code context at point. Thus the c++ code
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 ;; this.that().theothe
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 ;; would make a list:
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 ;; ( ("this" variable ..) ("that" function ...) "theothe")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 ;; Where the first two elements are the semantic tags of the prefix.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 ;; PF is the reverse of this list. If the first item is a string,
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 ;; then it is an incomplete symbol, thus we pick the second.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 ;; The second cannot be a string, as that would have been an error.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 (first (car pf))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 (second (nth 1 pf))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 (cond
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 ((semantic-tag-p first)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 ;; We have a match. Just go there.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 (semantic-ia--fast-jump-helper first))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 ((semantic-tag-p second)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 ;; Because FIRST failed, we should visit our second tag.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 ;; HOWEVER, the tag we actually want that was only an unfound
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 ;; string may be related to some take in the datatype that belongs
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 ;; to SECOND. Thus, instead of visiting second directly, we
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 ;; can offer to find the type of SECOND, and go there.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 (let ((secondclass (car (reverse (oref ctxt prefixtypes)))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322 (cond
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 ((and (semantic-tag-with-position-p secondclass)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 (y-or-n-p (format "Could not find `%s'. Jump to %s? "
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 first (semantic-tag-name secondclass))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 (semantic-ia--fast-jump-helper secondclass)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 ;; If we missed out on the class of the second item, then
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 ;; just visit SECOND.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 ((and (semantic-tag-p second)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 (y-or-n-p (format "Could not find `%s'. Jump to %s? "
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 first (semantic-tag-name second))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333 (semantic-ia--fast-jump-helper second)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 ))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 ((semantic-tag-of-class-p (semantic-current-tag) 'include)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 ;; Just borrow this cool fcn.
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
338 (require 'semantic/decorate/include)
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339 (semantic-decoration-include-visit)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 (t
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 (error "Could not find suitable jump point for %s"
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344 first))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 )))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346
104461
c89254e41c98 lisp/cedet/semantic/ia.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
347 ;;;###autoload
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 (defun semantic-ia-fast-mouse-jump (evt)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349 "Jump to the tag referred to by the point clicked on.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 See `semantic-ia-fast-jump' for details on how it works.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 This command is meant to be bound to a mouse event."
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 (interactive "e")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 (semantic-ia-fast-jump
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 (save-excursion
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355 (posn-set-point (event-end evt))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
356 (point))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
357
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 ;;; DOC/DESCRIBE
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 ;; These routines show how to get additional information about a tag
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 ;; for purposes of describing or showing documentation about them.
104461
c89254e41c98 lisp/cedet/semantic/ia.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
362 ;;;###autoload
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363 (defun semantic-ia-show-doc (point)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 "Display the code-level documentation for the symbol at POINT."
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 (interactive "d")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 (let* ((ctxt (semantic-analyze-current-context point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 (pf (reverse (oref ctxt prefix)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 ;; If PF, the prefix is non-nil, then the last element is either
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 ;; a string (incomplete type), or a semantic TAG. If it is a TAG
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 ;; then we should be able to find DOC for it.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 (cond
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 ((stringp (car pf))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 (message "Incomplete symbol name."))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375 ((semantic-tag-p (car pf))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 ;; The `semantic-documentation-for-tag' fcn is language
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 ;; specific. If it doesn't return what you expect, you may
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 ;; need to implement something for your language.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380 ;; The default tries to find a comment in front of the tag
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 ;; and then strings off comment prefixes.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 (let ((doc (semantic-documentation-for-tag (car pf))))
110523
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
383 (if (or (null doc) (string= doc ""))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
384 (message "Doc unavailable for: %s"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
385 (semantic-format-tag-prototype (car pf)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
386 (with-output-to-temp-buffer "*TAG DOCUMENTATION*"
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
387 (princ "Tag: ")
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
388 (princ (semantic-format-tag-prototype (car pf)))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
389 (princ "\n")
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
390 (princ "\n")
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
391 (princ "Snarfed Documentation: ")
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
392 (princ "\n")
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
393 (princ "\n")
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
394 (if doc
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
395 (princ doc)
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
396 (princ " Documentation unavailable."))
a5ad4f188e19 Synch Semantic to CEDET 1.0.
Chong Yidong <cyd@stupidchicken.com>
parents: 106815
diff changeset
397 ))))
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 (t
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 (message "Unknown tag.")))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 ))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401
104461
c89254e41c98 lisp/cedet/semantic/ia.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
402 ;;;###autoload
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 (defun semantic-ia-describe-class (typename)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 "Display all known parts for the datatype TYPENAME.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 If the type in question is a class, all methods and other accessible
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 parts of the parent classes are displayed."
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407 ;; @todo - use a fancy completing reader.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 (interactive "sType Name: ")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 ;; When looking for a tag of any name there are a couple ways to do
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411 ;; it. The simple `semanticdb-find-tag-by-...' are simple, and
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 ;; you need to pass it the exact name you want.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 ;; The analyzer function `semantic-analyze-tag-name' will take
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 ;; more complex names, such as the cpp symbol foo::bar::baz,
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 ;; and break it up, and dive through the namespaces.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 (let ((class (semantic-analyze-find-tag typename)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 (when (not (semantic-tag-p class))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 (error "Cannot find class %s" class))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 (with-output-to-temp-buffer "*TAG DOCUMENTATION*"
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 ;; There are many semantic-format-tag-* fcns.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 ;; The summarize routine is a fairly generic one.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 (princ (semantic-format-tag-summarize class))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
425 (princ "\n")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 (princ " Type Members:\n")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 ;; The type tag contains all the parts of the type.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428 ;; In complex languages with inheritance, not all the
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 ;; parts are in the tag. This analyzer fcn will traverse
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 ;; the inheritance tree, and find all the pieces that
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431 ;; are inherited.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 (let ((parts (semantic-analyze-scoped-type-parts class)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 (while parts
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434 (princ " ")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 (princ (semantic-format-tag-summarize (car parts)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436 (princ "\n")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 (setq parts (cdr parts)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 )))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441 (provide 'semantic/ia)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442
104461
c89254e41c98 lisp/cedet/semantic/ia.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
443 ;; Local variables:
c89254e41c98 lisp/cedet/semantic/ia.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
444 ;; generated-autoload-file: "loaddefs.el"
c89254e41c98 lisp/cedet/semantic/ia.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
445 ;; generated-autoload-load-name: "semantic/ia"
c89254e41c98 lisp/cedet/semantic/ia.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
446 ;; End:
c89254e41c98 lisp/cedet/semantic/ia.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
447
105377
7f4c7f5c0eba Add arch tagline
Miles Bader <miles@gnu.org>
parents: 104522
diff changeset
448 ;; arch-tag: ceeed1f2-e5b6-4f7c-a85a-a2f8ee0193ca
104461
c89254e41c98 lisp/cedet/semantic/ia.el: Add local vars for autoloading.
Chong Yidong <cyd@stupidchicken.com>
parents: 104447
diff changeset
449 ;;; semantic/ia.el ends here