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-javadoc-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 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
229 ;; ;;
230 ;; jde-wiz-logger-decl - by yoonforh ;;
231 ;; ;;
232 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
233 (defun jde-wiz-logger-decl()
234 "insert logger declaration statement of current class"
235 (interactive)
236 (if (not (eq major-mode 'jde-mode))
237 (error "Major mode must be 'jde-mode'"))
238 (let* ((class-name
239 (jde-parse-get-unqualified-name
240 (jde-parse-get-class-at-point)))
241 (package (jde-wiz-get-package-name)))
242 (progn
243 (if (not package)
244 (setq string (concat "private static Logger logger = Logger.getLogger(" class-name ".class.getName());\n\n"))
245 (setq string (concat "private static Logger logger = Logger.getLogger(\"" package "\");\n\n"))
246 (insert string)
247 (jde-wiz-indent (point)))
248 )))
249
250 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
251 ;; ;;
252 ;; jde-wiz-assign-args - by yoonforh ;;
253 ;; ;;
254 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
255 ;;;###autoload
256 (defun jde-wiz-assign-args()
257 "insert assign statements for each args of a method or constructor"
258 (interactive)
259 (if (not (eq major-mode 'jde-mode))
260 (error "Major mode must be 'jde-mode'"))
261 (let ((found (jde-yoonforh-nonterminal-at-line)))
262 (if (not found)
263 (error "No tag found at point")
264 (let* ((modifiers (semantic-tag-modifiers found))
265 (type (semantic-tag-type found))
266 (name (semantic-tag-name found))
267 (arguments (semantic-tag-function-arguments found))
268 (throws (semantic-tag-function-throws found)))
269 (while arguments
270 (let* ((arg (car arguments))
271 (name (semantic-tag-name arg)) ;;argument name
272 (type (semantic-tag-type arg)) ;;argument type i.e. boolean
273 )
274
275 (insert (concat "this." name " = " name ";\n"))
276 (setq arguments (cdr arguments))))
277 ))
278
279 (jde-wiz-indent (point))
280 ))
281
282
283 (global-set-key [?\C-c?\C-v?l] 'jde-wiz-log-method)
284 (global-set-key [?\C-c?\C-v?s] 'jde-wiz-tostring)
285 (global-set-key [?\C-c?\C-v?a] 'jde-wiz-assign-args)
286 (global-set-key [?\C-c?\C-v?c] 'jde-wiz-constructor)
287 (global-set-key [?\C-c?\C-v?p] 'jde-wiz-logger-decl)
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