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 
  99        (setq variables (cdr variables))))
 100    (if (= size 0)
 101        (setq method 
 102              (concat method ")\";\n}\n")))
 103 
 104    (insert method))
 105 
 106  (jde-wiz-indent (point)))
 107 
 108 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 109 ;;                                                                               ;;
 110 ;;    jde-wiz-constructor - by yoonforh                                          ;;
 111 ;;                                                                               ;;
 112 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 113 
 114 (defun jde-wiz-constructor()
 115   "Generates a constructor() method for tbe class at point. The method
 116 returns a string comprising the values of the member variables defined
 117 by the class."
 118  (interactive)
 119  (let* ((class-name 
 120          (jde-parse-get-unqualified-name
 121           (jde-parse-get-class-at-point)))
 122         (variables 
 123          (semantic-find-nonterminal-by-token 
 124           'variable 
 125           (jde-wiz-get-class-parts 
 126            class-name 
 127            (semantic-find-nonterminal-by-token 
 128             'type 
 129             (semantic-bovinate-toplevel t)
 130             ))))
 131         (method
 132          (concat
 133           "public " class-name "("))
 134         (body)
 135         )
 136 
 137    (setq variables (jde-wiz-filter-variables-by-typemodifier variables))
 138 
 139    (if jde-wiz-tostring-sort-variables
 140        (setq variables (semantic-sort-tokens-by-name-increasing variables)))
 141 
 142    (setq size (length variables))
 143 
 144    (while variables
 145      (let* ((var (car variables))
 146            (name (semantic-token-name var)) ;;variable name
 147            (type (semantic-token-type var)) ;;variable type i.e. boolean
 148            (staticp
 149             (member "static"
 150                     (semantic-token-variable-modifiers var))) ;;is it static
 151            (finalp
 152             (member "final"
 153                    (semantic-token-variable-modifiers var)))) ;;is it final
 154 
 155        (if (or (not staticp) jde-wiz-tostring-static-members)
 156            (progn 
 157                    (if (> (length variables) 1)
 158                        (setq method (concat method type " " name ", "))
 159                      (setq method 
 160                            (concat method type " " name (if jde-gen-k&r ") {\n" ")\n{\n")))
 161                      )
 162                    (setq body (concat body "this." name " = " name ";\n"))
 163                    ))
 164        (if staticp (setq size (- size 1)))
 165        (if finalp (setq size (- size 1)))
 166 
 167        (setq variables (cdr variables))))
 168    (if (= size 0)
 169        (setq method 
 170              (concat method (if jde-gen-k&r ") {\n" ")\n{\n"))))
 171    (setq method 
 172          (concat method body "}\n"))
 173 
 174    (insert method))
 175 
 176  (jde-wiz-indent (point)))
 177 
 178 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 179 ;;                                                                               ;;
 180 ;;    jde-wiz-log-method - by yoonforh                                           ;;
 181 ;;                                                                               ;;
 182 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 183 ;;;###autoload
 184 (defun jde-wiz-log-method()
 185   "insert logger statement of a method or constructor"
 186   (interactive)
 187   (if (not (eq major-mode 'jde-mode))
 188       (error "Major mode must be 'jde-mode'"))
 189   (let ((found (jde-yoonforh-nonterminal-at-line)))
 190     (if (not found)
 191         (error "No tag found at point")
 192       (let* ((modifiers  (semantic-tag-modifiers found))
 193             (type       (semantic-tag-type               found))
 194             (name       (semantic-tag-name               found))
 195             (arguments       (semantic-tag-function-arguments found))
 196             (throws     (semantic-tag-function-throws    found))
 197         (string
 198          (concat
 199           "if (logger.isLoggable(Level.FINEST))"
 200           (if jde-gen-k&r " {\n" "\n{\n")
 201           "logger.finest(\""
 202           name
 203           "(")))
 204 
 205         (setq size (length arguments))
 206 
 207         (while arguments
 208           (let* ((arg (car arguments))
 209                  (name (semantic-tag-name arg)) ;;argument name
 210                  (type (semantic-tag-type arg)) ;;argument type i.e. boolean
 211                  )
 212 
 213             (if (> (length arguments) 1)
 214                 (setq string (concat string name " - \" + " name " + \", "))
 215               (setq string 
 216                     (concat string name " - \" + " name " + \")\");\n}\n\n")))
 217 
 218             (setq arguments (cdr arguments))))
 219         (if (= size 0)
 220             (setq string
 221                   (concat string ")\");\n}\n\n")))
 222         (insert string)
 223         ))
 224 
 225     (jde-wiz-indent (point))
 226     ))
 227 
 228 (defun jde-yoonforh-nonterminal-at-line ()
 229   "Search the bovine table for the tag at the current line."
 230   (save-excursion
 231     ;; Preserve current tags when the lexer fails (when there is an
 232     ;; unclosed block or an unterminated string for example).
 233     (let ((semantic-flex-unterminated-syntax-end-function
 234            #'(lambda (syntax &rest ignore)
 235                (throw 'jde-yoonforh-flex-error syntax))))
 236       (catch 'jde-yoonforh-flex-error
 237         (semantic-fetch-tags))))
 238   (save-excursion
 239     ;; Move the point to the first non-blank character found.  Skip
 240     ;; spaces, tabs and newlines.
 241     (beginning-of-line)
 242     (forward-comment (point-max))
 243     (semantic-current-tag)))
 244 
 245 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 246 ;;                                                                               ;;
 247 ;;    jde-wiz-logger-decl - by yoonforh                                          ;;
 248 ;;                                                                               ;;
 249 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 250 (defun jde-wiz-logger-decl()
 251   "insert logger declaration statement of current class"
 252   (interactive)
 253   (if (not (eq major-mode 'jde-mode))
 254       (error "Major mode must be 'jde-mode'"))
 255   (let* ((class-name 
 256          (jde-parse-get-unqualified-name
 257           (jde-parse-get-class-at-point)))
 258         (package (jde-wiz-get-package-name)))
 259     (progn
 260       (if (not package)
 261           (setq string (concat "private static Logger logger = Logger.getLogger(" class-name ".class.getName());\n\n"))
 262          (setq string (concat "private static final Logger logger = Logger.getLogger(\"" package "\");\n\n"))
 263 ;;        (setq string (concat "private static Logger logger = Logger.getLogger(" class-name ".class.getPackage().getName());\n\n"))
 264         (insert string)
 265         (jde-wiz-indent (point))
 266       )
 267     ))
 268 )
 269 
 270 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 271 ;;                                                                               ;;
 272 ;;    jde-wiz-assign-args - by yoonforh                                          ;;
 273 ;;                                                                               ;;
 274 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 275 ;;;###autoload
 276 (defun jde-wiz-assign-args()
 277   "insert assign statements for each args of a method or constructor"
 278   (interactive)
 279   (if (not (eq major-mode 'jde-mode))
 280       (error "Major mode must be 'jde-mode'"))
 281   (let ((found (jde-yoonforh-nonterminal-at-line)))
 282     (if (not found)
 283         (error "No tag found at point")
 284       (let* ((modifiers  (semantic-tag-modifiers found))
 285             (type       (semantic-tag-type               found))
 286             (name       (semantic-tag-name               found))
 287             (arguments       (semantic-tag-function-arguments found))
 288             (throws     (semantic-tag-function-throws    found)))
 289         (while arguments
 290           (let* ((arg (car arguments))
 291                  (name (semantic-tag-name arg)) ;;argument name
 292                  (type (semantic-tag-type arg)) ;;argument type i.e. boolean
 293                  )
 294 
 295             (insert (concat "this." name " = " name ";\n"))
 296             (setq arguments (cdr arguments))))
 297         ))
 298 
 299     (jde-wiz-indent (point))
 300     ))
 301 
 302 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 303 ;;                                                                               ;;
 304 ;;    jde-wiz-serial-ver - by yoonforh                                           ;;
 305 ;;                                                                               ;;
 306 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 307 (defun jde-wiz-serial-ver()
 308   "insert serialver statement of current class"
 309   (interactive)
 310   (if (not (eq major-mode 'jde-mode))
 311       (error "Major mode must be 'jde-mode'"))
 312   (let* ((class-name 
 313           (jde-parse-get-unqualified-name
 314            (jde-parse-get-class-at-point)))
 315          (package (jde-wiz-get-package-name))
 316          )
 317     (progn
 318       (setq serial-ver (jde-jeval
 319                         (concat "print(\"    private static final long serialVersionUID = \" + java.io.ObjectStreamClass.lookup(Class.forName(\""
 320                                 (if (not package)
 321                                     class-name
 322                                   (concat package "." class-name))
 323                                 "\")).getSerialVersionUID() + \"L;\\n\");")
 324                         ))
 325       (if (= 0 (length serial-ver))
 326           (error "Cannot get serial version value")
 327         (insert serial-ver))
 328       (jde-wiz-indent (point))
 329       )
 330     )
 331   )
 332 
 333 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 334 ;;                                                                               ;;
 335 ;;    jde-wiz-delegate-impl - by yoonforh                                        ;;
 336 ;;                                                                               ;;
 337 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 338 ;;;###autoload
 339 (defun jde-wiz-delegate-impl()
 340   "insert impl delegate statement of a method or constructor"
 341   (interactive)
 342   (if (not (eq major-mode 'jde-mode))
 343       (error "Major mode must be 'jde-mode'"))
 344   (let ((found (jde-yoonforh-nonterminal-at-line)))
 345     (if (not found)
 346         (error "No tag found at point")
 347       (let* ((modifiers  (semantic-tag-modifiers found))
 348              (method-type       (semantic-tag-type               found))
 349              (method-name       (semantic-tag-name               found))
 350              (arguments       (semantic-tag-function-arguments found))
 351              (throws     (semantic-tag-function-throws    found))
 352              )
 353         (if (not (string= method-type "void"))
 354             (setq string (concat "return impl." method-name "("))
 355           (setq string (concat "impl." method-name "(")))
 356 
 357         (setq size (length arguments))
 358 
 359         (while arguments
 360           (let* ((arg (car arguments))
 361                  (name (semantic-tag-name arg)) ;;argument name
 362                  (type (semantic-tag-type arg)) ;;argument type i.e. boolean
 363                  )
 364             (if (> (length arguments) 1)
 365                 (setq string (concat string name ", "))
 366               (setq string 
 367                     (concat string name  ");")))
 368 
 369             (setq arguments (cdr arguments))))
 370         (if (= size 0)
 371             (setq string
 372                   (concat string ");")))
 373         (insert string)
 374         ))
 375 
 376     (jde-wiz-indent (point))
 377     ))
 378 
 379 (global-set-key [?\C-c?\C-v?l] 'jde-wiz-log-method)
 380 (global-set-key [?\C-c?\C-v?s] 'jde-wiz-tostring)
 381 (global-set-key [?\C-c?\C-v?a] 'jde-wiz-assign-args)
 382 (global-set-key [?\C-c?\C-v?c] 'jde-wiz-constructor)
 383 (global-set-key [?\C-c?\C-v?p] 'jde-wiz-logger-decl)
 384 (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