axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "marc fleury" <marc.fle...@jboss.org>
Subject RE: Emacs import cleanup utility - RE: More Fixes for imports.
Date Thu, 04 Oct 2001 17:14:10 GMT
righteous alright!

and if you had the emacs commands to run it on a tree recursively that would
be great (excuse my ignorance in emacs)

thanks

marcf

|-----Original Message-----
|From: Mark Roder [mailto:mroder@wamnet.com]
|Sent: Thursday, October 04, 2001 12:56 PM
|To: 'axis-dev@xml.apache.org'
|Subject: Emacs import cleanup utility - RE: More Fixes for imports.
|
|
|
|Here is some emacs functions to clean up imports in a java file.
|
|Disclaimer - works good enough for me, your results ????
|
|
|;;;
|;;; Java import cleanup
|;;;
|(defconst java-import-regexp
|  "^import")
|(defconst java-blank-line-regexp
|  "[ \t]*$")
|(defconst java-import-class-regexp
|  "\\(^import[ \t]+\\([a-zA-Z0-9_]+\\.\\)+\\)\\([A-Z][a-zA-Z0-9_]*\\);")
|
|(defun java-fix-imports ()
|  (interactive "")
|  (save-excursion
|    (goto-char (point-min))
|    (if (re-search-forward java-import-regexp nil t)
|        (progn
|          (beginning-of-line)
|          (let ((start (point))
|                end
|                match-string)
|
|            ;; bracket the import statements, deleting any blank lines
|            (while (or (looking-at java-import-regexp)
|                       (looking-at java-blank-line-regexp))
|              (if (looking-at java-blank-line-regexp)
|                  (kill-line)
|                (beginning-of-line 2))
|              )
|            (setq end (point))
|
|            ;; sort the imports and restore the blank line after the last
|one.
|            (sort-lines nil start end)
|            (open-line 1)
|
|            ;; Walk through the imports, separate them by package
|name,  and
|            ;; validate them.  Comment out the unused ones.
|            (goto-char start)
|            (while (looking-at java-import-class-regexp)
|              (let ((package (match-string 1))
|                    (class (match-string 3)))
|                (if (null
|                     (save-excursion
|                       (beginning-of-line 2)
|                       (word-search-forward class nil t)))
|                    (insert "//remove//"))
|                (beginning-of-line 2)
|                (if (null
|                     (looking-at package))
|                    (newline-and-indent))
|                )
|              )
|            )
|          )
|      ;; there aren't any import statements here
|      )
|    )
|  )
|
|
|;;;
|;;; - used after java-fix-import to remove the bad imports
|(defun java-fix-imports-remove-bad-imports()
|        "Remove bad imports that were generated with
|java-fix-imports-buffer"
|        (interactive)
|        (replace-regexp "^//remove//import.*$" "" )
|        (java-fix-imports))
|
|
|
|
|
|
|
|-----Original Message-----
|From: marc fleury
|To: axis-dev@xml.apache.org
|Sent: 10/4/01 8:19 AM
|Subject: RE: More Fixes for imports.
|
||Last go around, I rejected conflicts which were simply due to
|reordering.
||And manually applied fixes to conflicts which were substantive.
||
||This patch does simply reorder some imports, but more importantly it
||removes a fair number of unnecessary ones.
|
|Are you saying you have a tool that cleans up the imports that are not
|used?
|
|Can you share that?  As an ANT script? That would be righteous...
|
|marcf
|
||
||It also, to my surpise, replaces specific swing imports with "*" in the
||case of TCPMon.
||
||Clearly there appears to be a tool involved, and a threshhold being
||exceeded.  Dims - care to share with us how you did this magic?
||
||- Sam Ruby
||


Mime
View raw message