Re: Bugs introduced that affected jde-import-all (the patch to jde-import.el)

"Jeff Peck" <[email protected]>
Newsgroups gmane.emacs.jdee.devel
Message-ID <9D8628214EEE415DB8F8D61D45DB987E@blue>
oops, due to mailer confusion, the patch attachment was dropped.
included herein.

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev

_______________________________________________
jdee-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jdee-devel
jde-import-insertion.patch (application/octet-stream, 3.9 KB)
Index: lisp/jde-import.el
===================================================================
--- lisp/jde-import.el	(revision 191)
+++ lisp/jde-import.el	(working copy)
@@ -213,7 +213,7 @@
 	    (throw 'found import))))))
 
 (defun jde-import-get-import-insertion-point ()
-   "Determine where to insert an import statement.
+  "Determine where to insert an import statement.
 If the buffer contains an import statement, return
 the beginning of the next line; otherwise, if
 the buffer contains a package statement, insert
@@ -222,36 +222,34 @@
 contains a class definition, return the beginning
 of the line before the class definition; otherwise,
 return the beginning of the buffer."
-   (let* ((tags (semantic-fetch-tags))
-	  (import-tag
-	   (car (last (semantic-brute-find-tag-by-class
-		       'include tags))))
-	  (package-tag (car (semantic-brute-find-tag-by-class
-			     'package tags)))
-	  (class-tag (car (semantic-brute-find-tag-by-class
-			   'type tags)))
-	  insertion-point)
-     (cond (import-tag
-	    (setq insertion-point (+ (semantic-tag-end import-tag) 1)))
-	   (package-tag
-	    (save-excursion
-	      (goto-char (semantic-tag-end package-tag))
-	      (forward-line)
-	      (insert "\n")
-	      (setq insertion-point (point))))
-	   (class-tag
-	    (setq insertion-point
-		  (let ((comment-token (semantic-documentation-for-tag
-					class-tag 'lex)))
-		    (if comment-token
-			(semantic-lex-token-start comment-token)
-		      (semantic-tag-start class-tag)))))
-	   (t
-	    (setq insertion-point 1)))
-     (save-excursion
-       (goto-char insertion-point)
-       (unless (and (bolp) (eolp)) (insert "\n")))
-     insertion-point))
+  (flet ((insertion-point-after (tag-end)
+	  (save-excursion
+	    (goto-char tag-end)
+	    (if (eolp) (forward-char 1)(forward-line 1)) ;skip comment
+	    (unless (bolp) (insert "\n"))		 ;open empty line
+	    (point)
+	    )))
+    (let* ((tags (semantic-fetch-tags))
+	   (import-tag (car
+			(last (semantic-brute-find-tag-by-class
+			       'include tags))))
+	   (package-tag (car (semantic-brute-find-tag-by-class
+			      'package tags)))
+	   (class-tag (car (semantic-brute-find-tag-by-class
+			    'type tags)))
+	   )
+      (cond (import-tag
+	     (insertion-point-after (semantic-tag-end import-tag)))
+	    (package-tag
+	     (insertion-point-after (semantic-tag-end package-tag)))
+	    (class-tag
+	     (let ((comment-token (semantic-documentation-for-tag
+				   class-tag 'lex)))
+	       (if comment-token
+		   (semantic-lex-token-start comment-token)
+		 (semantic-tag-start class-tag))))
+	    (t 1))
+      )))
 
 (defun jde-import-import (class)
   "*Insert an import statement for a class in the current buffer.
@@ -402,20 +400,22 @@
 (defun jde-import-insert-imports-into-buffer (new-imports &optional exclude)
   "Inserts imports into the correct place in the buffer."
   (save-excursion
-    (goto-char (jde-import-get-import-insertion-point))
+    (goto-char (jde-import-get-import-insertion-point)) ;
     (if (not jde-xemacsp) (deactivate-mark))
     (if exclude
       (setq new-imports (jde-import-exclude-imports new-imports)))
     (loop for new-import in new-imports do
-	  (when (> (length new-import) 0) ;; added to avoid insert empty import statements.
-	    (insert
-	     (concat "import " new-import ";\n"))
+	  (when (> (length new-import) 0) ; added to avoid insert empty import statements.
+	    (insert (concat "import " new-import ";\n"))
 	    (message "Imported %s" new-import)))
     (if jde-import-auto-collapse-imports
-	(let (jde-import-auto-collapse-imports) ;; setting this to avoid infinite recursion
+	(let (jde-import-auto-collapse-imports) ; setting this to avoid infinite recursion
 	  (jde-import-collapse-imports)))
     (if jde-import-auto-sort
-	(funcall jde-import-auto-sort-function))))
+	(funcall jde-import-auto-sort-function))
+    (semantic-fetch-tags)
+    (semantic-parse-changes)
+    ))
 
 
 (defun jde-import-already-imports-class (class-name existing-imports)
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.