Update copyright year to 2014 by running admin/update-copyright.
[emacs.git] / lisp / cedet / semantic / symref / global.el
blob0648c90857d6797c4dc2cf64a3783965891e8ab6
1 ;;; semantic/symref/global.el --- Use GNU Global for symbol references
3 ;; Copyright (C) 2008-2014 Free Software Foundation, Inc.
5 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
7 ;; This file is part of GNU Emacs.
9 ;; GNU Emacs is free software: you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation, either version 3 of the License, or
12 ;; (at your option) any later version.
14 ;; GNU Emacs is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
22 ;;; Commentary:
24 ;; GNU Global use with the semantic-symref system.
26 (require 'cedet-global)
27 (require 'semantic/symref)
29 ;;; Code:
30 ;;;###autoload
31 (defclass semantic-symref-tool-global (semantic-symref-tool-baseclass)
34 "A symref tool implementation using GNU Global.
35 The GNU Global command can be used to generate lists of tags in a way
36 similar to that of `grep'. This tool will parse the output to generate
37 the hit list.
39 See the function `cedet-gnu-global-search' for more details.")
41 (defmethod semantic-symref-perform-search ((tool semantic-symref-tool-global))
42 "Perform a search with GNU Global."
43 (let ((b (cedet-gnu-global-search (oref tool :searchfor)
44 (oref tool :searchtype)
45 (oref tool :resulttype)
46 (oref tool :searchscope)
49 (semantic-symref-parse-tool-output tool b)
52 (defmethod semantic-symref-parse-tool-output-one-line ((tool semantic-symref-tool-global))
53 "Parse one line of grep output, and return it as a match list.
54 Moves cursor to end of the match."
55 (cond ((or (eq (oref tool :resulttype) 'file)
56 (eq (oref tool :searchtype) 'tagcompletions))
57 ;; Search for files
58 (when (re-search-forward "^\\([^\n]+\\)$" nil t)
59 (match-string 1)))
61 (when (re-search-forward "^\\([^ ]+\\) +\\([0-9]+\\) \\([^ ]+\\) " nil t)
62 (cons (string-to-number (match-string 2))
63 (match-string 3))
64 ))))
66 (provide 'semantic/symref/global)
68 ;; Local variables:
69 ;; generated-autoload-file: "../loaddefs.el"
70 ;; generated-autoload-load-name: "semantic/symref/global"
71 ;; End:
73 ;;; semantic/symref/global.el ends here