Here is my little fix to this problem. I changed jde-open-class-source so
that it doesn't call jde.util.JdeUtilities.getQualifiedName(String
className) if the class name passed as argument contains a dot. If needed,
we could also extend jde-is-fully-qualified-class-name to include the other
forms proposed by Sandip.  For now, only fully qualified names with dot(s)
are handled.

If you like it, just put the following 2 functions in your .emacs.  It
should make your life easier with the recent useful defuns proposed by
Sandip and the ECB methods window (you will be able to open the source file
by clicking on entries under [Parents] even the parent classes are fully
qualified).

Sylvain


(defun jde-is-fully-qualified-class-name (class-name)
  ""
  (let ((pos  (position ?. class-name)))
         (if pos
                  t
                nil)))

(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 
              (or unqual-class
                  (read-from-minibuffer "Class: " (thing-at-point
'symbol))))
             (class-names
                        (if (jde-is-fully-qualified-class-name
unqualified-name)
                                 (cons 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 ((dialog
                   (jde-open-class-source-chooser-dialog
                    "show sources dialog"
                    :classes class-names)))
              (efc-dialog-show dialog)))
          (setq jde-project-context-switching-enabled-p old-value)))
    (error
     (message "%s" (error-message-string err)))))



> -----Original Message-----
> From: Sandip Chitale [mailto:[EMAIL PROTECTED]]
> Sent: April 3, 2002 2:24 AM
> To: Letourneau, Sylvain
> Cc: [EMAIL PROTECTED]
> Subject: Re: jde-open-class-source fails with full class name
> 
> 
> This has troubled me also. I never got around to
> raizing the issue or attempting to solve it.
> 
> In fact the jde-open-class-source when called
> interactively should support all these forms -
> 
> Object           // search on classpath, prompt if multiple
> java.lang.Object // bypass 
> jde.util.JdeUtilities.getQualifiedName(String className)
> java/lang/Object // 
> java\lang\Object // the above two so that even file system based
>                  // typically cut from some other place.
> 
> or even
> 
> bar$innerClass
> foo.baz.bar$innerClass
> foo/baz/bar$innerClass
> foo\baz\bar$innerClass
> 
> should also be supported. The function should
> simpy locate the bar.java first and then go to innerClass
> definition within it.
> 
> I will give it a try when I find time. Others are welcome
> to try it.
> 
> -sandip
> 
> ----- Original Message ----- 
> From: "Letourneau, Sylvain" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, April 02, 2002 7:25 PM
> Subject: jde-open-class-source fails with full class name
> 
> 
> > It seems that some functions call jde-open-class-source with a fully
> > qualified class name as argument and that makes it fail 
> with a "Cannot find
> > %s" message.  
> > 
> > As an example, the error happens with 
> jde-show-superclass-source when the
> > super class is fully qualified (e.g.: class MyClass extends
> > java.lang.Object).  I also noticed the same problem with ECB.
> > 
> > It seems that jde-open-class-source fails because
> > jde.util.JdeUtilities.getQualifiedName(String className) 
> returns nil when
> > the input is already a fully qualified name. Is there 
> already a fix for
> > this?  If not, what would be the preferred fix: 
> > 1) in jde-open-class-source (an extra check before calling 
> getQualifiedName)
> > 2) jde.util.JdeUtilities.getQualifiedName(String className) 
> (a special
> > processing when the given className contains ".")
> > 3) other?
> > 
> > Thanks, 
> > Sylvain
> > 
> 

Reply via email to