Re: Patch for allowing wildcards in jde-sourcepath

Troy Daniels <[email protected]>
Newsgroups gmane.emacs.jdee.devel
Message-ID <[email protected]>
On Wed, Mar 17, 2010 at 8:55 PM, Len Trigg
<[email protected]<lenbok%[email protected]>
> wrote:

> Troy Daniels wrote:
> > Attached is a patch to the 2.4.0 branch which allows wildcards in
> jde-sourcepath.  I've been using it at work for a few days and it works for
> me.  Can somebody
> > with commit permissions add it to the repository?
>
> I had a very quick look at it and it seems OK - I haven't tested the
> functionality though.  There are a few new compilation warnings as a
> result of the patch -- can you rebase it against the trunk and clean
> up those please?
>
>
I'm cleaning up those warnings, but there's one I'm not certain how to
handle.

In end of data:
jde-db.el:2018:1:Warning: the following functions are not known to be
defined:
    jde-find-class-source-file, jde-build-classpath, jde-normalize-path,
    jde-jdb-get-jdb

has now become

In end of data:
jde-db.el:2017:1:Warning: the following functions are not known to be
defined:
    jde-find-class-source-file, jde-build-classpath, jde-normalize-path,
    jde-jdb-get-jdb*, jde-expand-wildcards-and-normalize
*
The new function is defined in the jde.el, the same file as
jde-normalize-path, and that seems to be the logical place to define it (as
it is related to jde-normalize-path).  Is there a standard way to make
"forward declarations" for the compiler?  Since there is already a warning
for jde-normalize-path, it seems that there probably is not a way.  If so,
is it acceptable to add this warning to the build?

There is a similar warning in jde-javadoc-gen.el

I've attached the updated patch in case these warnings are acceptable.

Troy


Cheers,
> Len.
>

------------------------------------------------------------------------------
Download Intel&#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev

