Is this work visible?
I'd be interested to take a look.
Tim
-----Original Message-----
From: Paul Kinnucan [mailto:[EMAIL PROTECTED]]
Sent: Friday, May 31, 2002 2:30 PM
To: Babin, Timothy [NGC:B680:EXCH]
Cc: JDE (E-mail); '[EMAIL PROTECTED]'
Subject: Using semantic + import statement to open class source
Timothy Babin writes:
> Hi,
> I found the java-open package written by Rajeev Karunakaran to be
> quite useful and quick.
> I have written some functions which use the same concept but use semantic to
> get the import statements instead
> of reg-ex. This is very usefull if you don't have class files for the source
> that you are looking for and for speed.
> It would be nice if this could be used to open class source files before
> using the beanshell or if the user could
> specifiy which method to use first. It would also be nice to then fallback
> to using tags.
>
I've been working with Eric Ludlum to develop additions to semantic
that will integrate the Java classpath with semantic. By this I mean,
whenever you ask for information about a class, the JDEE will look
first in the semantic databases on your system and only resort to
the beanshell as a last resort. This will all be done transparently
so tha clients of the semantic database, such as the JDEE's completion
and go-to-symbol-def commands, never need to worry about where the
class information is located.
I've got a lot of the functionality implemented but have had to
put the project on hold in order to make time to absorb a recent
spate of JDEE contributions and also because of work deadlines.
I expect to get back to this project in a few weeks.
- Paul
> Let me know what you think.
>
>
> (defun jde-custom-find-fqimport (import-list class)
> "Opens the source file for `class' if a fully qualified import statement
> for
> the class is found in `import-list' and returns t; returns nil otherwise.
> Uses `jde-find-class-source' to open the file"
> (let ((current-import)
> (match-found nil)
> (iterator import-list))
> (while (and iterator (not match-found))
> (setq current-import (car (car iterator)))
> (message current-import)
> (if (string-match (concat ".*\\." class "\\'") current-import)
> (progn
> (if (not (jde-find-class-source current-import))
> (message "Can't find source"))
> (setq match-found t)))
> (setq iterator (cdr iterator)))
> match-found
> )
> )
>
> (defun jde-custom-find-starimport (import-list class)
> "Opens the source file for `class' if a star import statement for
> the class is found in `import-list' and returns t; returns nil otherwise.
> Uses `jde-find-class-source' to open the file"
> (let ((current-import)
> (match-found nil)
> (iterator import-list))
> (while (and iterator (not match-found))
> (setq current-import (car (car iterator)))
> (message current-import)
> (if (string-match "\\(.*\\.\\)\\*" current-import)
> (progn
> (setq current-import (replace-match "\\1" t nil current-import))
> (message "found star import")
> (message current-import)
> (if (jde-find-class-source (concat current-import class))
> (setq match-found t))))
> (setq iterator (cdr iterator)))
> match-found
> )
> )
>
>
> (defun jde-custom-open-class (&optional unqual-class)
> "Opens the source file for `class' if an import statement for
> the class is found or the class is found in the current source file
> directory or in java.lang.
> Uses `jde-find-class-source' to open the file"
> (interactive)
> ;; (semantic-bovinate-toplevel t)
> (save-excursion
> (let* ((class (or unqual-class
> (read-from-minibuffer "Class: " (thing-at-point
> 'symbol))))
> (tokens (semantic-bovinate-toplevel t))
> (depends (semantic-find-nonterminal-by-token 'include tokens)))
> (cond ((jde-custom-find-fqimport depends class))
> ((jde-custom-find-starimport depends class))
> ((progn
> ;; look for file in current directory
> (let ((fname (concat class ".java")))
> (if (file-readable-p fname)
> (progn (find-file fname) ; open file in current
> dir
> (message "Opened %s" (expand-file-name
> fname)))))))
> ((jde-find-class-source (concat "java.lang." class)))
> ((jde-open-class-source class))
> )
> )))
>
> (defun jde-custom-open-class-at-point()
> (interactive)
> (jde-custom-open-class (current-word)))
>
>
>
>
> Tim Babin
>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
> <HTML>
> <HEAD>
> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
> <META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2654.89">
> <TITLE>Using semantic + import statement to open class source</TITLE>
> </HEAD>
> <BODY>
>
> <P><FONT SIZE=2 FACE="Arial">Hi,</FONT>
> <BR> <FONT SIZE=2 FACE="Arial">I found the java-open package written by Rajeev Karunakaran to be quite useful and quick.</FONT>
> <BR><FONT SIZE=2 FACE="Arial">I have written some functions which use the same concept but use semantic to get the import statements instead</FONT>
> <BR><FONT SIZE=2 FACE="Arial">of reg-ex. This is very usefull if you don't have class files for the source that you are looking for and for speed.</FONT>
> <BR><FONT SIZE=2 FACE="Arial">It would be nice if this could be used to open class source files before using the beanshell or if the user could</FONT>
> <BR><FONT SIZE=2 FACE="Arial">specifiy which method to use first. It would also be nice to then fallback to using tags.</FONT>
> </P>
>
> <P><FONT SIZE=2 FACE="Arial">Let me know what you think.</FONT>
> </P>
> <BR>
>
> <P><FONT SIZE=2 FACE="Arial">(defun jde-custom-find-fqimport (import-list class)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> "Opens the source file for `class' if a fully qualified import statement for</FONT>
> <BR><FONT SIZE=2 FACE="Arial">the class is found in `import-list' and returns t; returns nil otherwise.</FONT>
> <BR><FONT SIZE=2 FACE="Arial">Uses `jde-find-class-source' to open the file"</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (let ((current-import)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (match-found nil)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (iterator import-list))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (while (and iterator (not match-found))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (setq current-import (car (car iterator)))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (message current-import)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (if (string-match (concat ".*\\." class "\\'") current-import)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (progn</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (if (not (jde-find-class-source current-import))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (message "Can't find source"))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (setq match-found t)))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (setq iterator (cdr iterator)))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> match-found</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> )</FONT>
> <BR><FONT SIZE=2 FACE="Arial">)</FONT>
> </P>
>
> <P><FONT SIZE=2 FACE="Arial">(defun jde-custom-find-starimport (import-list class)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> "Opens the source file for `class' if a star import statement for</FONT>
> <BR><FONT SIZE=2 FACE="Arial">the class is found in `import-list' and returns t; returns nil otherwise.</FONT>
> <BR><FONT SIZE=2 FACE="Arial">Uses `jde-find-class-source' to open the file"</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (let ((current-import)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (match-found nil)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (iterator import-list))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (while (and iterator (not match-found))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (setq current-import (car (car iterator)))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (message current-import)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (if (string-match "\\(.*\\.\\)\\*" current-import)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (progn</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (setq current-import (replace-match "\\1" t nil current-import))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (message "found star import")</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (message current-import)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (if (jde-find-class-source (concat current-import class))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (setq match-found t))))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (setq iterator (cdr iterator)))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> match-found</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> )</FONT>
> <BR><FONT SIZE=2 FACE="Arial">)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> </FONT>
> </P>
>
> <P><FONT SIZE=2 FACE="Arial">(defun jde-custom-open-class (&optional unqual-class)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> "Opens the source file for `class' if an import statement for</FONT>
> <BR><FONT SIZE=2 FACE="Arial">the class is found or the class is found in the current source file</FONT>
> <BR><FONT SIZE=2 FACE="Arial">directory or in java.lang.</FONT>
> <BR><FONT SIZE=2 FACE="Arial">Uses `jde-find-class-source' to open the file"</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (interactive)</FONT>
> <BR><FONT SIZE=2 FACE="Arial">;; (semantic-bovinate-toplevel t)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (save-excursion</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (let* ((class (or unqual-class</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (read-from-minibuffer "Class: " (thing-at-point 'symbol))))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (tokens (semantic-bovinate-toplevel t))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (depends (semantic-find-nonterminal-by-token 'include tokens)))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (cond ((jde-custom-find-fqimport depends class))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> ((jde-custom-find-starimport depends class))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> ((progn</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> ;; look for file in current directory</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (let ((fname (concat class ".java")))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (if (file-readable-p fname)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (progn (find-file fname) ; open file in current dir</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (message "Opened %s" (expand-file-name fname)))))))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> ((jde-find-class-source (concat "java.lang." class)))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> ((jde-open-class-source class))</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> )</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> )))</FONT>
> </P>
>
> <P><FONT SIZE=2 FACE="Arial">(defun jde-custom-open-class-at-point()</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (interactive)</FONT>
> <BR><FONT SIZE=2 FACE="Arial"> (jde-custom-open-class (current-word)))</FONT>
> </P>
> <BR>
> <BR>
> <BR>
>
> <P><FONT SIZE=2 FACE="Arial">Tim Babin</FONT>
> </P>
>
> </BODY>
> </HTML>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]