In principal you do the following:

1. Getting the class of current point
2. Introspection with java-code of this class

Here is your code

,----
| (defun jde-introspect-javatype-at-point ()
|   (interactive)
|   (if (jde-open-functions-exist)
|       (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  ;; <-------- step 1.
|                              pair thing-of-interest))
|            )
|         (if (and class-to-open (stringp class-to-open))
|             (jde-introspect-javatype class-to-open)      ;; <-------- step 2.
|           (error "Can not parse the thing at point!")))
|     (message "You need JDE >= 2.2.6 and Senator for using this feature!")))
`----

IMHO step 1. is enough and step 2 can be done much smarter with semantic
because this tool already offers all what we need for getting the contents of
a class!

I would do the following:

1. Getting the class C of current point like in your code.
2. Opening the file F which contains class C with find-file-noselect in a
   hidden buffer

   (save-excursion
      (set-buffer (find-file-noselect "file of class c"))
      ....
      )

3. In this buffer just call `senator-parse' or `semantic-bovinate-toplevel'
   which return all tokens in this file. The library semantic-util.el offers a
   lot to display and bucketize these tokens in several manners (e.g. like in
   UML-notation).

   (save-excursion
      (set-buffer (find-file-noselect "file of class c"))
      (let ((tokens (senator-parse)))
        ;; do something with the tokens, e.g. display it in a special buffer
        )
      )
   
4. If you use ECB you can use its methods buffer to display the contents of
   class under point with the following short code:

   (save-excursion
      (set-buffer (find-file-noselect "file of class c"))
      (ecb-update-methods-buffer--internal 'scroll-to-begin)
      )

   You do not need more code to display the methods and variables of class C
   under point in the methods-buffer of ECB!


IMHO this is much easier than using this somehow clumsy beanshell to
communicate between java and elisp. IMHO java/Beanshell is good to find out in
which file a class/method is defined, but the rest of the job can be done
very easy with semantic (and ECB if you like).

But do not misunderstand me: Your code is good and a really stringent
mechanism for code-completion/introspection/browsing etc.  is really needed in
JDEE. IMHO currently there are too many different mechanisms in JDEE to do
this things.

Ciao,
Klaus

On Tue, 18 Feb 2003, Sandip Chitale wrote:

>  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
>  /******************************************
>   * Constructors of class System
>   ******************************************/
>  private                       System()
>  /******************************************
>   * Methods of class System
>   ******************************************/
>  public static native          void arraycopy(Object, int, Object, int,
>  int)
>  public static native          int identityHashCode(Object)
>  public static                 void exit(int)
>  public static                 void runFinalizersOnExit(boolean)
>  private static                void initializeSystemClass()
>  public static                 String setProperty(String, String)
>  private static native         void registerNatives()
>  public static                 SecurityManager getSecurityManager()
>  static                        Class getCallerClass()
>  public static                 void loadLibrary(String)
>  public static                 String getProperty(String)
>  public static                 String getProperty(String, String)
>  public static native          String mapLibraryName(String)
>  public static                 void load(String)
>  public static                 void setIn(InputStream)
>  public static                 void setOut(PrintStream)
>  public static                 void setErr(PrintStream)
>  private static                void checkIO()
>  private static native         void setIn0(InputStream)
>  private static native         void setOut0(PrintStream)
>  private static native         void setErr0(PrintStream)
>  public static                 void setSecurityManager(SecurityManager)
>  private static synchronized   void setSecurityManager0(SecurityManager)
>  public static native          long currentTimeMillis()
>  private static native         Properties initProperties(Properties)
>  public static                 Properties getProperties()
>  public static                 void setProperties(Properties)
>  public static                 String getenv(String)
>  public static                 void gc()
>  public static                 void runFinalization()
>  private static                InputStream nullInputStream() throws
>  NullPointerException
>  private static                PrintStream nullPrintStream() throws
>  NullPointerException
>  /******************************************
>   * Fields of class System
>   ******************************************/
>  public final static           InputStream in 
>  public final static           PrintStream out 
>  public final static           PrintStream err 
>  private static                SecurityManager security 
>  private static                Properties props 

-- 
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