Here is my stab at fixing "jde-open-class-source fails with full class
name".
This also deals with some of the proposals I had made earlier.

(defun jde-normalize-class-name (class-name)
  "Normalize the class name by substituting / or \\ with ."
  (substitute ?. ?\\ (substitute ?. ?/ class-name))
)

(defun jde-open-class-source ( &optional unqual-class )
  "Displays source of the class whose name appears at point in the current
Java buffer. This command finds only classes that reside in the source paths
specified by `jde-db-source-directories'. You should provide a global
setting
for this variable in your .emacs file to accommodate source files that are
not associated with any project."
  (interactive)
  (condition-case err
      (let* ((unqualified-name 
              (jde-normalize-class-name (or unqual-class
                  (read-from-minibuffer "Class: " (thing-at-point
'symbol)))))
             (class-names
              (if (position ?. unqualified-name)
                  (list unqualified-name)
                ;;expand the names into full names, or a list of names
                (jde-jeval-r 
                 (concat 
                  "jde.util.JdeUtilities.getQualifiedName(\"" 
                  unqualified-name "\");"))))
             )
        ;;Check return value of QualifiedName
        (if (or (eq class-names nil)
                (not (listp class-names)))
            (error "Cannot find %s" unqualified-name))
        ;; Turn off switching project settings to avoid 
        ;; resetting jde-db-source-directories.
        (let ((old-value jde-project-context-switching-enabled-p))
          (setq jde-project-context-switching-enabled-p nil)
          ;;If the list is only one long
          (if (eq 1 (length class-names))
              ;;then show it
              (progn(other-window 1)
                    (jde-find-class-source (car class-names)))
                  ;;else let the user choose
            (let ((class (efc-query-options class-names "Which class?")))
                  (if class
                      (jde-find-class-source class))))
          (setq jde-project-context-switching-enabled-p old-value)))
    (error
     (message "%s" (error-message-string err)))))

Reply via email to