_______________________________________________
jdee-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jdee-devel
jdee-wildcards.patch (application/octet-stream, 7.4 KB)
Index: lisp/jde-db.el
===================================================================
--- lisp/jde-db.el	(revision 220)
+++ lisp/jde-db.el	(working copy)
@@ -2000,18 +2000,15 @@
   "Return true if one of `jde-sourcepath'
 matches FILE."
   (let* ((directory-sep-char ?/)
-	 (filename (jde-normalize-path file)))
+		 (filename (jde-normalize-path file)))
     (find-if
      (lambda (dir-x)
        (string-match
-	(concat
-	 "^"
-	 (jde-normalize-path
-	  dir-x
-	  'jde-sourcepath))
-	filename))
-     jde-sourcepath)))
+		(concat "^" dir-x)
+		filename))
+     (jde-expand-wildcards-and-normalize jde-sourcepath 'jde-sourcepath))))
 
+
 (provide 'jde-db)
 
 ;;; End of jde-db.el
Index: lisp/jde-javadoc-gen.el
===================================================================
--- lisp/jde-javadoc-gen.el	(revision 220)
+++ lisp/jde-javadoc-gen.el	(working copy)
@@ -328,8 +328,7 @@
 	       (list
 		"-sourcepath"
 		(jde-build-classpath
-		 jde-sourcepath
-		 'jde-sourcepath)))))
+		 (jde-expand-wildcards-and-normalize jde-sourcepath 'jde-sourcepath))))))
 
 
     ;; Insert bootclasspath
Index: lisp/jde-open-source.el
===================================================================
--- lisp/jde-open-source.el	(revision 220)
+++ lisp/jde-open-source.el	(working copy)
@@ -96,7 +96,7 @@
        (fboundp 'jde-parse-find-completion-for-pair)))
 
 
-(defun jde-open-jump-to-class (parsed-symbol class-name) 
+(defun jde-open-jump-to-class (parsed-symbol class-name)
   "Place the cursor in the parsed variable"
   (let* (tags super-class (first-time t))
     ;; Searching only for the symbol '{' is not good enough. We can
@@ -118,7 +118,7 @@
       (setq parsed-symbol (concat "\\b" parsed-symbol "\\b"))
       (while (not (senator-re-search-forward parsed-symbol nil t))
 	(message "Could not find %s in %s" parsed-symbol (buffer-name))
-        ;; searching for the thing-of-interest has failed 
+        ;; searching for the thing-of-interest has failed
         ;; let's try in the base class
         (progn
           (if (not super-class)
@@ -132,7 +132,7 @@
           ;;if it is the first time try in the class definition
           ;;itself.
           (if first-time
-              (progn 
+              (progn
                 (setq first-time nil)
                 (senator-re-search-forward
                  (progn
@@ -145,13 +145,13 @@
 (defun jde-get-parents ()
   "Returns a list with all the parents (super class and interfaces,
 if any) of the current class or interface."
-  (jde-remove-type 
+  (jde-remove-type
    (append (semantic-tag-type-superclasses
 	    (semantic-current-tag-of-class 'type))
-	   (semantic-tag-type-interfaces (semantic-current-tag-of-class 
+	   (semantic-tag-type-interfaces (semantic-current-tag-of-class
 					  'type)))))
 
-(defun jde-remove-type (list) 
+(defun jde-remove-type (list)
   "Removes generics '<Type>' declaration from every given
 class/interface name."
   (mapcar '(lambda(s) (replace-regexp-in-string "<.*>" "" s)) list))
@@ -317,9 +317,7 @@
 		".java")
 	  package (jde-parse-get-package-from-name outer-class))
     (catch 'found
-      (loop for path in jde-sourcepath do
-	    (progn
-	      (setq path (jde-normalize-path path 'jde-sourcepath))
+      (loop for path in (jde-expand-wildcards-and-normalize jde-sourcepath 'jde-sourcepath) do
 	      (if (and (file-exists-p path)
 		       (or (string-match "\.jar$" path)
 			   (string-match "\.zip$" path)))
@@ -355,7 +353,7 @@
 			 (pkg-dir (expand-file-name pkg-path path))
 			 (file-path (expand-file-name file pkg-dir)))
 		    (if (file-exists-p file-path)
-			(throw 'found file-path))))))))))
+		      (throw 'found file-path)))))))))
 
 (defcustom jde-preferred-packages
   '("java.util" "java" "javax")
Index: lisp/jde-package.el
===================================================================
--- lisp/jde-package.el	(revision 220)
+++ lisp/jde-package.el	(working copy)
@@ -152,7 +152,7 @@
    (jde-package-get-classpath)))
 
 
-(defun jde-package-seach-package-directories ()
+(defun jde-package-search-package-directories ()
   "Return a list of package directory candidates or nil if not found."
   (let ((dir (jde-normalize-path default-directory))
 	;; case-insensitive for Windows
@@ -166,9 +166,8 @@
      (append (jde-package-get-directories-in-classpath)
 	     (mapcar
 	      (lambda (p)
-		(file-name-as-directory
-		 (jde-normalize-path p 'jde-sourcepath)))
-	      jde-sourcepath)))))
+		(file-name-as-directory p))
+	      (jde-expand-wildcards-and-normalize jde-sourcepath 'jde-sourcepath))))))
 
 (defun jde-package-best-package-candidate (candidates)
   "Return the best package directory candidate from CANDIDATES.
@@ -181,7 +180,7 @@
   "Return the package directory, if found; otherwise,
 `jde-package-unknown-package-name'."
   (or (jde-package-best-package-candidate
-       (jde-package-seach-package-directories))
+       (jde-package-search-package-directories))
       jde-package-unknown-package-name))
 
 
Index: lisp/jde-xref.el
===================================================================
--- lisp/jde-xref.el	(revision 220)
+++ lisp/jde-xref.el	(working copy)
@@ -190,7 +190,12 @@
     (when (and (eq major-mode 'jde-mode) jde-sourcepath)
       (let ((first-prefix (car (split-string (jde-parse-get-package-name)
 					     "\\."))) (prefixes))
-	(dolist (path (remove-if-not (lambda (path) (file-exists-p path)) jde-sourcepath) prefixes)
+	(dolist (path (remove-if-not
+				   (lambda (path)
+					 (file-exists-p path))
+				   (jde-expand-wildcards-and-normalize jde-sourcepath
+													   'jde-sourcepath))
+				  prefixes)
 	  (when (member first-prefix (directory-files path nil "[^.]$"))
 	    (message (concat "path = " path))
 	    (add-to-list 'prefixes (get-prefix path first-prefix))))))))
Index: lisp/jde.el
===================================================================
--- lisp/jde.el	(revision 220)
+++ lisp/jde.el	(working copy)
@@ -542,7 +542,7 @@
 source files corresponding to class files.  When entering paths in the
 custom buffer, enter each path as a separate item in a separate edit
 field. Do NOT put more than one path in the same edit field. You'll
-only confuse JDE.  Paths may contain environment variables."
+only confuse JDE.  Paths may contain environment variables or wildcards."
   :group 'jde-project
   :type '(repeat (file :tag "Path")))
 
@@ -1483,6 +1483,30 @@
     (setq p (jde-convert-cygwin-path p))
     p))
 
+(defcustom jde-expand-wildcards-in-paths-p t
+  "Expands entries in the 'jde-sourcepath which are wildcards patterns into a list of matching files or directories which are interpolated into the sourcepath list."
+   :group 'jde-project
+   :type 'boolean)
+
+(defun jde-expand-wildcards-and-normalize (path &optional symbol)
+  "Expand any entries with wildcard patterns in path and interpolate them into the result"
+  (if jde-expand-wildcards-in-paths-p
+      (mapcan
+       (lambda (path)
+	 (let ((exp-paths (file-expand-wildcards path)))
+	   (if exp-paths exp-paths (list path))))
+       (jde-normalize-paths path symbol))
+    (jde-normalize-paths path symbol)
+    ))
+
+(defmacro jde-normalize-paths (pathlist &optional symbol)
+  "Normalize all paths of the list PATHLIST and returns a list with the
+expanded paths."
+  `(mapcar (lambda (path)
+			 (jde-normalize-path path ,symbol))
+		   ,pathlist))
+
+
 (defun jde-directory-files-recurs (dir &optional include-regexp)
   "Get all the files in DIR, and any subdirectories of DIR, whose
 names match INCLUDE-REGEXP."
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.