]> code.delx.au - gnu-emacs/blob - lisp/cedet/semantic/symref/idutils.el
cedet/semantic/symref.el, cedet/semantic/symref/cscope.el.
[gnu-emacs] / lisp / cedet / semantic / symref / idutils.el
1 ;;; semantic/symref/idutils.el --- Symref implementation for idutils
2
3 ;;; Copyright (C) 2009 Free Software Foundation, Inc.
4
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
6
7 ;; This file is part of GNU Emacs.
8
9 ;; This program is free software; you can redistribute it and/or
10 ;; modify it under the terms of the GNU General Public License as
11 ;; published by the Free Software Foundation; either version 2, or (at
12 ;; your option) any later version.
13
14 ;; This program is distributed in the hope that it will be useful, but
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 ;; General Public License for more details.
18
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with this program; see the file COPYING. If not, write to
21 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
23
24 ;;; Commentary:
25 ;;
26 ;; Support IDUtils use in the Semantic Symref tool.
27
28 (require 'cedet-idutils)
29 (require 'semantic-symref)
30
31 ;;; Code:
32 (defclass semantic-symref-tool-idutils (semantic-symref-tool-baseclass)
33 (
34 )
35 "A symref tool implementation using ID Utils.
36 The udutils command set can be used to generate lists of tags in a way
37 similar to that of `grep'. This tool will parse the output to generate
38 the hit list.
39
40 See the function `cedet-idutils-search' for more details.")
41
42 (defmethod semantic-symref-perform-search ((tool semantic-symref-tool-idutils))
43 "Perform a search with IDUtils."
44 (let ((b (cedet-idutils-search (oref tool :searchfor)
45 (oref tool :searchtype)
46 (oref tool :resulttype)
47 (oref tool :searchscope)
48 ))
49 )
50 (semantic-symref-parse-tool-output tool b)
51 ))
52
53 (defmethod semantic-symref-parse-tool-output-one-line ((tool semantic-symref-tool-idutils))
54 "Parse one line of grep output, and return it as a match list.
55 Moves cursor to end of the match."
56 (cond ((eq (oref tool :resulttype) 'file)
57 ;; Search for files
58 (when (re-search-forward "^\\([^\n]+\\)$" nil t)
59 (match-string 1)))
60 ((eq (oref tool :searchtype) 'tagcompletions)
61 (when (re-search-forward "^\\([^ ]+\\) " nil t)
62 (match-string 1)))
63 (t
64 (when (re-search-forward "^\\([^ :]+\\):+\\([0-9]+\\):" nil t)
65 (cons (string-to-number (match-string 2))
66 (expand-file-name (match-string 1) default-directory))
67 ))))
68
69 (provide 'semantic/symref/idutils)
70
71 ;;; semantic/symref/idutils.el ends here