The jde-run-etrace-* commands do this too, take a look at
http://www.mail-archive.com/[EMAIL PROTECTED]/msg06868.html


Paul Landes wrote:


I couldn't find anything that did this.  Let me know if I
have reinvented the wheel.  If someone with CVS access
wants to add this, I'll leave it up to them where they want
to add it.

I wrote everything Emacs friendly under XEmacs.  Let me
know if you have problems, and I will add this to my `make
compat with emacs' todo list.


;;; code starts here


(defun jde-exception-stack-trace-parse-line ()
 "Parse the current line of an exception stack trace.      The class name, method
and (if provided) the source file line number, are returned in a list."
 (let (eol line class method lineno)
   (save-excursion
     (save-match-data
        (end-of-line)
        (setq eol (point))
        (beginning-of-line)
        (when (re-search-forward
               "^[ \t]*at \\(.+\\)\\.\\(.+\\)([^:)]+:?\\([0-9]+\\)?)$"
               eol t)
          (setq class (match-string 1)
                method (match-string 2)
                lineno (let ((s (match-string 3)))
                         (and s (string-to-int s))))
          (list class method lineno)
          )))))

(defun jde-exception-stack-trace-goto-error ()
 "Go to the Java source file indicated by the line at the current point of an
exception stack trace.  Also go to the line number if given by the stack
trace.

The line must be a stack trace line meaning it looks like `at <class> ...',
otherwise an error is signaled."
 (interactive)
 (let* ((exception-info (jde-exception-stack-trace-parse-line))
         source-file)

   (if (null exception-info)
        (error "line doesn't appear to be an exception stack trace line"))

     (setq class (first exception-info)
            method (second exception-info)
            lineno (third exception-info)
            source-file (jde-find-class-source-file class))

     (if (not source-file)
          (error "class `%s' not found" (first exception-info))
        (find-file source-file)
        (if lineno (goto-line lineno))
        (message (concat (format "Method `%s'" method)
                         (if lineno (format " in line %d" lineno))
                         (format " of `%s'" class)))
        )))

;;; code ends here







Reply via email to