annotate lisp/cedet/semantic/ia.el @ 104447:273e528a9f9b

* emacs-lisp/autoload.el (generated-autoload-load-name): New var. (autoload-generate-file-autoloads): Use it. (make-autoload): Handle define-overloadable-function. * emacs-lisp/lisp-mode.el (define-overloadable-function): Add doc-string-elt property for define-overloadable-function. lisp/cedet/semantic/analyze.el: Add generated-autoload-load-name var. lisp/cedet/semantic/ctxt.el: Add generated-autoload-load-name var. lisp/cedet/semantic/db.el: Add generated-autoload-load-name var. lisp/cedet/semantic/db-file.el: Add generated-autoload-load-name var. lisp/cedet/semantic/db-mode.el: Add generated-autoload-load-name var. lisp/cedet/semantic/db-typecache.el: Add generated-autoload-load-name var. lisp/cedet/semantic/doc.el: Add generated-autoload-load-name var. lisp/cedet/semantic/find.el: Add generated-autoload-load-name var. lisp/cedet/semantic/format.el: Add generated-autoload-load-name var. lisp/cedet/semantic/lex.el: Add generated-autoload-load-name var. lisp/cedet/semantic/sb.el: Require semantic/format. lisp/cedet/semantic/sort.el: Add generated-autoload-load-name var. lisp/cedet/semantic/tag.el: Add generated-autoload-load-name var. lisp/cedet/semantic/tag-file.el: Add generated-autoload-load-name var. lisp/cedet/semantic/tag-ls.el: Add generated-autoload-load-name var.
author Chong Yidong <cyd@stupidchicken.com>
date Sat, 05 Sep 2009 01:00:36 +0000
parents 2bf481006ba4
children c89254e41c98
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; ia.el --- Interactive Analysis functions
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,
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4 ;;; 2008, 2009 Free Software Foundation, Inc.
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
104424
3783a1145a65 cedet/semantic/ia.el: Don't require senator.
Chong Yidong <cyd@stupidchicken.com>
parents: 104420
diff changeset
38 ;; (require 'senator)
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 (require 'semantic/analyze)
104447
273e528a9f9b * emacs-lisp/autoload.el (generated-autoload-load-name): New var.
Chong Yidong <cyd@stupidchicken.com>
parents: 104444
diff changeset
40 (require 'semantic/format)
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 (require 'pulse)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 (eval-when-compile
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 (require 'semantic/analyze)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 (require 'semantic/analyze/refs))
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
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 'semantic-prototype-nonterminal
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 "*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
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
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 (defvar semantic-ia-cache nil
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 "Cache of the last completion request.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 Of the form ( POINT . COMPLETIONS ) where POINT is a location in the
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 buffer where the completion was requested. COMPLETONS is the list
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 of semantic tag names that provide logical completions from that
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66 location.")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 (make-variable-buffer-local 'semantic-ia-cache)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
68
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
69 ;;; COMPLETION HELPER
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 ;; 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
72 ;; 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
73 ;;
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
74 ;; 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
75 ;; 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
76 ;; 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
77 ;; 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
78
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
79 (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
80 "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
81
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
82 (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
83 "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
84 (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
85 (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
86 (cond ((eq tt 'function)
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
87 (insert "("))
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
88 (t nil))))
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
89
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
90 (declare-function semantic-analyze-possible-completions
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
91 "semantic/analyze/complete")
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
92
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 (defun semantic-ia-get-completions (context point)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 "Fetch the completion of CONTEXT at POINT.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95 Supports caching."
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 ;; Cache the current set of symbols so that we can get at
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97 ;; them quickly the second time someone presses the
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 ;; complete button.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 (let ((symbols
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 (if (and semantic-ia-cache
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 (= point (car semantic-ia-cache)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 (cdr semantic-ia-cache)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 (semantic-analyze-possible-completions context))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 ;; Set the cache
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 (setq semantic-ia-cache (cons point symbols))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 symbols))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 (defun semantic-ia-complete-symbol (point)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 "Complete the current symbol at POINT.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 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
111 (interactive "d")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 ;; Calculating completions is a two step process.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 ;; The first analyzer the current context, which finds tags
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 ;; for all the stuff that may be references by the code around
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116 ;; POINT.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118 ;; The second step derives completions from that context.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 (let* ((a (semantic-analyze-current-context point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 (syms (semantic-ia-get-completions a point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 (pre (car (reverse (oref a prefix))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 ;; If PRE was actually an already completed symbol, it doesn't
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 ;; come in as a string, but as a tag instead.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 (if (semantic-tag-p pre)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 ;; We will try completions on it anyway.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 (setq pre (semantic-tag-name pre)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 ;; Complete this symbol.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 (if (null syms)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130 (progn
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 ;(message "No smart completions found. Trying senator-complete-symbol.")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 (if (semantic-analyze-context-p a)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133 ;; 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
134 ;; 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
135 ;; completions.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 ;; This is a way of making this fcn more useful since the
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 ;; smart completion engine sometimes failes.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 (senator-complete-symbol)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 ))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 ;; Use try completion to seek a common substring.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142 (let ((tc (try-completion (or pre "") syms)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 (if (and (stringp tc) (not (string= tc (or pre ""))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 (let ((tok (semantic-find-first-tag-by-name
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145 tc syms)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 ;; Delete what came before...
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 (when (and (car (oref a bounds)) (cdr (oref a bounds)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 (delete-region (car (oref a bounds))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 (cdr (oref a bounds)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 (goto-char (car (oref a bounds))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 ;; We have some new text. Stick it in.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 (if tok
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 (semantic-ia-insert-tag tok)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 (insert tc)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 ;; We don't have new text. Show all completions.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 (when (cdr (oref a bounds))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 (goto-char (cdr (oref a bounds))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 (with-output-to-temp-buffer "*Completions*"
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 (display-completion-list
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 (mapcar semantic-ia-completion-format-tag-function syms))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 ))))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 (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
164 'semantic-uml-concise-prototype-nonterminal
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 "*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
166 :group 'semantic
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 :type semantic-format-tag-custom-list)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 (defun semantic-ia-complete-symbol-menu (point)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 "Complete the current symbol via a menu based at POINT.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 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
172 (interactive "d")
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
173 (require 'imenu)
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 (let* ((a (semantic-analyze-current-context point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 (syms (semantic-ia-get-completions a point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 ;; Complete this symbol.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 (if (not syms)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 (progn
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 (message "No smart completions found. Trying Senator.")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 (when (semantic-analyze-context-p a)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 ;; This is a quick way of getting a nice completion list
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 ;; in the menu if the regular context mechanism fails.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 (senator-completion-menu-popup)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 (let* ((menu
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187 (mapcar
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 (lambda (tag)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 (cons
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 (funcall semantic-ia-completion-menu-format-tag-function tag)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 (vector tag)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 syms))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 (ans
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 (imenu--mouse-menu
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 ;; XEmacs needs that the menu has at least 2 items. So,
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 ;; include a nil item that will be ignored by imenu.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 (cons nil menu)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 (senator-completion-menu-point-as-event)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 "Completions")))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 (when ans
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 (if (not (semantic-tag-p ans))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 (setq ans (aref (cdr ans) 0)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203 (delete-region (car (oref a bounds)) (cdr (oref a bounds)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 (semantic-ia-insert-tag ans))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 ))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 ;;; Completions Tip
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 ;; 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
210 ;; 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
211
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 (defun semantic-ia-complete-tip (point)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 "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
214 (interactive "d")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215 (let* ((a (semantic-analyze-current-context point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 (syms (semantic-ia-get-completions a point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 (x (mod (- (current-column) (window-hscroll))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 (window-width)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 (y (save-excursion
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 (save-restriction
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 (widen)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 (narrow-to-region (window-start) (point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 (goto-char (point-min))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 (1+ (vertical-motion (buffer-size))))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225 (str (mapconcat #'semantic-tag-name
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 syms
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 "\n"))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229 (cond ((fboundp 'x-show-tip)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 (x-show-tip str
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 (selected-frame)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 nil
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 nil
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 x y)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 (t (message str))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 )))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 ;;; Summary
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 ;; 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
242 ;; show a summary on.
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 (defun semantic-ia-show-summary (point)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 "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
246 (interactive "P")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 (let* ((ctxt (semantic-analyze-current-context point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 (pf (when ctxt
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 ;; 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
250 ;; 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
251 ;; tag associated with the current context.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 (semantic-analyze-interesting-tag ctxt)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 (when pf
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 (message "%s" (semantic-format-tag-summarize pf nil t)))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 ;;; FAST Jump
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 ;; 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
260 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 ;; 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
262 ;; 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
263
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264 (defun semantic-ia--fast-jump-helper (dest)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 "Jump to DEST, a Semantic tag.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 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
267 ;; 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
268 ;; 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
269 ;; implementaion instead.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 (when (semantic-tag-prototype-p dest)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 (let* ((refs (semantic-analyze-tag-references dest))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 (impl (semantic-analyze-refs-impl refs t))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 (when impl (setq dest (car impl)))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 ;; 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
277 (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
278 (semantic-tag-get-attribute dest :line))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 (semantic-tag-file-name dest)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 (error "Tag %s has no buffer information"
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 (semantic-format-tag-name dest)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 ;; 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
284 ;; are the key bits to the jump:
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 ;; 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
287 ;; 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
288 (push-mark)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 (when (fboundp 'push-tag-mark)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 (push-tag-mark))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 ;; 2) Visits the tag.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 (semantic-go-to-tag dest)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 ;; 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
294 ;; 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
295 (switch-to-buffer (current-buffer))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 ;; 4) Fancy pulsing.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 (pulse-momentary-highlight-one-line (point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299
104444
2bf481006ba4 lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents: 104424
diff changeset
300 (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
301
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 (defun semantic-ia-fast-jump (point)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 "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
304 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
305 origin of the code at point."
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 (interactive "d")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 (let* ((ctxt (semantic-analyze-current-context point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 (pf (and ctxt (reverse (oref ctxt prefix))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 ;; 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
310 ;; 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
311 ;; this.that().theothe
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 ;; would make a list:
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313 ;; ( ("this" variable ..) ("that" function ...) "theothe")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 ;; 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
315 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 ;; 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
317 ;; 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
318 ;; 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
319 (first (car pf))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 (second (nth 1 pf))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 )
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 ((semantic-tag-p first)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 ;; We have a match. Just go there.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 (semantic-ia--fast-jump-helper first))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 ((semantic-tag-p second)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 ;; 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
329 ;; 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
330 ;; 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
331 ;; 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
332 ;; 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
333 (let ((secondclass (car (reverse (oref ctxt prefixtypes)))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 (cond
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 ((and (semantic-tag-with-position-p secondclass)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 (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
337 first (semantic-tag-name secondclass))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 (semantic-ia--fast-jump-helper secondclass)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 ;; 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
341 ;; just visit SECOND.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 ((and (semantic-tag-p second)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 (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
344 first (semantic-tag-name second))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 (semantic-ia--fast-jump-helper second)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346 ))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 ((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
349 ;; 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
350 (require 'semantic/decorate/include)
104420
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 (semantic-decoration-include-visit)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 (t
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355 (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
356 first))
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
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 (defun semantic-ia-fast-mouse-jump (evt)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 "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
361 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
362 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
363 (interactive "e")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 (semantic-ia-fast-jump
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 (save-excursion
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 (posn-set-point (event-end evt))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 (point))))
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 ;;; DOC/DESCRIBE
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 ;; 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
372 ;; for purposes of describing or showing documentation about them.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373 (defun semantic-ia-show-doc (point)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 "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
375 (interactive "d")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 (let* ((ctxt (semantic-analyze-current-context point))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 (pf (reverse (oref ctxt prefix)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 ;; 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
380 ;; 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
381 ;; 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
382 (cond
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 ((stringp (car pf))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384 (message "Incomplete symbol name."))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 ((semantic-tag-p (car pf))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 ;; 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
387 ;; 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
388 ;; need to implement something for your language.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 ;; 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
391 ;; and then strings off comment prefixes.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 (let ((doc (semantic-documentation-for-tag (car pf))))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 (with-output-to-temp-buffer "*TAG DOCUMENTATION*"
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 (princ "Tag: ")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 (princ (semantic-format-tag-prototype (car pf)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 (princ "\n")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 (princ "\n")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 (princ "Snarfed Documentation: ")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 (princ "\n")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 (princ "\n")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 (if doc
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 (princ doc)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 (princ " Documentation unavailable."))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 )))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 (t
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 (message "Unknown tag.")))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407 ))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 (defun semantic-ia-describe-class (typename)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 "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
411 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
412 parts of the parent classes are displayed."
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413 ;; @todo - use a fancy completing reader.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 (interactive "sType Name: ")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 ;; 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
417 ;; 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
418 ;; 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
419 ;;
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 ;; 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
421 ;; 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
422 ;; 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
423 (let ((class (semantic-analyze-find-tag typename)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
425 (when (not (semantic-tag-p class))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 (error "Cannot find class %s" class))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 (with-output-to-temp-buffer "*TAG DOCUMENTATION*"
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428 ;; There are many semantic-format-tag-* fcns.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 ;; 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
430 (princ (semantic-format-tag-summarize class))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431 (princ "\n")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 (princ " Type Members:\n")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 ;; 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
434 ;; 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
435 ;; 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
436 ;; 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
437 ;; are inherited.
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 (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
439 (while parts
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 (princ " ")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441 (princ (semantic-format-tag-summarize (car parts)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 (princ "\n")
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 (setq parts (cdr parts)))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 )
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445 )))
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 (provide 'semantic/ia)
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448
2e15afd37998 cedet/semantic/adebug.el, cedet/semantic/chart.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449 ;;; semantic-ia.el ends here