Mercurial > emacs
annotate lisp/cedet/semantic/util.el @ 104442:b22b44e953cb
cedet/semantic/chart.el: Don't require semantic/find.
cedet/semantic/complete.el: Don't require semantic/find.
cedet/semantic/decorate.el: Require semantic/tag-file.
(semantic-set-tag-folded-isearch): Require semantic/find.
cedet/semantic/dep.el: Change semantic--dependency-find-file-on-path
into a macro, to avoid compiler warning.
Defvar ede-minor-mode and ede-object.
Declare ede-system-include-path.
cedet/semantic/doc.el: Require semantic/tag-file and semantic/find.
cedet/semantic/edit.el: Require semantic/find and semantic/format.
cedet/semantic/find.el: Defvar semantic-case-fold.
Require semantic.
(semantic-find-tags-external-children-of-type): Require semantic/sort.
(semantic-find-tags-by-scope-protection-default): Require semantic/tag-ls.
cedet/semantic/format.el: Require semantic/tag-ls.
eval-when-compile semantic/find.
(semantic-format-tag-name): Move up to avoid compiler error.
(semantic-format-tag-prototype): Move up to avoid compiler error.
(semantic--format-tag-parent-tree): Require semantic/tag-file.
(semantic-format-tag-short-doc-default): Require semantic/doc.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Mon, 31 Aug 2009 02:16:34 +0000 |
parents | c13af98da4d6 |
children | df08b7ab0ba0 |
rev | line source |
---|---|
104416
c13af98da4d6
Fix renamed filenames in file headers.
Chong Yidong <cyd@stupidchicken.com>
parents:
104415
diff
changeset
|
1 ;;; util.el --- Utilities for use with semantic tag tables |
104415
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3 ;;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
4 ;;; 2008, 2009 Free Software Foundation, Inc. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
5 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
6 ;; Author: Eric M. Ludlam <zappo@gnu.org> |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
7 ;; Keywords: syntax |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
8 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
10 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
14 ;; (at your option) any later version. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
15 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
20 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
23 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
24 ;;; Commentary: |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
25 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
26 ;; Semantic utility API for use with semantic tag tables. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
27 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
28 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
29 (require 'assoc) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
30 (require 'semantic) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
31 (eval-when-compile |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
32 ;; Emacs 21 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
33 (condition-case nil |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
34 (require 'newcomment) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
35 (error nil)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
36 ;; Semanticdb calls |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
37 (require 'semantic/db) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
38 ) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
39 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
40 ;;; Code: |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
41 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
42 (defvar semantic-type-relation-separator-character '(".") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
43 "Character strings used to separate a parent/child relationship. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
44 This list of strings are used for displaying or finding separators |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
45 in variable field dereferencing. The first character will be used for |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
46 display. In C, a type field is separated like this: \"type.field\" |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
47 thus, the character is a \".\". In C, and additional value of \"->\" |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
48 would be in the list, so that \"type->field\" could be found.") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
49 (make-variable-buffer-local 'semantic-type-relation-separator-character) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
50 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
51 (defvar semantic-equivalent-major-modes nil |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
52 "List of major modes which are considered equivalent. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
53 Equivalent modes share a parser, and a set of override methods. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
54 A value of nil means that the current major mode is the only one.") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
55 (make-variable-buffer-local 'semantic-equivalent-major-modes) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
56 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
57 ;; These semanticdb calls will throw warnings in the byte compiler. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
58 ;; Doing the right thing to make them available at compile time |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
59 ;; really messes up the compilation sequence. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
60 (defun semantic-file-tag-table (file) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
61 "Return a tag table for FILE. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
62 If it is loaded, return the stream after making sure it's ok. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
63 If FILE is not loaded, check to see if `semanticdb' feature exists, |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
64 and use it to get tags from files not in memory. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
65 If FILE is not loaded, and semanticdb is not available, find the file |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
66 and parse it." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
67 (if (find-buffer-visiting file) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
68 (save-excursion |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
69 (set-buffer (find-buffer-visiting file)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
70 (semantic-fetch-tags)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
71 ;; File not loaded |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
72 (if (and (fboundp 'semanticdb-minor-mode-p) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
73 (semanticdb-minor-mode-p)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
74 ;; semanticdb is around, use it. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
75 (semanticdb-file-stream file) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
76 ;; Get the stream ourselves. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
77 (save-excursion |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
78 (set-buffer (find-file-noselect file)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
79 (semantic-fetch-tags))))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
80 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 (semantic-alias-obsolete 'semantic-file-token-stream |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
82 'semantic-file-tag-table) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
83 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
84 (defun semantic-something-to-tag-table (something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
85 "Convert SOMETHING into a semantic tag table. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
86 Something can be a tag with a valid BUFFER property, a tag table, a |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
87 buffer, or a filename. If SOMETHING is nil return nil." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
88 (cond |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
89 ;; A list of tags |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
90 ((and (listp something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
91 (semantic-tag-p (car something))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
92 something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
93 ;; A buffer |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
94 ((bufferp something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
95 (save-excursion |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
96 (set-buffer something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
97 (semantic-fetch-tags))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
98 ;; A Tag: Get that tag's buffer |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
99 ((and (semantic-tag-with-position-p something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
100 (semantic-tag-in-buffer-p something)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
101 (save-excursion |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
102 (set-buffer (semantic-tag-buffer something)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
103 (semantic-fetch-tags))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
104 ;; Tag with a file name in it |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
105 ((and (semantic-tag-p something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
106 (semantic-tag-file-name something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
107 (file-exists-p (semantic-tag-file-name something))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
108 (semantic-file-tag-table |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
109 (semantic-tag-file-name something))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
110 ;; A file name |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
111 ((and (stringp something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
112 (file-exists-p something)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
113 (semantic-file-tag-table something)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
114 ;; A Semanticdb table |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
115 ((and (featurep 'semanticdb) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
116 (semanticdb-minor-mode-p) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
117 (semanticdb-abstract-table-child-p something)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
118 (semanticdb-refresh-table something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
119 (semanticdb-get-tags something)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
120 ;; Semanticdb find-results |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
121 ((and (featurep 'semanticdb) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
122 (semanticdb-minor-mode-p) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
123 (semanticdb-find-results-p something)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
124 (semanticdb-strip-find-results something)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
125 ;; NOTE: This commented out since if a search result returns |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
126 ;; empty, that empty would turn into everything on the next search. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
127 ;; Use the current buffer for nil |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
128 ;; ((null something) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
129 ;; (semantic-fetch-tags)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
130 ;; don't know what it is |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
131 (t nil))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
132 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
133 (semantic-alias-obsolete 'semantic-something-to-stream |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
134 'semantic-something-to-tag-table) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
135 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
136 ;;; Recursive searching through dependency trees |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
137 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
138 ;; This will depend on the general searching APIS defined above. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
139 ;; but will add full recursion through the dependencies list per |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
140 ;; stream. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
141 (defun semantic-recursive-find-nonterminal-by-name (name buffer) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
142 "Recursively find the first occurrence of NAME. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
143 Start search with BUFFER. Recurse through all dependencies till found. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
144 The return item is of the form (BUFFER TOKEN) where BUFFER is the buffer |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
145 in which TOKEN (the token found to match NAME) was found. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
146 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
147 THIS ISN'T USED IN SEMANTIC. DELETE ME SOON." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
148 (save-excursion |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
149 (set-buffer buffer) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
150 (let* ((stream (semantic-fetch-tags)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
151 (includelist (or (semantic-find-tags-by-class 'include stream) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
152 "empty.silly.thing")) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
153 (found (semantic-find-first-tag-by-name name stream)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
154 (unfound nil)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
155 (while (and (not found) includelist) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
156 (let ((fn (semantic-dependency-tag-file (car includelist)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
157 (if (and fn (not (member fn unfound))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
158 (save-excursion |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
159 (set-buffer (find-file-noselect fn)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
160 (message "Scanning %s" (buffer-file-name)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
161 (setq stream (semantic-fetch-tags)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
162 (setq found (semantic-find-first-tag-by-name name stream)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
163 (if found |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
164 (setq found (cons (current-buffer) (list found))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
165 (setq includelist |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
166 (append includelist |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
167 (semantic-find-tags-by-class |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
168 'include stream)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
169 (setq unfound (cons fn unfound))))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
170 (setq includelist (cdr includelist))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
171 found))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
172 (make-obsolete 'semantic-recursive-find-nonterminal-by-name |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
173 "Do not use this function.") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
174 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
175 ;;; Completion APIs |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
176 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
177 ;; These functions provide minibuffer reading/completion for lists of |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
178 ;; nonterminals. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
179 (defvar semantic-read-symbol-history nil |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
180 "History for a symbol read.") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
181 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
182 (defun semantic-read-symbol (prompt &optional default stream filter) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
183 "Read a symbol name from the user for the current buffer. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
184 PROMPT is the prompt to use. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
185 Optional arguments: |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
186 DEFAULT is the default choice. If no default is given, one is read |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
187 from under point. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
188 STREAM is the list of tokens to complete from. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
189 FILTER is provides a filter on the types of things to complete. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
190 FILTER must be a function to call on each element." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
191 (if (not default) (setq default (thing-at-point 'symbol))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
192 (if (not stream) (setq stream (semantic-fetch-tags))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
193 (setq stream |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
194 (if filter |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
195 (semantic--find-tags-by-function filter stream) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
196 (semantic-brute-find-tag-standard stream))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
197 (if (and default (string-match ":" prompt)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
198 (setq prompt |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
199 (concat (substring prompt 0 (match-end 0)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
200 " (default: " default ") "))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
201 (completing-read prompt stream nil t "" |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
202 'semantic-read-symbol-history |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
203 default)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
204 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
205 (defun semantic-read-variable (prompt &optional default stream) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
206 "Read a variable name from the user for the current buffer. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
207 PROMPT is the prompt to use. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
208 Optional arguments: |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
209 DEFAULT is the default choice. If no default is given, one is read |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
210 from under point. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
211 STREAM is the list of tokens to complete from." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
212 (semantic-read-symbol |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
213 prompt default |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
214 (or (semantic-find-tags-by-class |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
215 'variable (or stream (current-buffer))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
216 (error "No local variables")))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
217 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
218 (defun semantic-read-function (prompt &optional default stream) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
219 "Read a function name from the user for the current buffer. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
220 PROMPT is the prompt to use. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
221 Optional arguments: |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
222 DEFAULT is the default choice. If no default is given, one is read |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
223 from under point. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
224 STREAM is the list of tags to complete from." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
225 (semantic-read-symbol |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
226 prompt default |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
227 (or (semantic-find-tags-by-class |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
228 'function (or stream (current-buffer))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
229 (error "No local functions")))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
230 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
231 (defun semantic-read-type (prompt &optional default stream) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
232 "Read a type name from the user for the current buffer. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
233 PROMPT is the prompt to use. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
234 Optional arguments: |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
235 DEFAULT is the default choice. If no default is given, one is read |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
236 from under point. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
237 STREAM is the list of tags to complete from." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
238 (semantic-read-symbol |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
239 prompt default |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
240 (or (semantic-find-tags-by-class |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
241 'type (or stream (current-buffer))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
242 (error "No local types")))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
243 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
244 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
245 ;;; Interactive Functions for |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
246 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
247 (defun semantic-describe-tag (&optional tag) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
248 "Describe TAG in the minibuffer. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
249 If TAG is nil, describe the tag under the cursor." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
250 (interactive) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
251 (if (not tag) (setq tag (semantic-current-tag))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
252 (semantic-fetch-tags) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
253 (if tag (message (semantic-format-tag-summarize tag)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
254 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
255 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
256 ;;; Putting keys on tags. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
257 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
258 (defun semantic-add-label (label value &optional tag) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
259 "Add a LABEL with VALUE on TAG. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
260 If TAG is not specified, use the tag at point." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
261 (interactive "sLabel: \nXValue (eval): ") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
262 (if (not tag) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
263 (progn |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
264 (semantic-fetch-tags) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
265 (setq tag (semantic-current-tag)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
266 (semantic--tag-put-property tag (intern label) value) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
267 (message "Added label %s with value %S" label value)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
268 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
269 (defun semantic-show-label (label &optional tag) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
270 "Show the value of LABEL on TAG. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
271 If TAG is not specified, use the tag at point." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
272 (interactive "sLabel: ") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
273 (if (not tag) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
274 (progn |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
275 (semantic-fetch-tags) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
276 (setq tag (semantic-current-tag)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
277 (message "%s: %S" label (semantic--tag-get-property tag (intern label)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
278 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
279 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
280 ;;; Hacks |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
281 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
282 ;; Some hacks to help me test these functions |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
283 (defun semantic-describe-buffer-var-helper (varsym buffer) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
284 "Display to standard out the value of VARSYM in BUFFER." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
285 (require 'data-debug) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
286 (let ((value (save-excursion |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
287 (set-buffer buffer) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
288 (symbol-value varsym)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
289 (cond |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
290 ((and (consp value) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
291 (< (length value) 10)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
292 ;; Draw the list of things in the list. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
293 (princ (format " %s: #<list of %d items>\n" |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
294 varsym (length value))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
295 (data-debug-insert-stuff-list |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
296 value " " ) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
297 ) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
298 (t |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
299 ;; Else do a one-liner. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
300 (data-debug-insert-thing |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
301 value " " (concat " " (symbol-name varsym) ": ")) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
302 )))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
303 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
304 (defun semantic-describe-buffer () |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
305 "Describe the semantic environment for the current buffer." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
306 (interactive) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
307 (let ((buff (current-buffer)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
308 ) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
309 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
310 (with-output-to-temp-buffer (help-buffer) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
311 (help-setup-xref (list #'semantic-describe-buffer) (interactive-p)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
312 (with-current-buffer standard-output |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
313 (princ "Semantic Configuration in ") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
314 (princ (buffer-name buff)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
315 (princ "\n\n") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
316 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
317 (princ "Buffer specific configuration items:\n") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
318 (let ((vars '(major-mode |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
319 semantic-case-fold |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
320 semantic-expand-nonterminal |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
321 semantic-parser-name |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
322 semantic-parse-tree-state |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
323 semantic-lex-analyzer |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
324 semantic-lex-reset-hooks |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
325 ))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
326 (dolist (V vars) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
327 (semantic-describe-buffer-var-helper V buff))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
328 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
329 (princ "\nGeneral configuration items:\n") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
330 (let ((vars '(semantic-inhibit-functions |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
331 semantic-init-hooks |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
332 semantic-init-db-hooks |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
333 semantic-unmatched-syntax-hook |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
334 semantic--before-fetch-tags-hook |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
335 semantic-after-toplevel-bovinate-hook |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
336 semantic-after-toplevel-cache-change-hook |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
337 semantic-before-toplevel-cache-flush-hook |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
338 semantic-dump-parse |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
339 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
340 ))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
341 (dolist (V vars) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
342 (semantic-describe-buffer-var-helper V buff))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
343 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
344 (princ "\n\n") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
345 (mode-local-describe-bindings-2 buff) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
346 ))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
347 ) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
348 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
349 (defun semantic-current-tag-interactive (p) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
350 "Display the current token. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
351 Argument P is the point to search from in the current buffer." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
352 (interactive "d") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
353 (let ((tok (semantic-brute-find-innermost-tag-by-position |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
354 p (current-buffer)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
355 (message (mapconcat 'semantic-abbreviate-nonterminal tok ",")) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
356 (car tok)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
357 ) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
358 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
359 (defun semantic-hack-search () |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
360 "Display info about something under the cursor using generic methods." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
361 (interactive) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
362 (let ( |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
363 ;(name (thing-at-point 'symbol)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
364 (strm (cdr (semantic-fetch-tags))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
365 (res nil)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
366 ; (if name |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
367 (setq res |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
368 ; (semantic-find-nonterminal-by-name name strm) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
369 ; (semantic-find-nonterminal-by-type name strm) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
370 ; (semantic-recursive-find-nonterminal-by-name name (current-buffer)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
371 (semantic-brute-find-tag-by-position (point) strm) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
372 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
373 ) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
374 ; ) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
375 (if res |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
376 (progn |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
377 (pop-to-buffer "*SEMANTIC HACK RESULTS*") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
378 (require 'pp) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
379 (erase-buffer) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
380 (insert (pp-to-string res) "\n") |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
381 (goto-char (point-min)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
382 (shrink-window-if-larger-than-buffer)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
383 (message "nil")))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
384 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
385 (defun semantic-assert-valid-token (tok) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
386 "Assert that TOK is a valid token." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
387 (if (semantic-tag-p tok) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
388 (if (semantic-tag-with-position-p tok) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
389 (let ((o (semantic-tag-overlay tok))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
390 (if (and (semantic-overlay-p o) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
391 (not (semantic-overlay-live-p o))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
392 (let ((debug-on-error t)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
393 (error "Tag %s is invalid!" (semantic-tag-name tok))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
394 ;; else, tag is OK. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
395 )) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
396 ;; Positionless tags are also ok. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
397 ) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
398 (let ((debug-on-error t)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
399 (error "Not a semantic tag: %S" tok)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
400 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
401 (defun semantic-sanity-check (&optional cache over notfirst) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
402 "Perform a sanity check on the current buffer. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
403 The buffer's set of overlays, and those overlays found via the cache |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
404 are verified against each other. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
405 CACHE, and OVER are the semantic cache, and the overlay list. |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
406 NOTFIRST indicates that this was not the first call in the recursive use." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
407 (interactive) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
408 (if (and (not cache) (not over) (not notfirst)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
409 (setq cache semantic--buffer-cache |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
410 over (semantic-overlays-in (point-min) (point-max)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
411 (while cache |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
412 (let ((chil (semantic-tag-components-with-overlays (car cache)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
413 (if (not (memq (semantic-tag-overlay (car cache)) over)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
414 (message "Tag %s not in buffer overlay list." |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
415 (semantic-format-tag-concise-prototype (car cache)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
416 (setq over (delq (semantic-tag-overlay (car cache)) over)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
417 (setq over (semantic-sanity-check chil over t)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
418 (setq cache (cdr cache)))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
419 (if (not notfirst) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
420 ;; Strip out all overlays which aren't semantic overlays |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
421 (let ((o nil)) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
422 (while over |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
423 (when (and (semantic-overlay-get (car over) 'semantic) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
424 (not (eq (semantic-overlay-get (car over) 'semantic) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
425 'unmatched))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
426 (setq o (cons (car over) o))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
427 (setq over (cdr over))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
428 (message "Remaining overlays: %S" o))) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
429 over) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
430 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
431 (provide 'semantic/util) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
432 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
433 ;;; Minor modes |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
434 ;; |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
435 (require 'semantic/util-modes) |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
436 |
4472b64928ad
cedet/semantic/util.el: New file.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
437 ;;; semantic-util.el ends here |