annotate lisp/cedet/semantic/symref.el @ 104439:da5b2513c225

cedet/cedet.el (cedet-packages): Bump srecode version. cedet/data-debug.el: Require `ring' for use of ring-length. cedet/semantic.el (semantic-repeat-parse-whole-stream): Check semantic-working-type before updating progress reporter. cedet/semantic/adebug.el: Fix file header. cedet/semantic/analyze.el: eval-when-compile semantic/find, for semantic-find-tags-by-name. Declare semanticdb-strip-find-results and semanticdb-find-tags-by-name. cedet/semantic/chart.el: Require semantic/find, semantic/db-mode, semantic/db-typecache, and semantic/scope. cedet/semantic/complete.el: Declare semantic-displayor-focus-abstract-child-p function (needed as the semantic-displayor-focus-abstract class is defined only after used). Move semantic-complete-inline-custom-type and semantic-complete-inline-analyzer-displayor-class variable definitions up, before they are used, to avoid compiler warning. Require semantic/decorate, semantic/tag-file, eieio-opt, and semantic/analyze/complete. cedet/semantic/ctxt.el: Require semantic/find. Don't eval-when-compile semantic/db (semantic-get-local-variables): Use Emacs' built-in progress reporter instead of working-status-forms. cedet/semantic/db-debug.el: Require data-debug, semantic/db-mode, and semantic/format. cedet/semantic/db-ebrowse.el: Require semantic/db-mode, semantic/find, semantic/sort, data-debug (semanticdb-create-database): Require semantic/dep for semantic-add-system-include. (semanticdb-table-ebrowse, semanticdb-project-database-ebrowse): Move class definitions near top of file, before they are used, to avoid compiler warnings. (semanticdb-ebrowse-add-tree-to-table): Use split-string.
author Chong Yidong <cyd@stupidchicken.com>
date Sun, 30 Aug 2009 21:16:39 +0000
parents 24150c0540ae
children df08b7ab0ba0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
104422
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
1 ;;; semantic/symref.el --- Symbol Reference API
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
2
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
3 ;;; Copyright (C) 2008, 2009 Free Software Foundation, Inc.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
4
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
6
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
7 ;; This file is part of GNU Emacs.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
8
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
10 ;; it under the terms of the GNU General Public License as published by
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
11 ;; the Free Software Foundation, either version 3 of the License, or
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
12 ;; (at your option) any later version.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
13
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
14 ;; GNU Emacs is distributed in the hope that it will be useful,
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
17 ;; GNU General Public License for more details.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
18
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
19 ;; You should have received a copy of the GNU General Public License
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
21
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
22 ;;; Commentary:
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
23 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
24 ;; Semantic Symbol Reference API.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
25 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
26 ;; Semantic's native parsing tools do not handle symbol references.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
27 ;; Tracking such information is a task that requires a huge amount of
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
28 ;; space and processing not apropriate for an Emacs Lisp program.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
29 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
30 ;; Many desired tools used in refactoring, however, need to have
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
31 ;; such references available to them. This API aims to provide a
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
32 ;; range of functions that can be used to identify references. The
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
33 ;; API is backed by an OO system that is used to allow multiple
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
34 ;; external tools to provide the information.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
35 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
36 ;; The default implementation uses a find/grep combination to do a
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
37 ;; search. This works ok in small projects. For larger projects, it
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
38 ;; is important to find an alternate tool to use as a back-end to
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
39 ;; symref.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
40 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
41 ;; See the command: `semantic-symref' for an example app using this api.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
42 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
43 ;; TO USE THIS TOOL
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
44 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
45 ;; The following functions can be used to find different kinds of
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
46 ;; references.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
47 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
48 ;; `semantic-symref-find-references-by-name'
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
49 ;; `semantic-symref-find-file-references-by-name'
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
50 ;; `semantic-symref-find-text'
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
51 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
52 ;; All the search routines return a class of type
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
53 ;; `semantic-symref-result'. You can reference the various slots, but
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
54 ;; you will need the following methods to get extended information.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
55 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
56 ;; `semantic-symref-result-get-files'
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
57 ;; `semantic-symref-result-get-tags'
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
58 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
59 ;; ADD A NEW EXTERNAL TOOL
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
60 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
61 ;; To support a new external tool, sublcass `semantic-symref-tool-baseclass'
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
62 ;; and implement the methods. The baseclass provides support for
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
63 ;; managing external processes that produce parsable output.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
64 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
65 ;; Your tool should then create an instance of `semantic-symref-result'.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
66
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
67 (require 'semantic/fw)
104423
24150c0540ae cedet/semantic/symref.el: Don't require ede at top-level.
Chong Yidong <cyd@stupidchicken.com>
parents: 104422
diff changeset
68 ;; (require 'ede)
104422
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
69 (eval-when-compile (require 'data-debug)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
70 (require 'eieio-datadebug))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
71
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
72 ;;; Code:
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
73 (defvar semantic-symref-tool 'detect
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
74 "*The active symbol reference tool name.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
75 The tool symbol can be 'detect, or a symbol that is the name of
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
76 a tool that can be used for symbol referencing.")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
77 (make-variable-buffer-local 'semantic-symref-tool)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
78
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
79 ;;; TOOL SETUP
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
80 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
81 (defvar semantic-symref-tool-alist
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
82 '( ( (lambda (rootdir) (file-exists-p (expand-file-name "GPATH" rootdir))) .
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
83 global)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
84 ( (lambda (rootdir) (file-exists-p (expand-file-name "ID" rootdir))) .
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
85 idutils)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
86 ( (lambda (rootdir) (file-exists-p (expand-file-name "cscope.out" rootdir))) .
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
87 cscope )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
88 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
89 "Alist of tools usable by `semantic-symref'.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
90 Each entry is of the form:
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
91 ( PREDICATE . KEY )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
92 Where PREDICATE is a function that takes a directory name for the
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
93 root of a project, and returns non-nil if the tool represented by KEY
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
94 is supported.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
95
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
96 If no tools are supported, then 'grep is assumed.")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
97
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
98 (defun semantic-symref-detect-symref-tool ()
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
99 "Detect the symref tool to use for the current buffer."
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
100 (if (not (eq semantic-symref-tool 'detect))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
101 semantic-symref-tool
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
102 ;; We are to perform a detection for the right tool to use.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
103 (let* ((rootproj (when (and (featurep 'ede) ede-minor-mode)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
104 (ede-toplevel)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
105 (rootdir (if rootproj
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
106 (ede-project-root-directory rootproj)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
107 default-directory))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
108 (tools semantic-symref-tool-alist))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
109 (while (and tools (eq semantic-symref-tool 'detect))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
110 (when (funcall (car (car tools)) rootdir)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
111 (setq semantic-symref-tool (cdr (car tools))))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
112 (setq tools (cdr tools)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
113
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
114 (when (eq semantic-symref-tool 'detect)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
115 (setq semantic-symref-tool 'grep))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
116
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
117 semantic-symref-tool)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
118
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
119 (defun semantic-symref-instantiate (&rest args)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
120 "Instantiate a new symref search object.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
121 ARGS are the initialization arguments to pass to the created class."
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
122 (let* ((srt (symbol-name (semantic-symref-detect-symref-tool)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
123 (class (intern-soft (concat "semantic-symref-tool-" srt)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
124 (inst nil)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
125 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
126 (when (not (class-p class))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
127 (error "Unknown symref tool %s" semantic-symref-tool))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
128 (setq inst (apply 'make-instance class args))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
129 inst))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
130
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
131 (defvar semantic-symref-last-result nil
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
132 "The last calculated symref result.")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
133
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
134 (defun semantic-symref-data-debug-last-result ()
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
135 "Run the last symref data result in Data Debug."
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
136 (interactive)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
137 (if semantic-symref-last-result
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
138 (progn
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
139 (data-debug-new-buffer "*Symbol Reference ADEBUG*")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
140 (data-debug-insert-object-slots semantic-symref-last-result "]"))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
141 (message "Empty results.")))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
142
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
143 ;;; EXTERNAL API
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
144 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
145
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
146 (defun semantic-symref-find-references-by-name (name &optional scope tool-return)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
147 "Find a list of references to NAME in the current project.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
148 Optional SCOPE specifies which file set to search. Defaults to 'project.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
149 Refers to `semantic-symref-tool', to determine the reference tool to use
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
150 for the current buffer.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
151 Returns an object of class `semantic-symref-result'.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
152 TOOL-RETURN is an optional symbol, which will be assigned the tool used
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
153 to perform the search. This was added for use by a test harness."
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
154 (interactive "sName: ")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
155 (let* ((inst (semantic-symref-instantiate
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
156 :searchfor name
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
157 :searchtype 'symbol
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
158 :searchscope (or scope 'project)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
159 :resulttype 'line))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
160 (result (semantic-symref-get-result inst)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
161 (when tool-return
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
162 (set tool-return inst))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
163 (prog1
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
164 (setq semantic-symref-last-result result)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
165 (when (interactive-p)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
166 (semantic-symref-data-debug-last-result))))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
167 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
168
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
169 (defun semantic-symref-find-tags-by-name (name &optional scope)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
170 "Find a list of references to NAME in the current project.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
171 Optional SCOPE specifies which file set to search. Defaults to 'project.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
172 Refers to `semantic-symref-tool', to determine the reference tool to use
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
173 for the current buffer.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
174 Returns an object of class `semantic-symref-result'."
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
175 (interactive "sName: ")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
176 (let* ((inst (semantic-symref-instantiate
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
177 :searchfor name
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
178 :searchtype 'tagname
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
179 :searchscope (or scope 'project)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
180 :resulttype 'line))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
181 (result (semantic-symref-get-result inst)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
182 (prog1
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
183 (setq semantic-symref-last-result result)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
184 (when (interactive-p)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
185 (semantic-symref-data-debug-last-result))))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
186 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
187
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
188 (defun semantic-symref-find-tags-by-regexp (name &optional scope)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
189 "Find a list of references to NAME in the current project.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
190 Optional SCOPE specifies which file set to search. Defaults to 'project.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
191 Refers to `semantic-symref-tool', to determine the reference tool to use
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
192 for the current buffer.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
193 Returns an object of class `semantic-symref-result'."
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
194 (interactive "sName: ")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
195 (let* ((inst (semantic-symref-instantiate
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
196 :searchfor name
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
197 :searchtype 'tagregexp
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
198 :searchscope (or scope 'project)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
199 :resulttype 'line))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
200 (result (semantic-symref-get-result inst)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
201 (prog1
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
202 (setq semantic-symref-last-result result)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
203 (when (interactive-p)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
204 (semantic-symref-data-debug-last-result))))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
205 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
206
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
207 (defun semantic-symref-find-tags-by-completion (name &optional scope)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
208 "Find a list of references to NAME in the current project.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
209 Optional SCOPE specifies which file set to search. Defaults to 'project.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
210 Refers to `semantic-symref-tool', to determine the reference tool to use
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
211 for the current buffer.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
212 Returns an object of class `semantic-symref-result'."
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
213 (interactive "sName: ")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
214 (let* ((inst (semantic-symref-instantiate
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
215 :searchfor name
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
216 :searchtype 'tagcompletions
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
217 :searchscope (or scope 'project)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
218 :resulttype 'line))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
219 (result (semantic-symref-get-result inst)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
220 (prog1
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
221 (setq semantic-symref-last-result result)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
222 (when (interactive-p)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
223 (semantic-symref-data-debug-last-result))))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
224 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
225
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
226 (defun semantic-symref-find-file-references-by-name (name &optional scope)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
227 "Find a list of references to NAME in the current project.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
228 Optional SCOPE specifies which file set to search. Defaults to 'project.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
229 Refers to `semantic-symref-tool', to determine the reference tool to use
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
230 for the current buffer.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
231 Returns an object of class `semantic-symref-result'."
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
232 (interactive "sName: ")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
233 (let* ((inst (semantic-symref-instantiate
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
234 :searchfor name
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
235 :searchtype 'regexp
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
236 :searchscope (or scope 'project)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
237 :resulttype 'file))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
238 (result (semantic-symref-get-result inst)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
239 (prog1
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
240 (setq semantic-symref-last-result result)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
241 (when (interactive-p)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
242 (semantic-symref-data-debug-last-result))))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
243 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
244
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
245 (defun semantic-symref-find-text (text &optional scope)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
246 "Find a list of occurances of TEXT in the current project.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
247 TEXT is a regexp formatted for use with egrep.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
248 Optional SCOPE specifies which file set to search. Defaults to 'project.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
249 Refers to `semantic-symref-tool', to determine the reference tool to use
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
250 for the current buffer.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
251 Returns an object of class `semantic-symref-result'."
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
252 (interactive "sEgrep style Regexp: ")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
253 (let* ((inst (semantic-symref-instantiate
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
254 :searchfor text
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
255 :searchtype 'regexp
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
256 :searchscope (or scope 'project)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
257 :resulttype 'line))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
258 (result (semantic-symref-get-result inst)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
259 (prog1
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
260 (setq semantic-symref-last-result result)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
261 (when (interactive-p)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
262 (semantic-symref-data-debug-last-result))))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
263 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
264
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
265 ;;; RESULTS
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
266 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
267 ;; The results class and methods provide features for accessing hits.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
268 (defclass semantic-symref-result ()
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
269 ((created-by :initarg :created-by
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
270 :type semantic-symref-tool-baseclass
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
271 :documentation
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
272 "Back-pointer to the symref tool creating these results.")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
273 (hit-files :initarg :hit-files
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
274 :type list
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
275 :documentation
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
276 "The list of files hit.")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
277 (hit-text :initarg :hit-text
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
278 :type list
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
279 :documentation
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
280 "If the result doesn't provide full lines, then fill in hit-text.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
281 GNU Global does completion search this way.")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
282 (hit-lines :initarg :hit-lines
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
283 :type list
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
284 :documentation
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
285 "The list of line hits.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
286 Each element is a cons cell of the form (LINE . FILENAME).")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
287 (hit-tags :initarg :hit-tags
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
288 :type list
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
289 :documentation
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
290 "The list of tags with hits in them.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
291 Use the `semantic-symref-hit-tags' method to get this list.")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
292 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
293 "The results from a symbol reference search.")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
294
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
295 (defmethod semantic-symref-result-get-files ((result semantic-symref-result))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
296 "Get the list of files from the symref result RESULT."
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
297 (if (slot-boundp result :hit-files)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
298 (oref result hit-files)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
299 (let* ((lines (oref result :hit-lines))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
300 (files (mapcar (lambda (a) (cdr a)) lines))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
301 (ans nil))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
302 (setq ans (list (car files))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
303 files (cdr files))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
304 (dolist (F files)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
305 ;; This algorithm for uniqing the file list depends on the
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
306 ;; tool in question providing all the hits in the same file
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
307 ;; grouped together.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
308 (when (not (string= F (car ans)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
309 (setq ans (cons F ans))))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
310 (oset result hit-files (nreverse ans))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
311 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
312 ))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
313
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
314 (defmethod semantic-symref-result-get-tags ((result semantic-symref-result)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
315 &optional open-buffers)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
316 "Get the list of tags from the symref result RESULT.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
317 Optional OPEN-BUFFERS indicates that the buffers that the hits are
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
318 in should remain open after scanning.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
319 Note: This can be quite slow if most of the hits are not in buffers
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
320 already."
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
321 (if (and (slot-boundp result :hit-tags) (oref result hit-tags))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
322 (oref result hit-tags)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
323 ;; Calculate the tags.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
324 (let ((lines (oref result :hit-lines))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
325 (txt (oref (oref result :created-by) :searchfor))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
326 (searchtype (oref (oref result :created-by) :searchtype))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
327 (ans nil)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
328 (out nil)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
329 (buffs-to-kill nil))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
330 (save-excursion
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
331 (setq
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
332 ans
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
333 (mapcar
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
334 (lambda (hit)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
335 (let* ((line (car hit))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
336 (file (cdr hit))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
337 (buff (get-file-buffer file))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
338 (tag nil)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
339 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
340 (cond
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
341 ;; We have a buffer already. Check it out.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
342 (buff
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
343 (set-buffer buff))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
344
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
345 ;; We have a table, but it needs a refresh.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
346 ;; This means we should load in that buffer.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
347 (t
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
348 (let ((kbuff
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
349 (if open-buffers
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
350 ;; Even if we keep the buffers open, don't
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
351 ;; let EDE ask lots of questions.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
352 (let ((ede-auto-add-method 'never))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
353 (find-file-noselect file t))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
354 ;; When not keeping the buffers open, then
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
355 ;; don't setup all the fancy froo-froo features
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
356 ;; either.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
357 (semantic-find-file-noselect file t))))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
358 (set-buffer kbuff)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
359 (setq buffs-to-kill (cons kbuff buffs-to-kill))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
360 (semantic-fetch-tags)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
361 ))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
362 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
363
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
364 ;; Too much baggage in goto-line
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
365 ;; (goto-line line)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
366 (goto-char (point-min))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
367 (forward-line (1- line))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
368
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
369 ;; Search forward for the matching text
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
370 (re-search-forward (regexp-quote txt)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
371 (point-at-eol)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
372 t)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
373
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
374 (setq tag (semantic-current-tag))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
375
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
376 ;; If we are searching for a tag, but bound the tag we are looking
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
377 ;; for, see if it resides in some other parent tag.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
378 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
379 ;; If there is no parent tag, then we still need to hang the originator
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
380 ;; in our list.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
381 (when (and (eq searchtype 'symbol)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
382 (string= (semantic-tag-name tag) txt))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
383 (setq tag (or (semantic-current-tag-parent) tag)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
384
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
385 ;; Copy the tag, which adds a :filename property.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
386 (when tag
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
387 (setq tag (semantic-tag-copy tag nil t))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
388 ;; Ad this hit to the tag.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
389 (semantic--tag-put-property tag :hit (list line)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
390 tag))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
391 lines)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
392 ;; Kill off dead buffers, unless we were requested to leave them open.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
393 (when (not open-buffers)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
394 (mapc 'kill-buffer buffs-to-kill))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
395 ;; Strip out duplicates.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
396 (dolist (T ans)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
397 (if (and T (not (semantic-equivalent-tag-p (car out) T)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
398 (setq out (cons T out))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
399 (when T
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
400 ;; Else, add this line into the existing list of lines.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
401 (let ((lines (append (semantic--tag-get-property (car out) :hit)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
402 (semantic--tag-get-property T :hit))))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
403 (semantic--tag-put-property (car out) :hit lines)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
404 ))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
405 ;; Out is reversed... twice
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
406 (oset result :hit-tags (nreverse out)))))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
407
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
408 ;;; SYMREF TOOLS
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
409 ;;
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
410 ;; The base symref tool provides something to hang new tools off of
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
411 ;; for finding symbol references.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
412 (defclass semantic-symref-tool-baseclass ()
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
413 ((searchfor :initarg :searchfor
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
414 :type string
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
415 :documentation "The thing to search for.")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
416 (searchtype :initarg :searchtype
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
417 :type symbol
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
418 :documentation "The type of search to do.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
419 Values could be `symbol, `regexp, 'tagname, or 'completion.")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
420 (searchscope :initarg :searchscope
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
421 :type symbol
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
422 :documentation
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
423 "The scope to search for.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
424 Can be 'project, 'target, or 'file.")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
425 (resulttype :initarg :resulttype
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
426 :type symbol
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
427 :documentation
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
428 "The kind of search results desired.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
429 Can be 'line, 'file, or 'tag.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
430 The type of result can be converted from 'line to 'file, or 'line to 'tag,
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
431 but not from 'file to 'line or 'tag.")
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
432 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
433 "Baseclass for all symbol references tools.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
434 A symbol reference tool supplies functionality to identify the locations of
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
435 where different symbols are used.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
436
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
437 Subclasses should be named `semantic-symref-tool-NAME', where
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
438 NAME is the name of the tool used in the configuration variable
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
439 `semantic-symref-tool'"
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
440 :abstract t)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
441
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
442 (defmethod semantic-symref-get-result ((tool semantic-symref-tool-baseclass))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
443 "Calculate the results of a search based on TOOL.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
444 The symref TOOL should already contain the search criteria."
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
445 (let ((answer (semantic-symref-perform-search tool))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
446 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
447 (when answer
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
448 (let ((answersym (if (eq (oref tool :resulttype) 'file)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
449 :hit-files
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
450 (if (stringp (car answer))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
451 :hit-text
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
452 :hit-lines))))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
453 (semantic-symref-result (oref tool searchfor)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
454 answersym
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
455 answer
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
456 :created-by tool))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
457 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
458 ))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
459
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
460 (defmethod semantic-symref-perform-search ((tool semantic-symref-tool-baseclass))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
461 "Base search for symref tools should throw an error."
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
462 (error "Symref tool objects must implement `semantic-symref-perform-search'"))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
463
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
464 (defmethod semantic-symref-parse-tool-output ((tool semantic-symref-tool-baseclass)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
465 outputbuffer)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
466 "Parse the entire OUTPUTBUFFER of a symref tool.
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
467 Calls the method `semantic-symref-parse-tool-output-one-line' over and
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
468 over until it returns nil."
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
469 (save-excursion
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
470 (set-buffer outputbuffer)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
471 (goto-char (point-min))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
472 (let ((result nil)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
473 (hit nil))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
474 (while (setq hit (semantic-symref-parse-tool-output-one-line tool))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
475 (setq result (cons hit result)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
476 (nreverse result)))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
477 )
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
478
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
479 (defmethod semantic-symref-parse-tool-output-one-line ((tool semantic-symref-tool-baseclass))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
480 "Base tool output parser is not implemented."
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
481 (error "Symref tool objects must implement `semantic-symref-parse-tool-output-one-line'"))
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
482
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
483 (provide 'semantic/symref)
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
484
36f56620b2ae cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
Chong Yidong <cyd@stupidchicken.com>
parents:
diff changeset
485 ;;; semantic/symref.el ends here