]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/semantic/symref/idutils.el
Perform xref searches without visiting unopened files
[gnu-emacs] / lisp / cedet / semantic / symref / idutils.el
index 5e9a0a42bfc5bfb7fcfb847ee50a28c8d16b8b0b..db3e9a0dddb67d5104060bd03c39d77b13c1bd26 100644 (file)
@@ -1,6 +1,6 @@
 ;;; semantic/symref/idutils.el --- Symref implementation for idutils
 
-;;; Copyright (C) 2009-2015 Free Software Foundation, Inc.
+;;; Copyright (C) 2009-2016 Free Software Foundation, Inc.
 
 ;; Author: Eric M. Ludlam <eric@siege-engine.com>
 
@@ -38,7 +38,7 @@ the hit list.
 
 See the function `cedet-idutils-search' for more details.")
 
-(defmethod semantic-symref-perform-search ((tool semantic-symref-tool-idutils))
+(cl-defmethod semantic-symref-perform-search ((tool semantic-symref-tool-idutils))
   "Perform a search with IDUtils."
   (let ((b (cedet-idutils-search (oref tool :searchfor)
                                 (oref tool :searchtype)
@@ -49,7 +49,10 @@ See the function `cedet-idutils-search' for more details.")
     (semantic-symref-parse-tool-output tool b)
     ))
 
-(defmethod semantic-symref-parse-tool-output-one-line ((tool semantic-symref-tool-idutils))
+(defconst semantic-symref-idutils--line-re
+  "^\\(\\(?:[a-zA-Z]:\\)?[^:\n]+\\):\\([0-9]+\\):")
+
+(cl-defmethod semantic-symref-parse-tool-output-one-line ((tool semantic-symref-tool-idutils))
   "Parse one line of grep output, and return it as a match list.
 Moves cursor to end of the match."
   (cond ((eq (oref tool :resulttype) 'file)
@@ -59,8 +62,13 @@ Moves cursor to end of the match."
        ((eq (oref tool :searchtype) 'tagcompletions)
         (when (re-search-forward "^\\([^ ]+\\) " nil t)
           (match-string 1)))
-       (t
-        (when (re-search-forward "^\\([^ :]+\\):+\\([0-9]+\\):" nil t)
+        ((eq (oref tool :resulttype) 'line-and-text)
+         (when (re-search-forward semantic-symref-idutils--line-re nil t)
+          (list (string-to-number (match-string 2))
+                 (expand-file-name (match-string 1) default-directory)
+                 (buffer-substring-no-properties (point) (line-end-position)))))
+       (t ; resulttype is line
+        (when (re-search-forward semantic-symref-idutils--line-re nil t)
           (cons (string-to-number (match-string 2))
                 (expand-file-name (match-string 1) default-directory))
           ))))