Mercurial > emacs
annotate lisp/cedet/semantic/ctxt.el @ 104444:2bf481006ba4
lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
lisp/emacs-lisp/autoload.el (generated-autoload-feature): New var.
(autoload-rubric): Use it.
lisp/cedet/semantic/adebug.el (data-debug-insert-find-results-button): Require
db-find.
lisp/cedet/semantic/analyze.el: Require semantic/tag. Don't declare
autoloaded functions.
lisp/cedet/semantic/chart.el: Don't declare autoloaded functions.
lisp/cedet/semantic/complete.el: eval-when-compile semantic/find for macro.
(semantic-collector-calculate-completions-raw): Require semantic/db-find.
lisp/cedet/semantic/ctxt.el (semantic-up-context): Require semantic/find.
Don't require it at top-level.
lisp/cedet/semantic/db-ebrowse.el (semanticdb-ebrowse-dump): Require
data-debug. Don't require it at top-level. Don't require semantic/sort.
lisp/cedet/semantic/db-find.el: Add local vars for autoloading.
Don't require semantic/tag-file and semantic/sort.
(semanticdb-find-default-throttle, semanticdb-find-result-length)
(semanticdb-find-result-nth, semanticdb-find-result-nth-in-buffer)
(semanticdb-find-tags-by-name, semanticdb-find-tags-for-completion)
(semanticdb-find-translate-path, semanticdb-find-table-for-include): Autoload.
lisp/cedet/semantic/db-ref.el: Require semantic and semantic/tag.
(semanticdb-ref-test): Require data-debug. Don't require it at
top-level.
lisp/cedet/semantic/db-typecache.el: Require semantic and semantic/tag.
Declare semantic-sort-tags-by-name-then-type-increasing and
semantic-scope-tag-clone-with-scope.
eval-when-compile semantic/find for semantic-find-tags-by-* macros.
Add local vars for autoloading.
(semanticdb-typecache-find): Autoload.
lisp/cedet/semantic/db.el: Add local vars for autoloading.
(semanticdb-current-database, semanticdb-current-table)
(semanticdb-file-table-object): Autoload.
lisp/cedet/semantic/decorate.el: Don't requirements for autoloaded functions.
lisp/cedet/semantic/doc.el: Add local vars for autoloading.
(semantic-documentation-for-tag): Autoload.
lisp/cedet/semantic/edit.el: Drop requirements for autoloaded functions.
lisp/cedet/semantic/find.el: Add local vars for autoloading.
(semantic-current-tag, semantic-find-tag-by-overlay)
(semantic-find-first-tag-by-name): Autoload.
lisp/cedet/semantic/format.el: Add local vars for autoloading.
(semantic-format-tag-name, semantic-format-tag-custom-list)
(semantic-format-tag-functions): Autoload.
lisp/cedet/semantic/fw.el: Require semantic/loaddefs.
lisp/cedet/semantic/html.el (semantic-html-recursive-combobulate-list):
Use assoc-string instead of assoc-case.
lisp/cedet/semantic/ia.el (semantic-ia-insert-tag): Move up to avoid
compiler error.
(semantic-ia-complete-symbol-menu): Require imenu.
(semantic-ia-fast-jump): Require semantic/decorate/include.
lisp/cedet/semantic/idle.el: Require semantic and semantic/tag.
Declare semanticdb-typecache-refresh-for-buffer and eldoc-message.
eval-when-compile semantic/find for semantic-find-tags-by-name macro.
lisp/cedet/semantic/sort.el: Add local vars for autoloading.
(semantic-flatten-tags-table, semantic-tag-external-member-parent):
Autoload.
lisp/cedet/semantic/tag-file.el: Add local vars for autoloading.
(semantic-go-to-tag, semantic-dependency-tag-file): Autoload.
lisp/cedet/semantic/tag-ls.el: Add local vars for autoloading.
(semantic-tag-prototype-p): Autoload.
lisp/cedet/semantic/tag.el: Don't declare autoloaded functions.
lisp/cedet/semantic/analyze/complete.el: Add local variables for autoloading.
(semantic-analyze-possible-completions): Autoload.
lisp/cedet/semantic/analyze/fcn.el: Require mode-local.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Wed, 02 Sep 2009 04:37:10 +0000 |
parents | da5b2513c225 |
children | df08b7ab0ba0 |
rev | line source |
---|---|
104439
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104417
diff
changeset
|
1 ;;; semantic/ctxt.el --- Context calculations for Semantic tools. |
104417
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
2 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
3 ;;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
4 ;;; 2007, 2008, 2009 Free Software Foundation, Inc. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
5 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
6 ;; Author: Eric M. Ludlam <zappo@gnu.org> |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
7 ;; Keywords: syntax |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
8 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
10 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
12 ;; it under the terms of the GNU General Public License as published by |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
14 ;; (at your option) any later version. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
15 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
19 ;; GNU General Public License for more details. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
20 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
21 ;; You should have received a copy of the GNU General Public License |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
23 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
24 ;;; Commentary: |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
25 ;; |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
26 ;; Semantic, as a tool, provides a nice list of searchable tags. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
27 ;; That information can provide some very accurate answers if the current |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
28 ;; context of a position is known. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
29 ;; |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
30 ;; This library provides the hooks needed for a language to specify how |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
31 ;; the current context is calculated. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
32 ;; |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
33 (require 'semantic) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
34 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
35 ;;; Code: |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
36 (defvar semantic-command-separation-character |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
37 ";" |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
38 "String which indicates the end of a command. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
39 Used for identifying the end of a single command.") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
40 (make-variable-buffer-local 'semantic-command-separation-character) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
41 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
42 (defvar semantic-function-argument-separation-character |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
43 "," |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
44 "String which indicates the end of an argument. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
45 Used for identifying arguments to functions.") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
46 (make-variable-buffer-local 'semantic-function-argument-separation-character) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
47 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
48 ;;; Local Contexts |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
49 ;; |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
50 ;; These context are nested blocks of code, such as code in an |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
51 ;; if clause |
104444
2bf481006ba4
lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
104439
diff
changeset
|
52 (declare-function semantic-current-tag-of-class "semantic/find") |
2bf481006ba4
lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
104439
diff
changeset
|
53 |
104417
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
54 (define-overloadable-function semantic-up-context (&optional point bounds-type) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
55 "Move point up one context from POINT. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
56 Return non-nil if there are no more context levels. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
57 Overloaded functions using `up-context' take no parameters. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
58 BOUNDS-TYPE is a symbol representing a tag class to restrict |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
59 movement to. If this is nil, 'function is used. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
60 This will find the smallest tag of that class (function, variable, |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
61 type, etc) and make sure non-nil is returned if you cannot |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
62 go up past the bounds of that tag." |
104444
2bf481006ba4
lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
104439
diff
changeset
|
63 (require 'semantic/find) |
104417
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
64 (if point (goto-char point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
65 (let ((nar (semantic-current-tag-of-class (or bounds-type 'function)))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
66 (if nar |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
67 (semantic-with-buffer-narrowed-to-tag nar (:override-with-args ())) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
68 (when bounds-type |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
69 (error "No context of type %s to advance in" bounds-type)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
70 (:override-with-args ())))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
71 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
72 (defun semantic-up-context-default () |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
73 "Move the point up and out one context level. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
74 Works with languages that use parenthetical grouping." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
75 ;; By default, assume that the language uses some form of parenthetical |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
76 ;; do dads for their context. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
77 (condition-case nil |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
78 (progn |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
79 (up-list -1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
80 nil) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
81 (error t))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
82 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
83 (define-overloadable-function semantic-beginning-of-context (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
84 "Move POINT to the beginning of the current context. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
85 Return non-nil if there is no upper context. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
86 The default behavior uses `semantic-up-context'.") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
87 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
88 (defun semantic-beginning-of-context-default (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
89 "Move POINT to the beginning of the current context via parenthisis. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
90 Return non-nil if there is no upper context." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
91 (if point (goto-char point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
92 (if (semantic-up-context) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
93 t |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
94 (forward-char 1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
95 nil)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
96 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
97 (define-overloadable-function semantic-end-of-context (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
98 "Move POINT to the end of the current context. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
99 Return non-nil if there is no upper context. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
100 Be default, this uses `semantic-up-context', and assumes parenthetical |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
101 block delimiters.") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
102 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
103 (defun semantic-end-of-context-default (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
104 "Move POINT to the end of the current context via parenthisis. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
105 Return non-nil if there is no upper context." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
106 (if point (goto-char point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
107 (let ((start (point))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
108 (if (semantic-up-context) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
109 t |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
110 ;; Go over the list, and back over the end parenthisis. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
111 (condition-case nil |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
112 (progn |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
113 (forward-sexp 1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
114 (forward-char -1)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
115 (error |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
116 ;; If an error occurs, get the current tag from the cache, |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
117 ;; and just go to the end of that. Make sure we end up at least |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
118 ;; where start was so parse-region type calls work. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
119 (if (semantic-current-tag) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
120 (progn |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
121 (goto-char (semantic-tag-end (semantic-current-tag))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
122 (when (< (point) start) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
123 (goto-char start))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
124 (goto-char start)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
125 t))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
126 nil)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
127 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
128 (defun semantic-narrow-to-context () |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
129 "Narrow the buffer to the extent of the current context." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
130 (let (b e) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
131 (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
132 (if (semantic-beginning-of-context) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
133 nil |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
134 (setq b (point)))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
135 (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
136 (if (semantic-end-of-context) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
137 nil |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
138 (setq e (point)))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
139 (if (and b e) (narrow-to-region b e)))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
140 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
141 (defmacro semantic-with-buffer-narrowed-to-context (&rest body) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
142 "Execute BODY with the buffer narrowed to the current context." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
143 `(save-restriction |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
144 (semantic-narrow-to-context) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
145 ,@body)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
146 (put 'semantic-with-buffer-narrowed-to-context 'lisp-indent-function 0) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
147 (add-hook 'edebug-setup-hook |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
148 (lambda () |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
149 (def-edebug-spec semantic-with-buffer-narrowed-to-context |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
150 (def-body)))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
151 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
152 ;;; Local Variables |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
153 ;; |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
154 ;; |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
155 (define-overloadable-function semantic-get-local-variables (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
156 "Get the local variables based on POINT's context. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
157 Local variables are returned in Semantic tag format. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
158 This can be overriden with `get-local-variables'." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
159 ;; The working status is to let the parser work properly |
104439
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104417
diff
changeset
|
160 (let ((semantic--progress-reporter |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104417
diff
changeset
|
161 (make-progress-reporter (semantic-parser-working-message "Local") |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104417
diff
changeset
|
162 0 100))) |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104417
diff
changeset
|
163 (save-excursion |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104417
diff
changeset
|
164 (if point (goto-char point)) |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104417
diff
changeset
|
165 (let* ((semantic-working-type nil) |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104417
diff
changeset
|
166 ;; Disable parsing messages |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104417
diff
changeset
|
167 (case-fold-search semantic-case-fold)) |
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104417
diff
changeset
|
168 (:override-with-args ()))))) |
104417
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
169 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
170 (defun semantic-get-local-variables-default () |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
171 "Get local values from a specific context. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
172 Uses the bovinator with the special top-symbol `bovine-inner-scope' |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
173 to collect tags, such as local variables or prototypes." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
174 ;; This assumes a bovine parser. Make sure we don't do |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
175 ;; anything in that case. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
176 (when (and semantic--parse-table (not (eq semantic--parse-table t)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
177 (not (semantic-parse-tree-unparseable-p))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
178 (let ((vars (semantic-get-cache-data 'get-local-variables))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
179 (if vars |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
180 (progn |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
181 ;;(message "Found cached vars.") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
182 vars) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
183 (let ((vars2 nil) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
184 ;; We want nothing to do with funny syntaxing while doing this. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
185 (semantic-unmatched-syntax-hook nil) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
186 (start (point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
187 (firstusefulstart nil) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
188 ) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
189 (while (not (semantic-up-context (point) 'function)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
190 (when (not vars) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
191 (setq firstusefulstart (point))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
192 (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
193 (forward-char 1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
194 (setq vars |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
195 ;; Note to self: semantic-parse-region returns cooked |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
196 ;; but unlinked tags. File information is lost here |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
197 ;; and is added next. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
198 (append (semantic-parse-region |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
199 (point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
200 (save-excursion (semantic-end-of-context) (point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
201 'bovine-inner-scope |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
202 nil |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
203 t) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
204 vars)))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
205 ;; Modify the tags in place. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
206 (setq vars2 vars) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
207 (while vars2 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
208 (semantic--tag-put-property (car vars2) :filename (buffer-file-name)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
209 (setq vars2 (cdr vars2))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
210 ;; Hash our value into the first context that produced useful results. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
211 (when (and vars firstusefulstart) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
212 (let ((end (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
213 (goto-char firstusefulstart) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
214 (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
215 (unless (semantic-end-of-context) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
216 (point)))))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
217 ;;(message "Caching values %d->%d." firstusefulstart end) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
218 (semantic-cache-data-to-buffer |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
219 (current-buffer) firstusefulstart |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
220 (or end |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
221 ;; If the end-of-context fails, |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
222 ;; just use our cursor starting |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
223 ;; position. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
224 start) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
225 vars 'get-local-variables 'exit-cache-zone)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
226 ) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
227 ;; Return our list. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
228 vars))))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
229 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
230 (define-overloadable-function semantic-get-local-arguments (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
231 "Get arguments (variables) from the current context at POINT. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
232 Parameters are available if the point is in a function or method. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
233 Return a list of tags unlinked from the originating buffer. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
234 Arguments are obtained by overriding `get-local-arguments', or by the |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
235 default function `semantic-get-local-arguments-default'. This, must |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
236 return a list of tags, or a list of strings that will be converted to |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
237 tags." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
238 (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
239 (if point (goto-char point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
240 (let* ((case-fold-search semantic-case-fold) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
241 (args (:override-with-args ())) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
242 arg tags) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
243 ;; Convert unsafe arguments to the right thing. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
244 (while args |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
245 (setq arg (car args) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
246 args (cdr args) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
247 tags (cons (cond |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
248 ((semantic-tag-p arg) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
249 ;; Return a copy of tag without overlay. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
250 ;; The overlay is preserved. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
251 (semantic-tag-copy arg nil t)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
252 ((stringp arg) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
253 (semantic--tag-put-property |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
254 (semantic-tag-new-variable arg nil nil) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
255 :filename (buffer-file-name))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
256 (t |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
257 (error "Unknown parameter element %S" arg))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
258 tags))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
259 (nreverse tags)))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
260 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
261 (defun semantic-get-local-arguments-default () |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
262 "Get arguments (variables) from the current context. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
263 Parameters are available if the point is in a function or method." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
264 (let ((tag (semantic-current-tag))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
265 (if (and tag (semantic-tag-of-class-p tag 'function)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
266 (semantic-tag-function-arguments tag)))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
267 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
268 (define-overloadable-function semantic-get-all-local-variables (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
269 "Get all local variables for this context, and parent contexts. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
270 Local variables are returned in Semantic tag format. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
271 Be default, this gets local variables, and local arguments. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
272 Optional argument POINT is the location to start getting the variables from.") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
273 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
274 (defun semantic-get-all-local-variables-default (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
275 "Get all local variables for this context. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
276 Optional argument POINT is the location to start getting the variables from. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
277 That is a cons (LOCAL-ARGUMENTS . LOCAL-VARIABLES) where: |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
278 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
279 - LOCAL-ARGUMENTS is collected by `semantic-get-local-arguments'. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
280 - LOCAL-VARIABLES is collected by `semantic-get-local-variables'." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
281 (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
282 (if point (goto-char point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
283 (let ((case-fold-search semantic-case-fold)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
284 (append (semantic-get-local-arguments) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
285 (semantic-get-local-variables))))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
286 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
287 ;;; Local context parsing |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
288 ;; |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
289 ;; Context parsing assumes a series of language independent commonalities. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
290 ;; These terms are used to describe those contexts: |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
291 ;; |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
292 ;; command - One command in the language. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
293 ;; symbol - The symbol the cursor is on. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
294 ;; This would include a series of type/field when applicable. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
295 ;; assignment - The variable currently being assigned to |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
296 ;; function - The function call the cursor is on/in |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
297 ;; argument - The index to the argument the cursor is on. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
298 ;; |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
299 ;; |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
300 (define-overloadable-function semantic-end-of-command () |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
301 "Move to the end of the current command. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
302 Be default, uses `semantic-command-separation-character'.") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
303 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
304 (defun semantic-end-of-command-default () |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
305 "Move to the end of the current command. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
306 Depends on `semantic-command-separation-character' to find the |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
307 beginning and end of a command." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
308 (semantic-with-buffer-narrowed-to-context |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
309 (let ((case-fold-search semantic-case-fold)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
310 (with-syntax-table semantic-lex-syntax-table |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
311 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
312 (if (re-search-forward (regexp-quote semantic-command-separation-character) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
313 nil t) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
314 (forward-char -1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
315 ;; If there wasn't a command after this, we are the last |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
316 ;; command, and we are incomplete. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
317 (goto-char (point-max))))))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
318 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
319 (define-overloadable-function semantic-beginning-of-command () |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
320 "Move to the beginning of the current command. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
321 Be default, uses `semantic-command-separation-character'.") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
322 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
323 (defun semantic-beginning-of-command-default () |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
324 "Move to the beginning of the current command. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
325 Depends on `semantic-command-separation-character' to find the |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
326 beginning and end of a command." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
327 (semantic-with-buffer-narrowed-to-context |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
328 (with-syntax-table semantic-lex-syntax-table |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
329 (let ((case-fold-search semantic-case-fold)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
330 (skip-chars-backward semantic-command-separation-character) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
331 (if (re-search-backward (regexp-quote semantic-command-separation-character) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
332 nil t) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
333 (goto-char (match-end 0)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
334 ;; If there wasn't a command after this, we are the last |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
335 ;; command, and we are incomplete. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
336 (goto-char (point-min))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
337 (skip-chars-forward " \t\n") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
338 )))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
339 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
340 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
341 (defsubst semantic-point-at-beginning-of-command () |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
342 "Return the point at the beginning of the current command." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
343 (save-excursion (semantic-beginning-of-command) (point))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
344 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
345 (defsubst semantic-point-at-end-of-command () |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
346 "Return the point at the beginning of the current command." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
347 (save-excursion (semantic-end-of-command) (point))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
348 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
349 (defsubst semantic-narrow-to-command () |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
350 "Narrow the current buffer to the current command." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
351 (narrow-to-region (semantic-point-at-beginning-of-command) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
352 (semantic-point-at-end-of-command))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
353 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
354 (defmacro semantic-with-buffer-narrowed-to-command (&rest body) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
355 "Execute BODY with the buffer narrowed to the current command." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
356 `(save-restriction |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
357 (semantic-narrow-to-command) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
358 ,@body)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
359 (put 'semantic-with-buffer-narrowed-to-command 'lisp-indent-function 0) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
360 (add-hook 'edebug-setup-hook |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
361 (lambda () |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
362 (def-edebug-spec semantic-with-buffer-narrowed-to-command |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
363 (def-body)))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
364 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
365 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
366 (define-overloadable-function semantic-ctxt-current-symbol (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
367 "Return the current symbol the cursor is on at POINT in a list. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
368 The symbol includes all logical parts of a complex reference. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
369 For example, in C the statement: |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
370 this.that().entry |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
371 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
372 Would be object `this' calling method `that' which returns some structure |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
373 whose field `entry' is being reference. In this case, this function |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
374 would return the list: |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
375 ( \"this\" \"that\" \"entry\" )") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
376 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
377 (defun semantic-ctxt-current-symbol-default (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
378 "Return the current symbol the cursor is on at POINT in a list. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
379 This will include a list of type/field names when applicable. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
380 Depends on `semantic-type-relation-separator-character'." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
381 (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
382 (if point (goto-char point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
383 (let* ((fieldsep1 (mapconcat (lambda (a) (regexp-quote a)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
384 semantic-type-relation-separator-character |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
385 "\\|")) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
386 ;; NOTE: The [ \n] expression below should used \\s-, but that |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
387 ;; doesn't work in C since \n means end-of-comment, and isn't |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
388 ;; really whitespace. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
389 (fieldsep (concat "[ \t\n\r]*\\(" fieldsep1 "\\)[ \t\n\r]*\\(\\w\\|\\s_\\)")) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
390 (case-fold-search semantic-case-fold) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
391 (symlist nil) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
392 end) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
393 (with-syntax-table semantic-lex-syntax-table |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
394 (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
395 (cond ((looking-at "\\w\\|\\s_") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
396 ;; In the middle of a symbol, move to the end. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
397 (forward-sexp 1)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
398 ((looking-at fieldsep1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
399 ;; We are in a find spot.. do nothing. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
400 nil |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
401 ) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
402 ((save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
403 (and (condition-case nil |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
404 (progn (forward-sexp -1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
405 (forward-sexp 1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
406 t) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
407 (error nil)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
408 (looking-at fieldsep1))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
409 (setq symlist (list "")) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
410 (forward-sexp -1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
411 ;; Skip array expressions. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
412 (while (looking-at "\\s(") (forward-sexp -1)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
413 (forward-sexp 1)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
414 ) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
415 ;; Set our end point. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
416 (setq end (point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
417 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
418 ;; Now that we have gotten started, lets do the rest. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
419 (condition-case nil |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
420 (while (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
421 (forward-char -1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
422 (looking-at "\\w\\|\\s_")) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
423 ;; We have a symbol.. Do symbol things |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
424 (forward-sexp -1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
425 (setq symlist (cons (buffer-substring-no-properties (point) end) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
426 symlist)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
427 ;; Skip the next syntactic expression backwards, then go forwards. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
428 (let ((cp (point))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
429 (forward-sexp -1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
430 (forward-sexp 1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
431 ;; If we end up at the same place we started, we are at the |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
432 ;; beginning of a buffer, or narrowed to a command and |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
433 ;; have to stop. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
434 (if (<= cp (point)) (error nil))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
435 (if (looking-at fieldsep) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
436 (progn |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
437 (forward-sexp -1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
438 ;; Skip array expressions. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
439 (while (and (looking-at "\\s(") (not (bobp))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
440 (forward-sexp -1)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
441 (forward-sexp 1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
442 (setq end (point))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
443 (error nil)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
444 ) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
445 (error nil))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
446 symlist)))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
447 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
448 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
449 (define-overloadable-function semantic-ctxt-current-symbol-and-bounds (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
450 "Return the current symbol and bounds the cursor is on at POINT. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
451 The symbol should be the same as returned by `semantic-ctxt-current-symbol'. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
452 Return (PREFIX ENDSYM BOUNDS).") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
453 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
454 (defun semantic-ctxt-current-symbol-and-bounds-default (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
455 "Return the current symbol and bounds the cursor is on at POINT. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
456 Uses `semantic-ctxt-current-symbol' to calculate the symbol. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
457 Return (PREFIX ENDSYM BOUNDS)." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
458 (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
459 (when point (goto-char (point))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
460 (let* ((prefix (semantic-ctxt-current-symbol)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
461 (endsym (car (reverse prefix))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
462 ;; @todo - Can we get this data direct from ctxt-current-symbol? |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
463 (bounds (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
464 (cond ((string= endsym "") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
465 (cons (point) (point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
466 ) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
467 ((and prefix (looking-at endsym)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
468 (cons (point) (progn |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
469 (condition-case nil |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
470 (forward-sexp 1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
471 (error nil)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
472 (point)))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
473 (prefix |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
474 (condition-case nil |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
475 (cons (progn (forward-sexp -1) (point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
476 (progn (forward-sexp 1) (point))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
477 (error nil))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
478 (t nil)))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
479 ) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
480 (list prefix endsym bounds)))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
481 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
482 (define-overloadable-function semantic-ctxt-current-assignment (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
483 "Return the current assignment near the cursor at POINT. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
484 Return a list as per `semantic-ctxt-current-symbol'. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
485 Return nil if there is nothing relevant.") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
486 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
487 (defun semantic-ctxt-current-assignment-default (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
488 "Return the current assignment near the cursor at POINT. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
489 By default, assume that \"=\" indicates an assignment." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
490 (if point (goto-char point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
491 (let ((case-fold-search semantic-case-fold)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
492 (with-syntax-table semantic-lex-syntax-table |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
493 (condition-case nil |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
494 (semantic-with-buffer-narrowed-to-command |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
495 (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
496 (skip-chars-forward " \t=") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
497 (condition-case nil (forward-char 1) (error nil)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
498 (re-search-backward "[^=]=\\([^=]\\|$\\)") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
499 ;; We are at an equals sign. Go backwards a sexp, and |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
500 ;; we'll have the variable. Otherwise we threw an error |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
501 (forward-sexp -1) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
502 (semantic-ctxt-current-symbol))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
503 (error nil))))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
504 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
505 (define-overloadable-function semantic-ctxt-current-function (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
506 "Return the current function call the cursor is in at POINT. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
507 The function returned is the one accepting the arguments that |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
508 the cursor is currently in. It will not return function symbol if the |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
509 cursor is on the text representing that function.") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
510 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
511 (defun semantic-ctxt-current-function-default (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
512 "Return the current function call the cursor is in at POINT. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
513 The call will be identifed for C like langauges with the form |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
514 NAME ( args ... )" |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
515 (if point (goto-char point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
516 (let ((case-fold-search semantic-case-fold)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
517 (with-syntax-table semantic-lex-syntax-table |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
518 (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
519 (semantic-up-context) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
520 (when (looking-at "(") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
521 (semantic-ctxt-current-symbol)))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
522 )) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
523 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
524 (define-overloadable-function semantic-ctxt-current-argument (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
525 "Return the index of the argument position the cursor is on at POINT.") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
526 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
527 (defun semantic-ctxt-current-argument-default (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
528 "Return the index of the argument the cursor is on at POINT. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
529 Depends on `semantic-function-argument-separation-character'." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
530 (if point (goto-char point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
531 (let ((case-fold-search semantic-case-fold)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
532 (with-syntax-table semantic-lex-syntax-table |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
533 (when (semantic-ctxt-current-function) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
534 (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
535 ;; Only get the current arg index if we are in function args. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
536 (let ((p (point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
537 (idx 1)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
538 (semantic-up-context) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
539 (while (re-search-forward |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
540 (regexp-quote semantic-function-argument-separation-character) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
541 p t) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
542 (setq idx (1+ idx))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
543 idx)))))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
544 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
545 (defun semantic-ctxt-current-thing () |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
546 "Calculate a thing identified by the current cursor position. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
547 Calls previously defined `semantic-ctxt-current-...' calls until something |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
548 gets a match. See `semantic-ctxt-current-symbol', |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
549 `semantic-ctxt-current-function', and `semantic-ctxt-current-assignment' |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
550 for details on the return value." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
551 (or (semantic-ctxt-current-symbol) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
552 (semantic-ctxt-current-function) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
553 (semantic-ctxt-current-assignment))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
554 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
555 (define-overloadable-function semantic-ctxt-current-class-list (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
556 "Return a list of tag classes that are allowed at POINT. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
557 If POINT is nil, the current buffer location is used. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
558 For example, in Emacs Lisp, the symbol after a ( is most likely |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
559 a function. In a makefile, symbols after a : are rules, and symbols |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
560 after a $( are variables.") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
561 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
562 (defun semantic-ctxt-current-class-list-default (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
563 "Return a list of tag classes that are allowed at POINT. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
564 Assume a functional typed language. Uses very simple rules." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
565 (save-excursion |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
566 (if point (goto-char point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
567 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
568 (let ((tag (semantic-current-tag))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
569 (if tag |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
570 (cond ((semantic-tag-of-class-p tag 'function) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
571 '(function variable type)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
572 ((or (semantic-tag-of-class-p tag 'type) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
573 (semantic-tag-of-class-p tag 'variable)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
574 '(type)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
575 (t nil)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
576 '(type) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
577 )))) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
578 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
579 (define-overloadable-function semantic-ctxt-current-mode (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
580 "Return the major mode active at POINT. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
581 POINT defaults to the value of point in current buffer. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
582 You should override this function in multiple mode buffers to |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
583 determine which major mode apply at point.") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
584 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
585 (defun semantic-ctxt-current-mode-default (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
586 "Return the major mode active at POINT. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
587 POINT defaults to the value of point in current buffer. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
588 This default implementation returns the current major mode." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
589 major-mode) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
590 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
591 ;;; Scoped Types |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
592 ;; |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
593 ;; Scoped types are types that the current code would have access to. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
594 ;; The come from the global namespace or from special commands such as "using" |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
595 (define-overloadable-function semantic-ctxt-scoped-types (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
596 "Return a list of type names currently in scope at POINT. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
597 The return value can be a mixed list of either strings (names of |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
598 types that are in scope) or actual tags (type declared locally |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
599 that may or may not have a name.)") |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
600 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
601 (defun semantic-ctxt-scoped-types-default (&optional point) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
602 "Return a list of scoped types by name for the current context at POINT. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
603 This is very different for various languages, and does nothing unless |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
604 overriden." |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
605 (if point (goto-char point)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
606 (let ((case-fold-search semantic-case-fold)) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
607 ;; We need to look at TYPES within the bounds of locally parse arguments. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
608 ;; C needs to find using statements and the like too. Bleh. |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
609 nil |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
610 )) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
611 |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
612 (provide 'semantic/ctxt) |
6810f0d84270
cedet/semantic/ctxt.el, cedet/semantic/db-find.el,
Chong Yidong <cyd@stupidchicken.com>
parents:
diff
changeset
|
613 |
104439
da5b2513c225
cedet/cedet.el (cedet-packages): Bump srecode version.
Chong Yidong <cyd@stupidchicken.com>
parents:
104417
diff
changeset
|
614 ;;; semantic/ctxt.el ends here |