On Wed, 19 Feb 2003, Karel Sprenger wrote:

>  Hello,
>  
>  Ironically enough, the method ecb-jde-display-class-at-point shows the same
>  behaviour as Sandip's code when I invoke it with point in the variable
>  logger in class B.

Of course, this must be because Sandips and my code use the same JDE code to
get the class for the thing under point. Or with other words: Both uses the
JDE mechanism used for method/field-completion.

The following code is responsible for getting the class:

,----
|   (let* (
|          (thing-of-interest (thing-at-point 'symbol))
|          (pair (save-excursion (end-of-thing 'symbol)
|                                (jde-parse-java-variable-at-point)))
|          (class-to-open (jde-open-get-class-to-open
|                          pair thing-of-interest))
|          (source-path-prefix-list (jde-open-get-path-prefix-list)) 
|          (java-file-name nil)
|          )
|     (if (and class-to-open (stringp class-to-open))
|         (progn
|           (setq java-file-name (jde-open-find-java-file-name
|                                 class-to-open source-path-prefix-list))
|           (if (not java-file-name)
|           ;; here comes the code which displays contents of
|           ;; java-file-name 
`----

Exactly the same mechanism is used by jde-open-class-at-point and also
also jde-complete.

See jde-open-source.el!

Sandips and my code are equal in getting the "correct" class and different in
getting and displaying the contents of this class.

Ciao,
Klaus

>  
>  public class A {
>     protected Logger logger = new Logger();
>     public A() {
>     }
>  
>     public String toString() {
>        logger.debug("A.toString() invoked.");
>        return "A";
>     }
> }
>  
>  public class B extends A {
>     public B() {
>     }
>  
>     public String toString() {
>        logger.debug("B.toString() invoked.");
>  //      ^-- invoke ecb-jde-display-class-at-point here
>        return "B";
>     }
> }
>  
>  If I invoke ecb-jde-display-class-at-point with point inside logger in the
>  toString method of class A, all is well and I get:
>  
>  Logger [-]
>    Varia... [+]
>    Logger()
>    Logger(String)
>    void debug(String)
>    void debug(String,Throwable)
>    void error(String)
>    void error(String,Throwable)
>    void info(String)
>    void info(String,Throwable)
>    void warn(String)
>    void warn(String,Throwable)
>  
>  Invoking ecb-jde-display-class-at-point with point inside logger in B's
>  toString method will show
>  
>  B [-]
>    Parents [+]
>    + B()
>    + String toString()
>  
>  Is this a semantic problem?
>  
>  Cheers, Karel -----Original Message----- From: Berndl, Klaus
>  [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 19, 2003 11:07 To:
>  'Sandip Chitale'; [EMAIL PROTECTED] Subject: RE: Introspection based Java
>  class browser....also demonstrates alittle bit of java and lisp
>  integration...
>  
>  
>  Hello,
>  
>  attached is a small library ecb-jde.el which enables you to display
>  the contents of class at point in the method-window of ECB:
>  
>  (defun ecb-jde-display-class-at-point ()
>    "Displays in the ECB-methods-buffer the contents \(methods, attributes
>  etc...) of the class which contains the definition of the \"thing\" under
>  point \(this can be a variablename, classname, methodname, attributename).
>  This function needs the same requirements to work as the method-completion
>  feature of JDE \(see `jde-complete-at-point')!. The source-file is searched
>  first in `jde-sourcepath', then in `jde-global-classpath', then in
>  $CLASSPATH, then in current-directory."
>    (interactive)
>    ...
>  )
>  
>  Just do:
>  
>  1. Save ecb-jde.el somewhere in your load-path - probably best in the
>     ecb-directory ;-)
>  2. Activate ECB
>  3. Open a java-source
>  4. Load ecb-jde.el, e.g. with M-x load-library RET ecb RET
>  5. Try it.
>  
>  Differences to Sandips code:
>  
>  - uses ECB method-window to display the class-contents
>  - uses semantic for getting the contents of a class
>  - needs the source-file of the class to work
>  
>  The first point can be seen as advantage or disadvantage ;-)
>  
>  Especially the latter point is a disadvantage because it prevents
>  from working for classes which are only available as *.class-file or
>  within a jar-file...
>  
>  But it demonstrates another elegant way of displaying things of a class
>  under point without needing java-introspection.
>  
>  Klaus
>  
>  -----Original Message----- From: Sandip Chitale
>  [mailto:[EMAIL PROTECTED]] Sent: Wednesday, February 19, 2003 7:32 AM
>  To: [EMAIL PROTECTED] Subject: Introspection based Java class browser....also
>  demonstrates alittle bit of java and lisp integration...
>  
>  
> >To use :
>  
> >1. unzip the attached zip at in the jde directory
> >2. Just put the following in your .emacs
>  
> >(require 'jde-introspect)
>  
> >Now put the point anywhere in Java buffer where you would
> >normally invoke jde-complete functions. Then type
> >(control c) (control v) (/) to see the java typeinfo
> >buffer.
>  
> >For example:
>  
> >With point in the 'System' below :
> >public class Foo {
> > public static void main(String[] args) {
> >  System.out.println(args.length);
> > }
> >}
> >here is what you get in a temp buffer. All the java class names are
> >hyperlinks (activated by
> >mouse or <RET> key).
> >class java.lang.System

-- 
Klaus Berndl                    mailto: [EMAIL PROTECTED]
sd&m AG                         http://www.sdm.de
software design & management    
Thomas-Dehler-Str. 27, 81737 München, Germany
Tel +49 89 63812-392, Fax -220

Reply via email to