Hi, The function `semantic-find-nonterminal' will use `semantic-find-dependency' on import statements. This function in turn uses `semantic-dependency-include-path' to seek out where a file is.
semantic-java does not yet support overloading `semantic-find-dependency' nor `semantic-dependency-include-path'. If one of these mechanisms were extended in JDE's context, then tools such as ECB, Speedbar, and Senator could all successfully jump to imports without the need for specialty commands. Doing so would be as simple as using the existing code, and using semantic's function overload facility to link them together. There is also the work that Paul mentioned he is doing in the semantic database which I do not think touches upon either of these two functions. Perhaps semantic's find-dependency function should go through semanticdb in the future. (It was written before the database.) Have fun Eric >>> "Timothy Babin" <[EMAIL PROTECTED]> seems to think that: >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. > >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 > >