JDE for Emacs

JDEE Resources

using unzip with JDEE in win32

Should set archive-zip-use-pkzip to be nil before loading jde. The order is important especially if the jde version is 2.3.5 or later

   1 ;; should come before jde loaded
   2 ;;  use unzip instead of pkunzip
   3 (setq archive-zip-use-pkzip nil)
   4 
   5 ;; ...
   6 ;; ...
   7 (require 'jde)

My JDEE emacs lisp functions

   1 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   2 ;;                                                                               ;;
   3 ;;    ToString Wizard - yoonforh edition                                         ;;
   4 ;;                                                                               ;;
   5 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   6 
   7 (defcustom jde-wiz-tostring-sort-variables nil
   8   "*Specifies whether or not to sort the list of variables in the
   9   generated method or list them in the order defined in the file."
  10   :group 'jde-wiz
  11   :type 'boolean)
  12 
  13 (defcustom jde-wiz-tostring-stringbuffer-size "100"
  14   "*Specifies the initial size of the StringBuffer used to create the
  15   result for the toString().  It is best to set this to a value large
  16   enough for most of your work to prevent expansion of the
  17   StringBuffer at runtime.  You can always change the value in the
  18   generated code to a smaller or larger one as needed."
  19   :group 'jde-wiz-tostring
  20   :type 'string)
  21 
  22 (defcustom jde-wiz-tostring-variable-separator "\", \""
  23   "*Specifies the string between each variable to separate them.
  24   Examples: 2 spaces (the default), a comma and a space, newline, or a
  25   method call (as long as the return value is a String).
  26 
  27   Note: Remember this must result in a String in Java!"
  28   :group 'jde-wiz-tostring
  29   :type 'string)
  30 
  31 (defcustom jde-wiz-tostring-static-members nil
  32   "If on (nonnil), `jde-wiz-tostring' generates information of 
  33  static members of the class in the current buffer."
  34   :group 'jde-wiz
  35   :type 'boolean)
  36 
  37 (defun jde-wiz-tostring()
  38   "Generates a toString() method for tbe class at point. The method
  39 returns a string comprising the values of the member variables defined
  40 by the class. The string lists the variables in alphabetical 
  41 order if `jde-wiz-tostring-sort-variables' is on. The string uses the
  42 string specified by `jde-wiz-tostring-variable-separator' to separate
  43 the variables. The generated method uses a string buffer of the size
  44 specified by `jde-wiz-tostring-stringbuffer-size' to build the string."
  45  (interactive)
  46  (let* ((class-name 
  47          (jde-parse-get-unqualified-name
  48           (jde-parse-get-class-at-point)))
  49         (variables 
  50          (semantic-find-nonterminal-by-token 
  51           'variable 
  52           (jde-wiz-get-class-parts 
  53            class-name 
  54            (semantic-find-nonterminal-by-token 
  55             'type 
  56             (semantic-bovinate-toplevel t)
  57             ))))
  58         (method
  59          (concat
  60           "/**\n"
  61           " * {@inheritDoc}\n"
  62           " */\n"
  63           "public String toString()"
  64           (if jde-gen-k&r " {\n" "\n{\n")
  65           "return \"" class-name "(")))
  66 
  67    (setq variables (jde-wiz-filter-variables-by-typemodifier variables))
  68 
  69    (if jde-wiz-tostring-sort-variables
  70        (setq variables (semantic-sort-tokens-by-name-increasing variables)))
  71 
  72    (setq size (length variables))
  73 
  74    (while variables
  75      (let* ((var (car variables))
  76            (name (semantic-token-name var)) ;;variable name
  77            (type (semantic-token-type var)) ;;variable type i.e. boolean
  78            (staticp
  79             (member "static"
  80                     (semantic-token-variable-modifiers var))) ;;is it static
  81            (finalp
  82             (member "final"
  83                    (semantic-token-variable-modifiers var)))) ;;is it final
  84 
  85        (if (or (not staticp) jde-wiz-tostring-static-members)
  86            (if (> (length variables) 1)
  87                (setq method (concat method name " - \" + " name "\n+ \", "))
  88              (setq method 
  89                    (concat method name " - \" + " name "\n+ \")\";\n}\n")))
  90          (progn
  91            (setq size (- size 1))
  92            (if (= (length variables) 1)
  93                (setq method ;; remove preceding ", "
  94                      (concat (substring method 0 (- (length method) 2)) ")\";\n}\n"))
  95                )
  96            )
  97          )
  98 ;;       (setq method (concat method "[" (number-to-string (length variables)) "]["(number-to-string size) "]"))
  99 
 100        (setq variables (cdr variables))))
 101 ;;   (setq method (concat method "[" (number-to-string size) "]"))
 102    (if (= size 0)
 103        (setq method 
 104              (concat method ")\";\n}\n")))
 105 
 106    (insert method))
 107 
 108  (jde-wiz-indent (point)))
 109 
 110 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 111 ;;                                                                               ;;
 112 ;;    jde-wiz-constructor - by yoonforh                                          ;;
 113 ;;                                                                               ;;
 114 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 115 
 116 (defun jde-wiz-constructor()
 117   "Generates a constructor() method for tbe class at point. The method
 118 returns a string comprising the values of the member variables defined
 119 by the class."
 120  (interactive)
 121  (let* ((class-name 
 122          (jde-parse-get-unqualified-name
 123           (jde-parse-get-class-at-point)))
 124         (variables 
 125          (semantic-find-nonterminal-by-token 
 126           'variable 
 127           (jde-wiz-get-class-parts 
 128            class-name 
 129            (semantic-find-nonterminal-by-token 
 130             'type 
 131             (semantic-bovinate-toplevel t)
 132             ))))
 133         (method
 134          (concat
 135           "public " class-name "("))
 136         (body)
 137         )
 138 
 139    (setq variables (jde-wiz-filter-variables-by-typemodifier variables))
 140 
 141    (if jde-wiz-tostring-sort-variables
 142        (setq variables (semantic-sort-tokens-by-name-increasing variables)))
 143 
 144    (setq size (length variables))
 145 
 146    (while variables
 147      (let* ((var (car variables))
 148            (name (semantic-token-name var)) ;;variable name
 149            (type (semantic-token-type var)) ;;variable type i.e. boolean
 150            (staticp
 151             (member "static"
 152                     (semantic-token-variable-modifiers var))) ;;is it static
 153            (finalp
 154             (member "final"
 155                    (semantic-token-variable-modifiers var)))) ;;is it final
 156 
 157        (if (or (not staticp) jde-wiz-tostring-static-members)
 158            (progn 
 159                    (if (> (length variables) 1)
 160                        (setq method (concat method type " " name ", "))
 161                      (setq method 
 162                            (concat method type " " name (if jde-gen-k&r ") {\n" ")\n{\n")))
 163                      )
 164                    (setq body (concat body "this." name " = " name ";\n"))
 165                    ))
 166        (if staticp (setq size (- size 1)))
 167        (if finalp (setq size (- size 1)))
 168 
 169        (setq variables (cdr variables))))
 170 ;;   (setq method (concat method "[" (number-to-string size) "]"))
 171    (if (= size 0)
 172        (setq method 
 173              (concat method (if jde-gen-k&r ") {\n" ")\n{\n"))))
 174    (setq method 
 175          (concat method body "}\n"))
 176 
 177    (insert method))
 178 
 179  (jde-wiz-indent (point)))
 180 
 181 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 182 ;;                                                                               ;;
 183 ;;    jde-wiz-log-method - by yoonforh                                           ;;
 184 ;;                                                                               ;;
 185 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 186 ;;;###autoload
 187 (defun jde-wiz-log-method()
 188   "insert logger statement of a method or constructor"
 189   (interactive)
 190   (if (not (eq major-mode 'jde-mode))
 191       (error "Major mode must be 'jde-mode'"))
 192   (let ((found (jde-yoonforh-nonterminal-at-line)))
 193     (if (not found)
 194         (error "No tag found at point")
 195       (let* ((modifiers  (semantic-tag-modifiers found))
 196             (type       (semantic-tag-type               found))
 197             (name       (semantic-tag-name               found))
 198             (arguments       (semantic-tag-function-arguments found))
 199             (throws     (semantic-tag-function-throws    found))
 200         (string
 201          (concat
 202           "if (logger.isLoggable(Level.FINEST))"
 203           (if jde-gen-k&r " {\n" "\n{\n")
 204           "logger.finest(\""
 205           name
 206           "(")))
 207 
 208         (setq size (length arguments))
 209 
 210         (while arguments
 211           (let* ((arg (car arguments))
 212                  (name (semantic-tag-name arg)) ;;argument name
 213                  (type (semantic-tag-type arg)) ;;argument type i.e. boolean
 214                  )
 215 
 216             (if (> (length arguments) 1)
 217                 (setq string (concat string name " - \" + " name " + \", "))
 218               (setq string 
 219                     (concat string name " - \" + " name " + \")\");\n}\n\n")))
 220 
 221             (setq arguments (cdr arguments))))
 222 ;;        (setq string (concat string "[" (number-to-string size) "]"))
 223         (if (= size 0)
 224             (setq string
 225                   (concat string ")\");\n}\n\n")))
 226         (insert string)
 227         ))
 228 
 229     (jde-wiz-indent (point))
 230     ))
 231 
 232 (defun jde-yoonforh-nonterminal-at-line ()
 233   "Search the bovine table for the tag at the current line."
 234   (save-excursion
 235     ;; Preserve current tags when the lexer fails (when there is an
 236     ;; unclosed block or an unterminated string for example).
 237     (let ((semantic-flex-unterminated-syntax-end-function
 238            #'(lambda (syntax &rest ignore)
 239                (throw 'jde-yoonforh-flex-error syntax))))
 240       (catch 'jde-yoonforh-flex-error
 241         (semantic-fetch-tags))))
 242   (save-excursion
 243     ;; Move the point to the first non-blank character found.  Skip
 244     ;; spaces, tabs and newlines.
 245     (beginning-of-line)
 246     (forward-comment (point-max))
 247     (semantic-current-tag)))
 248 
 249 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 250 ;;                                                                               ;;
 251 ;;    jde-wiz-logger-decl - by yoonforh                                          ;;
 252 ;;                                                                               ;;
 253 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 254 (defun jde-wiz-logger-decl()
 255   "insert logger declaration statement of current class"
 256   (interactive)
 257   (if (not (eq major-mode 'jde-mode))
 258       (error "Major mode must be 'jde-mode'"))
 259   (let* ((class-name 
 260          (jde-parse-get-unqualified-name
 261           (jde-parse-get-class-at-point)))
 262         (package (jde-wiz-get-package-name)))
 263     (progn
 264       (if (not package)
 265           (setq string (concat "private static Logger logger = Logger.getLogger(" class-name ".class.getName());\n\n"))
 266          (setq string (concat "private static final Logger logger = Logger.getLogger(\"" package "\");\n\n"))
 267 ;;        (setq string (concat "private static Logger logger = Logger.getLogger(" class-name ".class.getPackage().getName());\n\n"))
 268         (insert string)
 269         (jde-wiz-indent (point))
 270       )
 271     ))
 272 )
 273 
 274 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 275 ;;                                                                               ;;
 276 ;;    jde-wiz-assign-args - by yoonforh                                          ;;
 277 ;;                                                                               ;;
 278 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 279 ;;;###autoload
 280 (defun jde-wiz-assign-args()
 281   "insert assign statements for each args of a method or constructor"
 282   (interactive)
 283   (if (not (eq major-mode 'jde-mode))
 284       (error "Major mode must be 'jde-mode'"))
 285   (let ((found (jde-yoonforh-nonterminal-at-line)))
 286     (if (not found)
 287         (error "No tag found at point")
 288       (let* ((modifiers  (semantic-tag-modifiers found))
 289             (type       (semantic-tag-type               found))
 290             (name       (semantic-tag-name               found))
 291             (arguments       (semantic-tag-function-arguments found))
 292             (throws     (semantic-tag-function-throws    found)))
 293         (while arguments
 294           (let* ((arg (car arguments))
 295                  (name (semantic-tag-name arg)) ;;argument name
 296                  (type (semantic-tag-type arg)) ;;argument type i.e. boolean
 297                  )
 298 
 299             (insert (concat "this." name " = " name ";\n"))
 300             (setq arguments (cdr arguments))))
 301 ;;        (setq string (concat string "[" (number-to-string size) "]"))
 302         ))
 303 
 304     (jde-wiz-indent (point))
 305     ))
 306 
 307 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 308 ;;                                                                               ;;
 309 ;;    jde-wiz-serial-ver - by yoonforh                                           ;;
 310 ;;                                                                               ;;
 311 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 312 (defun jde-wiz-serial-ver()
 313   "insert serialver statement of current class"
 314   (interactive)
 315   (if (not (eq major-mode 'jde-mode))
 316       (error "Major mode must be 'jde-mode'"))
 317   (let* ((class-name 
 318           (jde-parse-get-unqualified-name
 319            (jde-parse-get-class-at-point)))
 320          (package (jde-wiz-get-package-name))
 321          )
 322     (progn
 323       (setq serial-ver (jde-jeval
 324                         (concat "print(\"    private static final long serialVersionUID = \" + java.io.ObjectStreamClass.lookup(Class.forName(\""
 325                                 (if (not package)
 326                                     class-name
 327                                   (concat package "." class-name))
 328                                 "\")).getSerialVersionUID() + \"L;\\n\");")
 329                         ))
 330       (if (= 0 (length serial-ver))
 331           (error "Cannot get serial version value")
 332         (insert serial-ver))
 333       (jde-wiz-indent (point))
 334       )
 335     )
 336   )
 337 
 338 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 339 ;;                                                                               ;;
 340 ;;    jde-wiz-delegate-impl - by yoonforh                                        ;;
 341 ;;                                                                               ;;
 342 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 343 ;;;###autoload
 344 (defun jde-wiz-delegate-impl()
 345   "insert impl delegate statement of a method or constructor"
 346   (interactive)
 347   (if (not (eq major-mode 'jde-mode))
 348       (error "Major mode must be 'jde-mode'"))
 349   (let ((found (jde-yoonforh-nonterminal-at-line)))
 350     (if (not found)
 351         (error "No tag found at point")
 352       (let* ((modifiers  (semantic-tag-modifiers found))
 353              (method-type       (semantic-tag-type               found))
 354              (method-name       (semantic-tag-name               found))
 355              (arguments       (semantic-tag-function-arguments found))
 356              (throws     (semantic-tag-function-throws    found))
 357 ;;              (string
 358 ;;               (concat
 359 ;;                "return impl."
 360 ;;                name
 361 ;;                "(")
 362 ;;               )
 363              )
 364         (if (not (string= method-type "void"))
 365             (setq string (concat "return impl." method-name "("))
 366           (setq string (concat "impl." method-name "(")))
 367 
 368         (setq size (length arguments))
 369 
 370         (while arguments
 371           (let* ((arg (car arguments))
 372                  (name (semantic-tag-name arg)) ;;argument name
 373                  (type (semantic-tag-type arg)) ;;argument type i.e. boolean
 374                  )
 375             (if (> (length arguments) 1)
 376                 (setq string (concat string name ", "))
 377               (setq string 
 378                     (concat string name  ");")))
 379 
 380             (setq arguments (cdr arguments))))
 381 ;;        (setq string (concat string "[" (number-to-string size) "]"))
 382         (if (= size 0)
 383             (setq string
 384                   (concat string ");")))
 385         (insert string)
 386         ))
 387 
 388     (jde-wiz-indent (point))
 389     ))
 390 
 391 (global-set-key [?\C-c?\C-v?l] 'jde-wiz-log-method)
 392 (global-set-key [?\C-c?\C-v?s] 'jde-wiz-tostring)
 393 (global-set-key [?\C-c?\C-v?a] 'jde-wiz-assign-args)
 394 (global-set-key [?\C-c?\C-v?c] 'jde-wiz-constructor)
 395 (global-set-key [?\C-c?\C-v?p] 'jde-wiz-logger-decl)
 396 (global-set-key [?\C-c?\C-v?d] 'jde-wiz-delegate-impl)

Binding for keymap jde-mode-map

As of JDEE 2.3.4

key             binding
---             -------

<f4>            html-script-release-region
C-c             Prefix Command
/               c-electric-slash
*               c-electric-star
,               c-electric-semi&comma
DEL             c-electric-backspace
C-d             c-electric-delete-forward
TAB             c-indent-command
ESC             Prefix Command
)               c-electric-paren
(               c-electric-paren
:               c-electric-colon
#               c-electric-pound
;               c-electric-semi&comma
}               c-electric-brace
{               c-electric-brace

C-c C-v         Prefix Command
C-c .           c-set-style
C-c C-t         c-toggle-auto-hungry-state
C-c C-s         c-show-syntactic-information
C-c C-o         c-set-offset
C-c C-d         c-toggle-hungry-state
C-c C-c         comment-region
C-c C-b         c-submit-bug-report
C-c C-a         c-toggle-auto-state
C-c C-\         c-backslash-region
C-c C-q         c-indent-defun
C-c C-u         c-up-conditional
C-c C-p         c-backward-conditional
C-c C-n         c-forward-conditional

ESC q           c-fill-paragraph
ESC j           c-indent-new-comment-line
ESC C-j         c-indent-new-comment-line
ESC e           c-end-of-statement
ESC a           c-beginning-of-statement
ESC C-q         c-indent-exp
ESC C-h         c-mark-function

C-c C-v .       jde-complete-in-line
C-c C-v C-.     jde-complete
C-c C-v C-]     jde-run-etrace-next
C-c C-v ESC     jde-run-etrace-prev
C-c C-v z       jde-import-all
C-c C-v t       jde-gen-try-catch-wrapper
C-c C-v o       jde-wiz-override-method
C-c C-v j       jde-javadoc-autodoc-at-line
C-c C-v i       jde-wiz-implement-interface
C-c C-v f       jde-gen-try-finally-wrapper
C-c C-v e       jde-wiz-extend-abstract-class
C-c C-v C-z     jde-import-find-and-import
C-c C-v C-y     jde-open-class-at-point
C-c C-v C-x     jde-show-superclass-source
C-c C-v C-w     jde-help-symbol
C-c C-v C-t     jde-jdb-menu-debug-applet
C-c C-v C-s     speedbar-frame-mode
C-c C-v C-r     jde-run
C-c C-v C-q     jde-wiz-update-class-list
C-c C-v C-p     jde-save-project
C-c C-v C-n     jde-help-browse-jdk-doc
C-c C-v C-l     jde-gen-println
C-c C-v C-k     jde-bsh-run
C-c C-v C-g     jde-open-class-at-point
C-c C-v C-f     jde-find
C-c C-v C-d     jde-debug
C-c C-v C-c     jde-compile
C-c C-v C-b     jde-build
C-c C-v C-a     jde-run-menu-run-applet

last edited 2006-07-20 18:05:55 by YoonKyungKoo