I have made a couple of modification to jdee to have the capability to
open source file directly from jar file (if jar file is specified in
jde-sourcepath)

this modification are based on code found in arc-mode.

I have modified the function "jde-find-class-source-file"
and re-write the function "jde-search-src-dirs"

Maybe it is possible to add this modification to jdee for future release.
I'm not an expert lisp coder, if something is wrong, tou can mdofiy this
code without hesitating

Christophe

;;;;; jde-search-src-dirs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun jde-find-class-source-file (class)
  "*Find the source file for a specified class.
CLASS is the fully qualified name of the class. This
function searchs the source file paths specified by
`jde-sourcepath' for the source file
corresponding to CLASS. If it finds the source file,
it returns the file's path. Otherwise, it returns nil."
  (let* ((class (jde-remove-inner-class class))
         (source-dir (jde-search-src-dirs class))
         (file-name
         (concat (jde-parse-get-unqualified-name class)
                 ".java")))
     (if source-dir
         (if (not (string= source-dir "jar-src"))
             (expand-file-name file-name source-dir)
           )
       (message "JDE error: Could not find source for \"%s\". See
`jde-sourcepath' for more information." class)
       nil)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;;;;; jde-search-src-dirs ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun jde-search-src-dirs(class)
;;    (interactive)
;;    (setq class (read-buffer "CLASS: "))
   (let ((file (concat
                (jde-parse-get-unqualified-name class)
                ".java"))
         (package (jde-parse-get-package-from-name class))
         )
    (catch 'found
      (loop for dir in jde-sourcepath do
            (progn
              (setq dir(jde-normalize-path dir 'jde-sourcepath))
              (setq extractor nil)
              (if (and (or (string-match "\.jar$" dir)
                           (string-match "\.zip$" dir)
                           )
                       (file-exists-p dir))
                  (progn
                    (let* ((other-window-p nil)
                           (pkg-path (subst-char-in-string ?. ?/ package))
                           (view-p (eq other-window-p 'view))
                           (class-file-name (concat  pkg-path "/" file))
                           (bufname (concat file " (" (file-name-nondirectory 
dir) ")"))
                           (buffer (get-buffer bufname))
                           (just-created nil)
                           exit-status success)
                      (if buffer
                          (progn
                            (or (not (buffer-name buffer))
                                (progn
                                  (if view-p
                                      (view-buffer buffer (and just-created 
'kill-buffer))
                                    (if (eq other-window-p 'display)
                                        (display-buffer buffer)
                                      (if other-window-p
                                          (switch-to-buffer-other-window buffer)
                                        (switch-to-buffer buffer)))
                                    )))
                            )
                        (setq buffer (get-buffer-create bufname))
                        (setq just-created t)
                        (save-excursion
                          (set-buffer buffer)
                          (setq buffer-file-name (expand-file-name (concat dir 
":"
class-file-name)))
                          (setq buffer-file-truename file)
                          (setq default-directory (file-name-directory dir))
                          (setq exit-status (archive-extract-by-stdout dir 
class-file-name
archive-zip-extract))
                          (message "status:%s" exit-status)
                          (if (and (numberp exit-status) (= exit-status 0))
                              (progn
                                (message "found");
                                (setq buffer-read-only t)
                                (goto-char (point-min))
                                (rename-buffer bufname)
                                (setq buffer-undo-list nil)
                                (set-buffer-modified-p nil)
                                (setq buffer-saved-size (buffer-size))
                                (set-buffer-major-mode buffer)
                                (normal-mode)
                                (or (not (buffer-name buffer))
                                    (progn
                                      (if view-p
                                          (view-buffer buffer (and just-created 
'kill-buffer))
                                        (if (eq other-window-p 'display)
                                            (display-buffer buffer)
                                          (if other-window-p
                                              (switch-to-buffer-other-window 
buffer)
                                            (switch-to-buffer buffer)))
                                        )))
                                (throw 'found "jar-src")
                                )
                            (progn
                              (set-buffer-modified-p nil)
                              (server-kill-buffer buffer))
                            )
                          )
                        )))
                (if (file-exists-p (expand-file-name file dir))
                    (throw 'found dir)
                  (let* ((pkg-path (subst-char-in-string ?. ?/ package))
                         (pkg-dir (expand-file-name pkg-path dir))
                         (file-path (expand-file-name file pkg-dir)))
                    (if (file-exists-p file-path)
                        (throw 'found pkg-dir))))))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Reply via email to