1 ;;; jde-gen.el -- Integrated Development Environment for Java.
4 ;; Author: Paul Kinnucan <paulk@mathworks.com>
5 ;; Maintainer: Paul Kinnucan
6 ;; Keywords: java, tools
8 ;; Copyright (C) 1997, 1998, 2000, 2001, 2002, 2003, 2004 Paul Kinnucan.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; Gnu Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
33 (defcustom jde-gen-k&r t
34 "*If non-nil, use braces in Original Kernighan & Ritchie Style.
35 The Creators of C started using brace placement style:
41 But there is also the alternative line-up style:
48 Setting this variable to t, uses K&R style in skeletons and tempaltes.
50 Note: According to the Java Code Convention [section 6.4], this value should
55 ; There must be some cleverer way to do this ...
56 (defun jde-gen-delete-preceding-whitespace ()
57 "Delete any syntactical whitespace (including newlines)
59 (while (and (not (bobp))
61 (re-search-backward "\\s-\\=" nil t)))
64 (defun jde-gen-extract-ids-from-params (params)
65 "Given a parameter lsit \"Type1 id1, Type2, id2, ...\" extract the
66 ids and return as \"id1, id2, ...\"."
71 (replace-in-string arg "^[ \t\n\f\l]+" "")
72 "[ \t\n\f\l]+$" ""))))
73 (split-string params "[,]") ", "))
75 (defun jde-gen-lookup-named (name)
76 "Lookup some saved data under the name NAME.
77 Returns the data if NAME was found, and nil otherwise."
78 (cdr (assq name tempo-named-insertions)))
80 (defun jde-gen-read-template (strings)
81 "Converts an autocode template represented as a list
82 of strings to a list of Lisp objects as required by
84 (let ((template-string "")
89 (concat template-string (nth i strings) "\n"))
92 (concat "'(" template-string ")"))
93 (eval (car (read-from-string template-string)))))
95 (defcustom jde-gen-buffer-boilerplate nil
96 "*Lines of boilerplate text to put at the head of a buffer template."
98 :type '(repeat (string :tag "Line")))
100 (defcustom jde-gen-boilerplate-function 'jde-gen-create-buffer-boilerplate
101 "*Specifes buffer boilerplate text function.
102 This variable specifies a function to create boilerplate text for
103 insertion at the head of Java source buffers generated by JDE
104 templates. The specified function should take no arguments and should
105 return a text string. The default value is
106 `jde-gen-create-buffer-boilerplate', which returns the lines of text
107 specified by `jde-gen-buffer-boilerplate'."
111 (defun jde-gen-create-buffer-boilerplate ()
112 "This function creates buffer boilerplate from the
113 variable `jde-gen-buffer-boilerplate'."
114 (if jde-gen-buffer-boilerplate
116 (n (length jde-gen-buffer-boilerplate))
120 (concat bp (elt jde-gen-buffer-boilerplate i) "\n"))
124 (defun jde-gen-get-extend-class ()
125 (let ((super-class (read-from-minibuffer "extends: ")))
126 (if (not (string= super-class ""))
128 (jde-import-find-and-import super-class)
129 (concat "extends " super-class " ")))))
131 (defcustom jde-gen-final-arguments t
132 "Specifies whether to add final modifiers to method arguments.
133 If this variable is t, `jde-gen-method-signature' automatically
134 adds final modifiers to each method argument."
138 (defcustom jde-gen-final-methods t
139 "Specifies whether to add final method modifier.
140 If this variable is t, `jde-gen-method-signature' automatically adds
141 the final method modifier. This option is ignored within final classes.
142 Note that anonymous classes are implicitly final."
146 (defun jde-gen-final-argument-modifier (method-args)
147 "Inserts the final modifier depending on `jde-gen-final-arguments'."
148 (if jde-gen-final-arguments
150 (arg-list (split-string method-args ",")))
151 (setq method-args "")
154 (if (string-match "\\<final\\>" arg)
155 (setq method-args (concat method-args comma arg))
159 (if (string-match "^[ \t]" arg) " ")
161 (if (string-match "^[^ \t]" arg) " ")
167 (defun jde-gen-final-method-modifier (method-modifiers)
168 "Insert final modifier according to `jde-gen-final-methods'."
169 (let ((class-info (jde-parse-get-class-modifiers)))
170 ;; Anonymous classes are implicitly final. See:
171 ;; Java Language specification, section 15.9.5.
172 ;; http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html
173 (unless (or (member "final" class-info) ; explicit final modifier?
176 (goto-char (cdar class-info))
177 (looking-at "new")))) ; anonymous class?
178 (if (and jde-gen-final-methods
179 (not (string-match "final" method-modifiers))
180 (not (string-match "private" method-modifiers))
181 (not (string-match "abstract" method-modifiers)))
182 ;; Find correct position according to
183 ;; Java Language specification, section 8.4.3.
184 ;; http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html
185 (let* ((pos (max (if (string-match "public" method-modifiers) (match-end 0) 0)
186 (if (string-match "protected" method-modifiers) (match-end 0) 0)
187 (if (string-match "static" method-modifiers) (match-end 0) 0)))
188 (left (substring method-modifiers 0 pos))
189 (right (substring method-modifiers pos)))
190 (setq method-modifiers (concat
192 (if (> (length left) 0) " ")
194 (if (and (= (length left) 0) (> (length right) 0)) " ")
198 (defmacro jde-gen-save-excursion (&rest body)
199 "Evaluate BODY within a let form.
200 Protects `tempo-marks', `tempo-named-insertions', `tempo-region-start'
201 and `tempo-region-stop' against modifications by invoked template.
202 Those tempo vars will be set to their default values.
203 This allows to invoke tempo-templates within tempo-templates
204 without having mutual interference of those templates.
208 (tempo-named-insertions)
209 (tempo-region-start (make-marker))
210 (tempo-region-stop (make-marker)))
214 (defun jde-gen-electric-brace (&optional padding)
215 "Insert a brace according to `jde-gen-k&r'.
216 Optional argument PADDING is inserted before brace
217 if jde-gen-k&r is enabled."
219 (if padding (insert padding))
221 (indent-according-to-mode)
224 (indent-according-to-mode)
228 (defun jde-gen-indent ()
229 "Indent current line if it is not empty.
230 Removes indentation if the current line contains only whitespaces.
231 The purpose of this function is to avoid trailing whitespaces
232 in generated java code. Returns nil."
235 (looking-at "\\s-+$"))
237 (if (not (and (bolp) (eolp)))
239 nil) ;; must return nil to prevent template insertion.
241 (defun jde-gen-blank-lines (n &optional m)
242 "Ensure exactly N blank lines.
243 Leaves point at the beginning of the line following blank lines.
244 If M is non-nil, (`forward-line' M) will be called after inserting.
245 If point is at the beginning of a non-blank line, blank lines will appear before that line.
246 If point is at the end of a non-blank line, blank lines will appear after that line.
247 If point is in the middle of a non-blank line, this line will be split at point.
248 Indentation and trailing whitespace of surrounding non-blank lines will stay unchanged.
251 (if (or (bolp) (eolp)
254 (looking-at "\\s-*$")))
256 (+ (point) (skip-chars-backward " \t\n") (skip-chars-forward " \t"))
257 (+ (point) (skip-chars-forward " \t\n") (skip-chars-backward " \t"))))
265 ; In order to avoid problems with recursive tempo-template invocations
266 ; interface generation has been split in two parts.
267 ; jde-gen-get-interface-implementation prompts for the
268 ; interface and stores point-marker and interface name in buffer local
269 ; variables. jde-gen-insert-interface-implementation is invoked after
270 ; the template for class or inner class and generates the interface
273 (defvar jde-gen-interface-to-gen nil
274 "Insertion marker and name (MARKER . NAME) of interface
275 implemented by the most recently generated class template.
276 Used by `jde-gen-get-interface-implementation' to
277 store name and location of interface to be inserted
278 by `jde-gen-insert-interface-implementation'.")
280 (defun jde-gen-get-interface-implementation (&optional insert-immediately)
281 "Prompts the user to enter the name of an interface
282 implemented by a class being generated by a tempo template.
283 If the user enters a name, stores the current point as marker in
284 the buffer and the interface name as a cons (MARKER . NAME)
285 in the global variable `jde-gen-interface-to-gen'. Otherwise
286 it sets this variable to nil. If INSERT-IMMEDIATELY is non-nil,
287 `jde-gen-insert-interface-implementation' will be called immediately
288 and jde-gen-interface-to-gen will be set to nil."
289 (let ((interface (read-from-minibuffer "implements: ")))
290 (if (not (string= interface ""))
292 (setq jde-gen-interface-to-gen
293 (cons (point-marker) interface))
294 (if insert-immediately
296 (jde-gen-insert-interface-implementation)
297 (setq jde-gen-interface-to-gen nil))))
298 (setq jde-gen-interface-to-gen nil)))
299 nil) ;; must return nil to prevent template insertion.
301 (defun jde-gen-insert-interface-implementation ()
302 "Generates the interface specified by the cdr of `jde-gen-interface-to-gen'
303 and inserts it in the current buffer at the location specified
304 by the car of `jde-gen-interface-to-gen'."
305 (if jde-gen-interface-to-gen
306 (let ((ins-pos (marker-position (car jde-gen-interface-to-gen)))
307 (interface (cdr jde-gen-interface-to-gen)))
310 (jde-wiz-implement-interface-internal interface)))))
312 (defun jde-gen-get-package-statement ()
313 (require 'jde-package)
314 (let* ((package-dir (jde-package-get-package-directory))
315 (suggested-package-name
317 (string= package-dir jde-package-unknown-package-name)
318 (string= package-dir ""))
320 (jde-package-convert-directory-to-package package-dir)))
322 (read-from-minibuffer "Package: " suggested-package-name)))
325 (not (string= package-name "")))
326 (format "package %s;\n\n" package-name))))
329 (defcustom jde-gen-method-signature-padding-1 ""
330 "String that comes just after the function name and just before
331 the opening parenthesis of the argument list for a method call or definition.
332 For example, if set to a single space [\" \"], then a generated method might
337 If not set, the same generated method would look like:
341 Note: According to the Java Code Convention [section 6.4], this value should
342 be the empty string."
347 (defcustom jde-gen-method-signature-padding-2 ""
348 "String which comes just after the opening parenthesis and just before
349 the closing parenthesis of an argument list for a method call or definition.
350 For example, if set to a single space [\" \"], then a generated method might
353 void setXxxx( boolean newValue ) {
355 If not set, the same generated method would look like:
357 void setXxxx(boolean newValue) {
359 Note: According to the Java Code Convention [section 6.4], this value should
360 be the empty string."
365 (defcustom jde-gen-method-signature-padding-3 " "
366 "String which comes just after the closing parenthesis of an
367 argument list for a method call or definition. For example, if set to
368 a single space [\" \"], then a generated method might look like:
370 void setXxxx(boolean newValue) {
372 If not set, the same generated method would look like:
374 void setXxxx(boolean newValue){
376 Note: According to the Java Code Convention [section 6.4], this value should
382 (defcustom jde-gen-conditional-padding-1 " "
383 "The string to be inserted between a conditional keyword (if, while, etc.)
384 and the opening parenthesis for its conditional expression:
386 <keyword><1>(<2><expression><2>)<3>{
390 where <1> is jde-gen-conditional-padding-1
391 and <2> is jde-gen-conditional-padding-2
392 and <3> is jde-gen-conditional-padding-3.
394 For example, if <1> is a space, <2> is nil and <3> is a space, then a while
395 clause might look like:
399 Note: According to the Java Code Convention [section 7.4], this value should
405 (defcustom jde-gen-conditional-padding-2 ""
406 "The string to be inserted before and after a conditional expression
407 between the parentheses. See `jde-gen-conditional-padding-1' for details.
409 Note: According to the Java Code Convention [section 7.4], this value should
410 be the empty string."
415 (defcustom jde-gen-conditional-padding-3 " "
416 "The string to be inserted after the closing parenthesis of the
417 conditional expression and before the opening brace. See
418 `jde-gen-conditional-padding-1' for details.
420 Note: According to the Java Code Convention [section 7.4], this value should
426 (defun jde-gen-method-signature (access type name arglist &optional throwslist)
427 "This function generates method signatures with a consistent format.
428 All jde-gen functions and/or templates should use this function when
429 creating Java methods and constructors.
431 The signature is of the format:
433 <access> <type> <name><1>(<2><arglist><2>) throws <throwslist><3>
435 where <1> is the value of jde-gen-method-signature-padding-1
436 and <2> is the value of jde-gen-method-signature-padding-2
437 and <3> is the value of jde-gen-method-signature-padding-3.
439 <3> will not be used if `jde-gen-k&r' is nil.
441 This function takes care of `jde-gen-final-methods' and
442 `jde-gen-final-arguments'. final modifiers will be added
443 according to those flags.
445 If a parameter to this function is empty or nil, then it is omitted
446 (as well as the corresponding padding, whitespace and/or Java keywords)."
448 (if (> (length type) 0) ; ordinary method?
449 (setq access (jde-gen-final-method-modifier access)))
452 (if (> (length access) 0)
454 ());; if no access (e.g. "public static"), then nothing
455 (if (> (length type) 0)
457 ());; if no type (e.g. "boolean" or "void"), then nothing
459 jde-gen-method-signature-padding-1
461 (if (> (length arglist) 0)
462 (concat jde-gen-method-signature-padding-2 (jde-gen-final-argument-modifier arglist)
463 jde-gen-method-signature-padding-2 )
466 (if (> (length throwslist) 0)
467 (concat " throws " throwslist)
470 jde-gen-method-signature-padding-3
474 ;;(makunbound 'jde-gen-class-buffer-template)
475 (defcustom jde-gen-class-buffer-template
477 "(funcall jde-gen-boilerplate-function)"
478 "(jde-gen-get-package-statement)"
479 "(progn (require 'jde-javadoc) (jde-javadoc-insert-start-block))"
480 "\" * Describe class \""
481 "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
483 "\" \" (jde-javadoc-insert-empty-line)"
484 "\" \" (jde-javadoc-insert-empty-line)"
485 "\" * Created: \" (current-time-string) 'n"
486 "\" \" (jde-javadoc-insert-empty-line)"
487 "\" \" (jde-gen-save-excursion (jde-javadoc-insert 'tempo-template-jde-javadoc-author-tag))"
488 "\" \" (jde-gen-save-excursion (jde-javadoc-insert 'tempo-template-jde-javadoc-version-tag))"
489 "\" \" (jde-javadoc-insert-end-block)"
491 "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
492 "\" \" (jde-gen-get-extend-class)"
493 "(jde-gen-electric-brace)"
496 "(if jde-gen-comments (concat \" // \""
497 " (file-name-sans-extension (file-name-nondirectory buffer-file-name))))"
499 ";; Here comes the stuff that needs a fully generated class."
500 ";; We jump back and add those things retrospectively."
501 "(progn (tempo-backward-mark)"
502 " (jde-gen-save-excursion"
503 " (jde-gen-get-interface-implementation t))"
504 " (jde-gen-save-excursion"
505 " (jde-wiz-gen-method \"public\" \"\""
506 " (file-name-sans-extension (file-name-nondirectory buffer-file-name)) \"\" \"\" \"\")))"
507 ";; Move to constructor body. Set tempo-marks to nil in order to prevent tempo moving to mark."
508 "(progn (re-search-forward \"^[ \\t]*$\") (setq tempo-marks nil) nil)")
509 "*Template for new Java class.
510 Setting this variable defines a template instantiation
511 command `jde-gen-class', as a side-effect."
513 :type '(repeat string)
514 :set '(lambda (sym val)
515 (tempo-define-template "java-class-buffer-template"
516 (jde-gen-read-template val)
518 "Insert a generic Java class buffer skeleton.")
519 (defalias 'jde-gen-class
522 (list 'tempo-template-java-class-buffer-template)
523 (list 'jde-gen-insert-interface-implementation)))
524 (set-default sym val)))
527 (defun jde-gen-class-buffer (file)
528 "Create a new Java buffer containing a class of the same name.
529 This command inserts the class template generated by `jde-gen-class'.
535 ;;(makunbound 'jde-gen-interface-buffer-template)
536 (defcustom jde-gen-interface-buffer-template
538 "(funcall jde-gen-boilerplate-function)"
539 "(jde-gen-get-package-statement)"
540 "(progn (require 'jde-javadoc) (jde-javadoc-insert-start-block))"
541 "\" * Describe interface \""
542 "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
544 "\" \" (jde-javadoc-insert-empty-line)"
545 "\" \" (jde-javadoc-insert-empty-line)"
546 "\" * Created: \" (current-time-string) 'n"
547 "\" \" (jde-javadoc-insert-empty-line)"
548 "\" \" (jde-gen-save-excursion (jde-javadoc-insert 'tempo-template-jde-javadoc-author-tag))"
549 "\" \" (jde-gen-save-excursion (jde-javadoc-insert 'tempo-template-jde-javadoc-version-tag))"
550 "\" \" (jde-javadoc-insert-end-block)"
551 "\"public interface \""
552 "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
553 "\" \" (jde-gen-get-extend-class)"
554 "(jde-gen-electric-brace)"
557 "(if jde-gen-comments (concat \" // \""
558 " (file-name-sans-extension (file-name-nondirectory buffer-file-name))))"
560 "*Template for new Java interface.
561 Setting this variable defines a template instantiation
562 command `jde-gen-interface', as a side-effect."
564 :type '(repeat string)
565 :set '(lambda (sym val)
566 (tempo-define-template "java-interface-buffer-template"
567 (jde-gen-read-template val)
569 "Insert a generic Java interface buffer skeleton.")
570 (defalias 'jde-gen-interface
573 (list 'tempo-template-java-interface-buffer-template)))
574 (set-default sym val)))
577 (defun jde-gen-interface-buffer (file)
578 "Create a new Java buffer containing an interface of the same name.
579 This command inserts the interface template generated by `jde-gen-interface'.
580 It then moves the point to the location of the first method."
585 ;;(makunbound 'jde-gen-console-buffer-template)
586 (defcustom jde-gen-console-buffer-template
588 "(funcall jde-gen-boilerplate-function)"
589 "(jde-gen-get-package-statement)"
590 "(progn (require 'jde-javadoc) (jde-javadoc-insert-start-block))"
591 "\" * Describe class \""
592 "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
594 "\" \" (jde-javadoc-insert-empty-line)"
595 "\" \" (jde-javadoc-insert-empty-line)"
596 "\" * Created: \" (current-time-string) 'n"
597 "\" \" (jde-javadoc-insert-empty-line)"
598 "\" \" (jde-gen-save-excursion (jde-javadoc-insert 'tempo-template-jde-javadoc-author-tag))"
599 "\" \" (jde-gen-save-excursion (jde-javadoc-insert 'tempo-template-jde-javadoc-version-tag))"
600 "\" \" (jde-javadoc-insert-end-block)"
601 "\"public final class \""
602 "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
603 "(jde-gen-electric-brace \" \")"
606 "(if jde-gen-comments (concat \" // \""
607 " (file-name-sans-extension (file-name-nondirectory buffer-file-name))))"
609 ";; Here comes the stuff that needs a fully generated class."
610 ";; We jump back and add those things retrospectively."
611 "(progn (tempo-backward-mark)"
612 " (jde-gen-save-excursion"
613 " (jde-gen-main-method))"
614 " (tempo-backward-mark)"
615 " (jde-gen-save-excursion"
616 " (jde-wiz-gen-method \"private\" \"\""
617 " (file-name-sans-extension (file-name-nondirectory buffer-file-name)) \"\" \"\" \"\")))"
618 ";; Move to constructor body. Set tempo-marks to nil in order to prevent tempo moving to mark."
619 "(progn (re-search-forward \"^[ \\t]*$\") (setq tempo-marks nil) nil)")
620 "*Template for new Java console app main class buffer.
621 Setting this variable defines a template instantiation
622 command `jde-gen-console', as a side-effect."
624 :type '(repeat string)
625 :set '(lambda (sym val)
626 (defalias 'jde-gen-console
627 (tempo-define-template "java-console-buffer-template"
628 (jde-gen-read-template val)
630 "Insert skeleton for a new Java console buffer"))
631 (set-default sym val)))
634 (defun jde-gen-console-buffer (file)
635 "Create a new Java buffer containing a console class of the same name.
636 This command inserts the class template generated by `jde-gen-class'.
637 It then moves the point to the location to the constructor."
642 ;;(makunbound 'jde-gen-deep-clone-template)
643 (defcustom jde-gen-deep-clone-template
645 "(jde-wiz-generate-interface \"java.lang.Cloneable\")"
647 "'&'> (progn (require 'jde-javadoc) nil)"
649 ;; create the javadoc (todo: only generate if turned on)
650 "(jde-javadoc-insert-start-block)"
651 "\"* Create a deep clone of this object.\" '>'n"
653 "\"* @return a deep clone of this object.\" '>'n"
654 "'> (jde-javadoc-insert-end-block)"
656 ;; create method declaration
657 "(let (jde-gen-final-methods)"
658 " (jde-gen-method-signature"
665 "(jde-gen-electric-brace)"
667 ;; return declaration
668 "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
669 "\" ret = null;\" '>'n'n"
671 ;; must catch CloneNotSupported exception
672 "(let ((beg (point)))"
673 " (insert \"ret = (\")"
674 " (insert (file-name-sans-extension"
675 " (file-name-nondirectory buffer-file-name)))"
676 " (insert \") super.clone();\")"
677 " (jde-gen-try-catch-wrapper beg (point))"
678 ;; at this point we are at the place to add what exception to catch
679 " (insert \"CloneNotSupportedException\")"
683 ;; first go out of the catch exception ()s
684 " (goto-char (scan-lists (point) 1 1))"
685 ;; now go into the catch {}s definition part
686 " (goto-char (scan-lists (point) 1 -1))"
689 "\"throw new InternalError(\\\"clone should be supported (forgot?)\\\");\""
692 "(progn (goto-char (scan-lists (point) 1 1)) (end-of-line) '(l n))"
694 ;; todo: detect which members need cloning and generate assignments
695 "(if jde-gen-comments "
696 " '(l \" // add non-immutable member clone assignments here\" '>'n))"
698 ;; add return statement and finish method
699 "\"return ret;\" '>'n"
702 "*Template for creating a deep clone method.
703 Setting this variable defines a template instantiation
704 command `jde-gen-deep-clone', as a side-effect."
706 :type '(repeat string)
707 :set '(lambda (sym val)
708 (defalias 'jde-gen-deep-clone
709 (tempo-define-template
710 "java-deep-clone-method"
711 (jde-gen-read-template val)
713 "Create a deep clone method at the current point."))
714 (set-default sym val)))
716 ;; TO DO: Add support for style that puts member declarations at the bottom
718 (defun jde-gen-get-next-member-pos (modifiers &optional no-move-to-point)
719 "Return the position to add the next member in a class. Return
720 the point at end of a group of modifiers at the end of the line in a class
721 definition, or the top of the class if there are no variables with the
722 modifiers we supply. This assumes a style where modifiers always are at the
723 top of the class like:
725 public class Person {
727 public static final String RACE = \"HUMAN\";
733 MODIFIERS is a set of modifiers to put the point after.
734 NO-MOVE-POINT if nil move the point, either way, we return the position.
736 (if (stringp modifiers) (setq modifiers (split-string modifiers ",")))
737 (let* ((pair (jde-parse-get-innermost-class-at-point))
738 (class-name (if pair (car pair)))
740 (if (null pair) (error "point is not in a class definition"))
741 (semantic-fetch-tags)
742 (setq pos (jde-parse-get-nth-member class-name modifiers
745 (if (null pos) (setq pos (jde-parse-get-top-of-class class-name)))
746 (if (and pos (not no-move-to-point)) (goto-char pos))
750 (defun jde-gen-insert-at-class-top (&optional class-regexp
752 "Position point at top of class, inserting space if needed.
754 CLASS-REGEXP the symbol used to find the class to find the top of. See
755 `jde-parse-get-top-of-class' for more information.
757 NO-MOVE-POINT if non-nil just the position is returned, otherwise the point is
759 (if (= (point) (jde-parse-get-top-of-class class-regexp no-move-point))
764 ;;(makunbound 'jde-gen-get-set-var-template)
765 (defcustom jde-gen-get-set-var-template
767 ;; position point at top of class, inserting space if needed
768 "(jde-gen-insert-at-class-top nil t)"
770 ;; remember where we are for later, then go to the end of the private
771 ;; declarations first found from the top of the class
772 "(progn (tempo-save-named 'mypos (point-marker)) nil)"
774 " (jde-gen-get-next-member-pos '(\"private\")) nil)"
777 "(P \"Variable type: \" type t)"
778 "(P \"Variable name: \" name t)"
780 "(progn (require 'jde-javadoc) (jde-javadoc-insert-start-block))"
781 "\"* Describe \" (s name) \" here.\" '>'n"
782 "'> (jde-javadoc-insert-end-block)"
783 "'& \"private \" (s type) \" \""
785 "(progn (goto-char (marker-position (tempo-lookup-named 'mypos))) nil)"
787 "(jde-gen-blank-lines 2 -1)"
788 ;;we begin by the getter
789 "'> (jde-javadoc-insert-start-block)"
790 "\"* Get the <code>\" (jde-gen-lookup-and-capitalize 'name) \"</code> value.\" '>'n"
791 "'> (jde-javadoc-insert-empty-line)"
793 "(let ((type (tempo-lookup-named 'type)))"
794 " (jde-gen-save-excursion (jde-javadoc-insert 'tempo-template-jde-javadoc-return-tag)))"
795 "'> (jde-javadoc-insert-end-block)"
796 "(jde-gen-method-signature"
798 " (jde-gen-lookup-named 'type)"
799 " (if (string= \"boolean\" (jde-gen-lookup-named 'type) ) "
800 " (concat \"is\" (jde-gen-lookup-and-capitalize 'name))"
801 " (concat \"get\" (jde-gen-lookup-and-capitalize 'name)))"
805 "(jde-gen-electric-brace)"
807 "\"return \" (s name) \";\" '>'n \"}\"'>'n"
808 ;; leave a blank line with no indentation
811 ;;we continue with the setter
812 "'> (jde-javadoc-insert-start-block)"
813 "\"* Set the <code>\" (jde-gen-lookup-and-capitalize 'name) \"</code> value.\" '>'n"
815 ;; ToDo: use jde-wiz-get-set-variable-prefix
816 "\"* @param new\" (jde-gen-lookup-and-capitalize 'name)"
817 "\" The new \" (jde-gen-lookup-and-capitalize 'name) \" value.\" '>'n"
818 "'> (jde-javadoc-insert-end-block)"
820 "(jde-gen-method-signature "
823 " (concat \"set\" (jde-gen-lookup-and-capitalize 'name))"
824 " (concat (jde-gen-lookup-named 'type) \" new\" "
825 " (jde-gen-lookup-and-capitalize 'name))"
828 "(jde-gen-electric-brace)"
830 "'>\"this.\" (s name) \" = new\" (jde-gen-lookup-and-capitalize 'name)"
831 "\";\" '>'n \"}\" '>"
832 "(when (looking-at \"\\\\s-*\\n\\\\s-*$\")"
833 " (forward-line 1) (end-of-line) nil)"
835 "*Template for creating a variable at the top of the class and
836 a get/set method pair for the variable at point.
837 Setting this variable defines a template instantiation
838 command `jde-gen-get-set', as a side-effect."
840 :type '(repeat string)
841 :set '(lambda (sym val)
842 (defalias 'jde-gen-get-set
843 (tempo-define-template
845 (jde-gen-read-template val)
847 "Insert variable at the top of the class and get-set method pair at point."))
848 (set-default sym val)))
850 (defun jde-gen-get-set-methods (duples)
851 "Generate variables at the top of the class and get and set methods for
852 the variables at point.
854 DUPLES is either a list of list type name pairs or a string. If it is a
855 string, the string has the form:
857 type1,name1;type2,name2;...;typeN,nameN
859 where type is the primitive or class name of the getter setter and name is the
860 name of the property (getter/setter).
862 If DUPLES is a lisp object it must a list with the form:
864 ((\"type1\" \"name1\") (\"type2\" \"name2\") ... )"
865 (interactive "sGets/Sets (type1,name1;type2,name2;...): ")
866 (if (stringp duples) (setq duples (split-string duples "[ \t]*;[ \t]*")))
868 (let ((pair (if (stringp elt) (split-string elt "[ \t]*,[ \t]*") elt)))
869 (tempo-save-named 'type (car pair))
870 (tempo-save-named 'name (car (cdr pair)))
873 ;; (makunbound 'jde-gen-bean-template)
874 (defcustom jde-gen-bean-template
877 ";; generate class and save point which is in body of the constructor"
880 ;; position point at end of class.
881 "(progn (end-of-buffer) (search-backward \"}\") (backward-char 1)) 'n"
882 "(jde-gen-blank-lines 2 -1)"
884 "(jde-gen-save-excursion"
886 ;; import Java, per spec, bean stuff
887 " (jde-wiz-generate-interface \"java.io.Serializable\")"
888 " (jde-import-insert-import '(\"java.io.Serializable\"))"
890 ;; add getters and setters
891 " (call-interactively 'jde-gen-get-set-methods))"
893 "*Template for creating a Java bean.
894 Setting this variable defines a template instantiation
895 command `jde-gen-bean', as a side-effect."
897 :type '(repeat string)
898 :set '(lambda (sym val)
899 (defalias 'jde-gen-bean
900 (tempo-define-template
902 (jde-gen-read-template val)
904 "Create a Java bean."))
905 (set-default sym val)))
908 (defun jde-gen-bean-buffer (file)
909 "Create a new Java buffer containing a Java bean of the same name.
910 This command inserts the class template generated by `jde-gen-bean'.
911 It then moves the point to the location of the constructor."
916 (defcustom jde-gen-jfc-app-buffer-template
918 "(funcall jde-gen-boilerplate-function)"
919 "(jde-gen-get-package-statement)"
920 "\"import java.awt.Dimension;\" '>'n"
921 "\"import java.awt.Graphics;\" '>'n"
922 "\"import java.awt.Graphics2D;\" '>'n"
923 "\"import java.awt.Color;\" '>'n"
924 "\"import java.awt.geom.Ellipse2D;\" '>'n"
925 "\"import java.awt.event.WindowAdapter;\" '>'n"
926 "\"import java.awt.event.WindowEvent;\" '>'n"
927 "\"import javax.swing.JFrame;\" '>'n"
928 "\"import javax.swing.JPanel;\" '>'n"
929 "\"import javax.swing.JScrollPane;\" '>'n"
930 "\"import javax.swing.JMenuBar;\" '>'n"
931 "\"import javax.swing.JMenu;\" '>'n"
932 "\"import java.awt.event.ActionEvent;\" '>'n"
933 "\"import javax.swing.AbstractAction;\" '>'n '>'n"
934 "(progn (require 'jde-javadoc) (jde-javadoc-insert-start-block))"
936 "(file-name-nondirectory buffer-file-name) '>'n"
937 "\" \" (jde-javadoc-insert-empty-line)"
938 "\" \" (jde-javadoc-insert-empty-line)"
939 "\" * Created: \" (current-time-string) '>'n"
940 "\" \" (jde-javadoc-insert-empty-line)"
941 "\" \" (jde-javadoc-insert 'tempo-template-jde-javadoc-author-tag)"
942 "\" \" (jde-javadoc-insert 'tempo-template-jde-javadoc-version-tag)"
943 "\" \" (jde-javadoc-insert 'tempo-template-jde-javadoc-end-block \"*/\")"
946 "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
947 "\" extends JFrame\""
954 "\"class Canvas extends JPanel\""
961 "(jde-gen-method-signature"
974 "\"setSize(getPreferredSize());\" '>'n"
975 "\"Canvas.this.setBackground(Color.white);\" '>'n"
978 "(jde-gen-method-signature"
981 " \"getPreferredSize\""
991 "\"return new Dimension(600, 600);\" '>'n"
994 "(jde-gen-method-signature"
997 " \"paintComponent\""
1007 "\"super.paintComponent(g);\" '>'n"
1008 "\"Graphics2D g2d = (Graphics2D) g;\" '>'n"
1009 "\"Ellipse2D circle = new Ellipse2D.Double(0d, 0d, 100d, 100d);\" '>'n"
1010 "\"g2d.setColor(Color.red);\" '>'n"
1011 "\"g2d.translate(10, 10);\" '>'n"
1012 "\"g2d.draw(circle);\" '>'n"
1013 "\"g2d.fill(circle);\" '>'n"
1020 "(jde-gen-method-signature"
1023 " (file-name-sans-extension (file-name-nondirectory buffer-file-name))"
1034 "\"super(\\\"\" (P \"Enter app title: \") \"\\\");\" '>'n"
1035 "\"setSize(300, 300);\" '>'n"
1036 "\"addWindowListener(new WindowAdapter() \""
1044 "\"public void windowClosing(WindowEvent e) {System.exit(0);}\" '>'n"
1045 "\"public void windowOpened(WindowEvent e) {}\" '>'n"
1049 "\"setJMenuBar(createMenu());\" '>'n"
1050 "\"getContentPane().add(new JScrollPane(new Canvas()));\" '>'n"
1055 "(jde-gen-method-signature"
1056 " \"public static\""
1059 " \"String[] args\""
1068 "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
1070 "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
1072 "\"f.show();\" '>'n"
1074 ;; createMenu method
1075 "\"protected JMenuBar createMenu() \""
1084 "\"JMenuBar mb = new JMenuBar();\" '>'n"
1085 "\"JMenu menu = new JMenu(\\\"File\\\");\" '>'n"
1086 "\"menu.add(new AbstractAction(\\\"Exit\\\") \""
1094 "(jde-gen-method-signature"
1097 " \"actionPerformed\""
1098 " \"ActionEvent e\""
1108 "\"System.exit(0);\" '>'n"
1111 "\"mb.add(menu);\" '>'n"
1112 "\"return mb;\" '>'n"
1115 "(file-name-sans-extension (file-name-nondirectory buffer-file-name))"
1117 "*Template for JFC (Swing) application buffer.
1118 Setting this variable defines a template instantiation
1119 command `jde-gen-jfc-app', as a side-effect."
1121 :type '(repeat string)
1122 :set '(lambda (sym val)
1123 (defalias 'jde-gen-jfc-app
1124 (tempo-define-template "java-jfc-app-buffer-template"
1125 (jde-gen-read-template val)
1127 "Insert skeleton for a JFC app buffer"))
1128 (set-default sym val)))
1131 (defun jde-gen-jfc-app-buffer (file)
1132 "Create a new Java buffer containing a JFC application class.
1133 This command inserts the class template generated by `jde-gen-jfc-app'.
1134 It then moves the point to the location to the constructor."
1138 (beginning-of-buffer)
1139 (search-forward "{")
1142 (tempo-forward-mark))
1145 (defcustom jde-gen-buffer-templates
1146 (list (cons "Class" 'jde-gen-class)
1147 (cons "Interface" 'jde-gen-interface)
1148 (cons "Exception Class" 'jde-gen-exception)
1149 (cons "Console" 'jde-gen-console)
1150 (cons "Swing App" 'jde-gen-jfc-app)
1151 (cons "Unit Test" 'jde-junit-test-class))
1152 "*Specifies available autocode templates for creating buffers.
1153 The value of this variable is an association list. The car of
1154 each element specifies the template's title. The cdr specifies
1155 a command that inserts the template into a buffer. See the function
1156 `tempo-define-template' for any easy way to create a template
1160 (cons :tag "Template"
1161 (string :tag "Title")
1162 (function :tag "Command")))
1163 :set '(lambda (sym val)
1164 (let ((n (length val))
1166 (setq jde-gen-buffer-template-names (list))
1168 (setq jde-gen-buffer-template-names
1170 jde-gen-buffer-template-names
1171 (list (cons (car (nth i val)) (1+ i)))))
1173 (set-default sym val)))
1176 (defun jde-gen-buffer (template file)
1177 "Create a new Java buffer containing a code template.
1178 This command inserts the specified template at the beginning
1181 (list (completing-read "Template: " jde-gen-buffer-template-names)
1182 (read-file-name "File: ")))
1184 (funcall (cdr (assoc template jde-gen-buffer-templates)))
1185 (beginning-of-buffer)
1186 (search-forward "{")
1191 (defun jde-gen-lookup-and-capitalize (val)
1192 "If the given value (val) is the name of saved data, the data is
1193 stripped of its prefix/suffix (see `jde-wiz-get-name') and it is
1194 capitalized. Otherwise, the given value is stripped and capitalized."
1195 (if (jde-gen-lookup-named val)
1196 (upcase-initials (jde-wiz-get-name (jde-gen-lookup-named val)))
1197 (upcase-initials (jde-wiz-get-name val))))
1200 (defcustom jde-gen-section-comment-template
1202 "(p \"Comment: \" comment-line 'noinsert)"
1204 "\"// \" (s comment-line) '>'n'n'>"
1206 "*Template for generating a section comment. Used as an introductory
1207 comment to a source code section by code generating functions."
1209 :type '(repeat string)
1210 :set '(lambda (sym val)
1211 (defalias 'jde-gen-section-comment
1212 (tempo-define-template
1214 (jde-gen-read-template val)
1216 "Insert section comment."))
1217 (set-default sym val)))
1219 (defcustom jde-gen-inner-class-template
1221 "(end-of-line) '& \"class \" (P \"Class name: \" class) '>"
1222 "\" \" (jde-gen-get-extend-class)"
1224 ;;we open the bracket according to k&r style or not
1230 "(jde-gen-method-signature"
1233 " (jde-gen-lookup-named 'class)"
1237 ;;we open the bracket according to k&r style or not
1245 "(jde-gen-get-interface-implementation)"
1250 "*Template that creates an empty private class at point."
1252 :type '(repeat string)
1253 :set '(lambda (sym val)
1254 (tempo-define-template "java-inner-class"
1255 (jde-gen-read-template val)
1257 "Insert inner class.")
1258 (defalias 'jde-gen-inner-class-internal
1259 (list 'lambda (list)
1260 (list 'tempo-template-java-inner-class)
1261 (list 'jde-gen-insert-interface-implementation)))
1262 (set-default sym val)))
1264 (defun jde-gen-inner-class ()
1266 (jde-gen-inner-class-internal)
1267 (goto-char (scan-lists (point) -1 0))
1270 (defcustom jde-gen-action-listener-template
1272 "'& (P \"Component name: \")"
1273 "\".addActionListener(\" jde-gen-method-signature-padding-2 "
1274 "\"new ActionListener\" jde-gen-method-signature-padding-1 \"()\" '>"
1276 ;;we open the bracket according to k&r style or not
1278 " jde-gen-method-signature-padding-3"
1283 "(jde-gen-method-signature"
1286 " \"actionPerformed\""
1287 " \"ActionEvent e\""
1291 ;;we open the bracket according to k&r style or not
1298 "\"}\" jde-gen-method-signature-padding-2 \");\"'>'n'>'n'>"
1300 "*Template for generating an action listener.
1301 Setting this variable defines a template instantiation
1302 command, `jde-gen-action-listener', as a side-effect."
1304 :type '(repeat string)
1305 :set '(lambda (sym val)
1306 (defalias 'jde-gen-action-listener
1307 (tempo-define-template
1308 "java-action-listener"
1309 (jde-gen-read-template val)
1311 "Insert skeleton action listener."))
1312 (set-default sym val)))
1314 (defcustom jde-gen-window-listener-template
1316 "(end-of-line) '& (P \"Window name: \")"
1317 "\".addWindowListener(\" jde-gen-method-signature-padding-2 "
1318 "\"new WindowAdapter\" jde-gen-method-signature-padding-1 \"()\"'>"
1320 ;;we open the bracket according to k&r style or not
1322 " jde-gen-method-signature-padding-3"
1326 "(jde-gen-method-signature"
1329 " \"windowActivated\""
1330 " \"WindowEvent e\""
1334 ;;we open the bracket according to k&r style or not
1341 "(jde-gen-method-signature"
1345 " \"WindowEvent e\""
1349 ;;we open the bracket according to k&r style or not
1356 "(jde-gen-method-signature"
1359 " \"windowClosing\""
1360 " \"WindowEvent e\""
1364 ;;we open the bracket according to k&r style or not
1369 " \"System.exit(0);\" '>'n \"}\""
1372 "(jde-gen-method-signature"
1375 " \"windowDeactivated\""
1376 " \"WindowEvent e\""
1380 ;;we open the bracket according to k&r style or not
1387 "(jde-gen-method-signature"
1390 " \"windowDeiconified\""
1391 " \"WindowEvent e\""
1395 ;;we open the bracket according to k&r style or not
1402 "(jde-gen-method-signature"
1405 " \"windowIconified\""
1406 " \"WindowEvent e\""
1410 ;;we open the bracket according to k&r style or not
1417 "(jde-gen-method-signature"
1421 " \"WindowEvent e\""
1425 ;;we open the bracket according to k&r style or not
1432 "\"}\" jde-gen-method-signature-padding-2 \");\" '>'n'>"
1434 "*Template for generating a window listener.
1435 Setting this variable defines a template instantiation
1436 command, `jde-gen-window-listener', as a side-effect."
1438 :type '(repeat string)
1439 :set '(lambda (sym val)
1440 (defalias 'jde-gen-window-listener
1441 (tempo-define-template
1442 "java-window-listener"
1443 (jde-gen-read-template val)
1445 "Insert skeleton window listener."))
1446 (set-default sym val)))
1450 (defcustom jde-gen-mouse-listener-template
1452 "(end-of-line) '& (P \"Component name: \")"
1453 "\".addMouseListener(\" jde-gen-method-signature-padding-2 "
1454 "\"new MouseAdapter\" jde-gen-method-signature-padding-1 \"()\" '>"
1456 ;;we open the bracket according to k&r style or not
1458 " jde-gen-method-signature-padding-3"
1462 "(jde-gen-method-signature"
1470 ;;we open the bracket according to k&r style or not
1477 "(jde-gen-method-signature"
1485 ;;we open the bracket according to k&r style or not
1492 "(jde-gen-method-signature"
1500 ;;we open the bracket according to k&r style or not
1507 "(jde-gen-method-signature"
1515 ;;we open the bracket according to k&r style or not
1522 "(jde-gen-method-signature"
1525 " \"mouseReleased\""
1530 ;;we open the bracket according to k&r style or not
1537 "\"}\" jde-gen-method-signature-padding-2 \");\"'>'n'>"
1539 "*Template for generating a mouse listener.
1540 Setting this variable defines a template instantiation
1541 command, `jde-gen-mouse-listener', as a side-effect."
1543 :type '(repeat string)
1544 :set '(lambda (sym val)
1545 (defalias 'jde-gen-mouse-listener
1546 (tempo-define-template
1547 "java-mouse-listener"
1548 (jde-gen-read-template val)
1550 "Insert skeleton mouse listener."))
1551 (set-default sym val)))
1553 (defcustom jde-gen-mouse-motion-listener-template
1555 "(end-of-line) '& (P \"Component name: \")"
1556 "\".addMouseMotionListener(\" jde-gen-method-signature-padding-2 "
1557 "\"new MouseMotionAdapter\" jde-gen-method-signature-padding-1 \"()\" '>"
1559 ;;we open the bracket according to k&r style or not
1561 " jde-gen-method-signature-padding-3"
1565 "(jde-gen-method-signature"
1573 ;;we open the bracket according to k&r style or not
1580 "(jde-gen-method-signature"
1588 ;;we open the bracket according to k&r style or not
1595 "\"}\" jde-gen-method-signature-padding-2 \");\"'>'n'>"
1597 "*Template for generating a mouse listener.
1598 Setting this variable defines a template instantiation
1599 command, `jde-gen-mouse-motion-listener', as a side-effect."
1601 :type '(repeat string)
1602 :set '(lambda (sym val)
1603 (defalias 'jde-gen-mouse-motion-listener
1604 (tempo-define-template
1605 "java-mouse-motion-listener"
1606 (jde-gen-read-template val)
1608 "Insert skeleton mouse motion listener."))
1609 (set-default sym val)))
1611 (defcustom jde-gen-change-listener-template
1613 "'& (P \"Component name: \")"
1614 "\".addChangeListener(\" jde-gen-method-signature-padding-2 "
1615 "\"new ChangeListener\" jde-gen-method-signature-padding-1 \"()\" '>"
1617 ;;we open the bracket according to k&r style or not
1619 " jde-gen-method-signature-padding-3"
1624 "(jde-gen-method-signature"
1628 " \"ChangeEvent e\""
1632 ;;we open the bracket according to k&r style or not
1639 "\"}\" jde-gen-method-signature-padding-2 \");\"'>'n'>'n'>"
1641 "*Template for generating a change listener.
1642 Setting this variable defines a template instantiation
1643 command, `jde-gen-change-listener', as a side-effect."
1645 :type '(repeat string)
1646 :set '(lambda (sym val)
1647 (defalias 'jde-gen-change-listener
1648 (tempo-define-template
1649 "java-change-listener"
1650 (jde-gen-read-template val)
1652 "Insert skeleton change listener."))
1653 (set-default sym val)))
1655 (defcustom jde-gen-main-method-template
1657 "(jde-gen-save-excursion"
1658 " (jde-wiz-gen-method"
1659 " \"public static\""
1662 " \"String[] args\""
1664 ";; don't move point"
1665 "(setq tempo-marks nil)"
1667 "Template for generating the main method.
1668 Setting this variable defines a template instantiation
1669 command, `jde-gen-main-method', as a side-effect."
1671 :type '(repeat string)
1672 :set '(lambda (sym val)
1673 (defalias 'jde-gen-main-method
1674 (tempo-define-template
1676 (jde-gen-read-template val)
1678 "Insert skeleton main method."))
1679 (set-default sym val)))
1682 (defcustom jde-gen-println
1685 "\"System.out.println(\" (P \"Print out: \") \");\" '>'n'>"
1687 "*Template for generating a System.out.println statement."
1689 :type '(repeat string)
1690 :set '(lambda (sym val)
1691 (defalias 'jde-gen-println
1692 (tempo-define-template
1694 (jde-gen-read-template val)
1696 "Insert println statement."))
1697 (set-default sym val)))
1699 (defcustom jde-gen-beep
1702 "\"Toolkit.getDefaultToolkit().beep();\"'>'n'>"
1704 "*Template for generating a Toolkit.getDefaultToolkit().beep() statement."
1706 :type '(repeat string)
1707 :set '(lambda (sym val)
1708 (defalias 'jde-gen-beep
1709 (tempo-define-template
1711 (jde-gen-read-template val)
1713 "Insert beep statement."))
1714 (set-default sym val)))
1716 (defcustom jde-gen-property-change-support
1720 "\"protected PropertyChangeSupport pcs = new PropertyChangeSupport(this);\" '>'n '>'n"
1724 "\"* Adds a PropertyChangeListener to the listener list.\" '>'n"
1725 "\"* The listener is registered for all properties.\" '>'n"
1727 "\"* @param listener The PropertyChangeListener to be added\" '>'n"
1730 "(jde-gen-method-signature"
1733 " \"addPropertyChangeListener\""
1734 " \"PropertyChangeListener listener\""
1738 ;;we open the bracket according to k&r style or not
1744 "\"pcs.addPropertyChangeListener(listener);\" '>'n \"}\" '>'n '>'n"
1747 "\"* Removes a PropertyChangeListener from the listener list.\" '>'n"
1748 "\"* This removes a PropertyChangeListener that was registered\" '>'n"
1749 "\"* for all properties.\" '>'n"
1751 "\"* @param listener The PropertyChangeListener to be removed\" '>'n"
1754 "(jde-gen-method-signature"
1757 " \"removePropertyChangeListener\""
1758 " \"PropertyChangeListener listener\""
1762 ;;we open the bracket according to k&r style or not
1768 "'>\"pcs.removePropertyChangeListener(listener);\" '>'n \"}\" '>'n '>'n"
1771 "\"* Adds a PropertyChangeListener for a specific property.\" '>'n"
1772 "\"* The listener will be invoked only when a call on firePropertyChange\" '>'n"
1773 "\"* names that specific property.\" '>'n"
1775 "\"* @param propertyName The name of the property to listen on\" '>'n"
1776 "\"* @param listener The PropertyChangeListener to be added\" '>'n"
1779 "(jde-gen-method-signature"
1782 " \"addPropertyChangeListener\""
1783 " \"String propertyName, PropertyChangeListener listener\""
1787 ;;we open the bracket according to k&r style or not
1793 "'> \"pcs.addPropertyChangeListener(propertyName, listener);\" '>'n"
1797 "\"* Removes a PropertyChangeListener for a specific property.\" '>'n"
1799 "\"* @param propertyName The name of the property that was listened on\" '>'n"
1800 "\"* @param listener The PropertyChangeListener to be removed\"'>'n"
1803 "(jde-gen-method-signature"
1806 " \"removePropertyChangeListener\""
1807 " \"String propertyName, PropertyChangeListener listener\""
1811 ;;we open the bracket according to k&r style or not
1817 "'> \"pcs.removePropertyChangeListener(propertyName, listener);\" '>'n"
1821 "\"* Reports a bound property update to any registered listeners. \" '>'n"
1822 "\"* No event is fired if old and new are equal and non-null.\" '>'n"
1824 "\"* @param propertyName The programmatic name of the property\" '>'n"
1825 "\"* that was changed\" '>'n"
1826 "\"* @param oldValue The old value of the property\" '>'n"
1827 "\"* @param newValue The new value of the property.\" '>'n \"*/\" '>'n"
1829 "(jde-gen-method-signature"
1832 " \"firePropertyChange\""
1833 " \"String propertyName, Object oldValue, Object newValue\""
1837 ;;we open the bracket according to k&r style or not
1843 "'> \"pcs.firePropertyChange(propertyName, oldValue, newValue);\" '>'n"
1847 "\"* Reports a bound property update to any registered listeners. \" '>'n"
1848 "\"* No event is fired if old and new are equal and non-null.\" '>'n"
1849 "\"* This is merely a convenience wrapper around the more general\" '>'n"
1850 "\"* firePropertyChange method that takes Object values.\" '>'n"
1851 "\"* No event is fired if old and new are equal and non-null.\" '>'n"
1853 "\"* @param propertyName The programmatic name of the property\" '>'n"
1854 "\"* that was changed\" '>'n"
1855 "\"* @param oldValue The old value of the property\" '>'n"
1856 "\"* @param newValue The new value of the property.\" '>'n \"*/\" '>'n"
1858 "(jde-gen-method-signature"
1861 " \"firePropertyChange\""
1862 " \"String propertyName, int oldValue, int newValue\""
1866 ;;we open the bracket according to k&r style or not
1872 "'> \"pcs.firePropertyChange(propertyName, oldValue, newValue);\" '>'n"
1876 "\"* Reports a bound property update to any registered listeners. \" '>'n"
1877 "\"* No event is fired if old and new are equal and non-null.\" '>'n"
1878 "\"* This is merely a convenience wrapper around the more general\" '>'n"
1879 "\"* firePropertyChange method that takes Object values.\" '>'n"
1880 "\"* No event is fired if old and new are equal and non-null.\" '>'n"
1882 "\"* @param propertyName The programmatic name of the property\" '>'n"
1883 "\"* that was changed\" '>'n"
1884 "\"* @param oldValue The old value of the property\" '>'n"
1885 "\"* @param newValue The new value of the property.\" '>'n \"*/\" '>'n"
1887 "(jde-gen-method-signature"
1890 " \"firePropertyChange\""
1891 " \"String propertyName, boolean oldValue, boolean newValue\""
1895 ;;we open the bracket according to k&r style or not
1901 "'> \"pcs.firePropertyChange(propertyName, oldValue, newValue);\" '>'n"
1905 "\"* Fires an existing PropertyChangeEvent to any registered listeners.\" '>'n"
1906 "\"* No event is fired if the given event's old and new values are\"'>'n"
1907 "\"* equal and non-null. \" '>'n"
1909 "\"* @param evt The PropertyChangeEvent object.\" '>'n\"*/\" '>'n"
1911 "(jde-gen-method-signature"
1914 " \"firePropertyChange\""
1915 " \"PropertyChangeEvent evt\""
1919 ;;we open the bracket according to k&r style or not
1925 "'> \"pcs.firePropertyChange(evt);\" '>'n \"}\" '>'n '>'n"
1928 "\"* Checks if there are any listeners for a specific property.\" '>'n"
1930 "\"* @param evt The PropertyChangeEvent object.\" '>'n"
1931 "\"* @return <code>true</code>if there are one or more listeners\"'>'n"
1932 "\"* for the given property\" '>'n"
1935 "(jde-gen-method-signature"
1939 " \"String propertyName\""
1943 ;;we open the bracket according to k&r style or not
1949 "'> \"return pcs.hasListeners(propertyName);\" '>'n \"}\" '>'n '>'n'>"
1951 "*Template for adding property change support to a class."
1953 :type '(repeat string)
1954 :set '(lambda (sym val)
1955 (defalias 'jde-gen-property-change-support
1956 (tempo-define-template
1957 "property change support template"
1958 (jde-gen-read-template val)
1960 "Insert property change support template."))
1961 (set-default sym val)))
1963 (defcustom jde-gen-listener-registry
1965 "(p \"Listener class (fully qualified): \" listenerFQN 'noinsert)"
1966 "(tempo-save-named 'listener-class "
1967 " (replace-in-string (tempo-lookup-named 'listenerFQN)"
1968 " \"[^\\\\.]+\\\\.\" \"\"))"
1969 "(tempo-save-named 'listener-vector "
1970 " (concat (jde-wiz-downcase-initials (tempo-lookup-named 'listener-class))"
1974 "\"protected Vector \" (s listener-vector) \" = new Vector();\" '>'n '>'n"
1977 "\"* The method <CODE>add\" (s listener-class)"
1978 "\"</CODE> allows to \" '>'n"
1979 "\"* add a new <CODE>\" (s listener-class) \"</CODE>\" '>'n"
1980 "\"* that will be notified of incoming events.\" '>'n"
1982 "\"* @see \" (s listenerFQN) '>'n"
1985 "(jde-gen-method-signature"
1988 " (concat \"add\" (tempo-lookup-named 'listener-class))"
1989 " (concat (tempo-lookup-named 'listener-class) \" l\")"
1993 ;;we open the bracket according to k&r style or not
1999 "(s listener-vector) \".addElement(l);\" '> 'n"
2004 "\"* The method <CODE>remove\" (s listener-class)"
2005 "\"</CODE> allows to \" '>'n"
2006 "\"* remove a <CODE>\" (s listener-class) \"</CODE> that was\" '>'n"
2007 "\"* previously registered to be notified of incoming events.\" '>'n"
2009 "\"* @see \" (s listenerFQN) '>'n"
2012 "(jde-gen-method-signature"
2015 " (concat \"remove\" (tempo-lookup-named 'listener-class))"
2016 " (concat (tempo-lookup-named 'listener-class) \" l\")"
2020 ;;we open the bracket according to k&r style or not
2026 "(s listener-vector) \".removeElement(l);\" '> 'n"
2030 "*Template for adding a registry for a class of listeners."
2032 :type '(repeat string)
2033 :set '(lambda (sym val)
2034 (defalias 'jde-gen-listener-registry
2035 (tempo-define-template
2036 "listener registry template"
2037 (jde-gen-read-template val)
2039 "Insert listener registry template."))
2040 (set-default sym val)))
2042 (defcustom jde-gen-event-source-fire-method-template
2044 "(p \"Listener class (fully qualified): \" listenerFQN 'noinsert)"
2045 "(p \"Listener method name: \" method-name 'noinsert)"
2046 "(p \"Method name: \" return-type 'noinsert)"
2047 "(p \"Method name: \" params 'noinsert)"
2048 "(tempo-save-named 'listener-class "
2049 " (replace-in-string (tempo-lookup-named 'listenerFQN)"
2050 " \"[^\\\\.]+\\\\.\" \"\"))"
2051 "(tempo-save-named 'listener-vector "
2052 " (concat (jde-wiz-downcase-initials (tempo-lookup-named 'listener-class))"
2054 "(tempo-save-named 'fire-method "
2055 " (concat \"fire\" (upcase-initials (tempo-lookup-named 'method-name))))"
2056 "(tempo-save-named 'param-ids "
2057 " (jde-gen-extract-ids-from-params (tempo-lookup-named 'params)))"
2061 "\"* The method <CODE>\" (s fire-method)"
2062 "\"</CODE> is used \" '>'n"
2063 "\"* to call the <CODE>\" (s method-name) \"</CODE> method of\" '>'n"
2064 "\"* every previously registered <CODE>\" (s listener-class) \"</CODE>.\" '>'n"
2066 "\"* @see \" (s listenerFQN) '>'n"
2069 "(jde-gen-method-signature"
2071 " (tempo-lookup-named 'return-type)"
2072 " (tempo-lookup-named 'fire-method)"
2073 " (tempo-lookup-named 'params)"
2077 ;;we open the bracket according to k&r style or not
2083 " \"for(int i = 0; i < \" (s listener-vector) \".size(); i++)\" '>"
2084 ;;we open the bracket according to k&r style or not
2089 "\"((\" (s listener-class) \")\" (s listener-vector)"
2090 "\".elementAt (i)).\" (s method-name) \" (\" (s param-ids) \");\" '> 'n"
2095 "*Template for adding a registry for a class of listeners."
2097 :type '(repeat string)
2098 :set '(lambda (sym val)
2099 (defalias 'jde-gen-event-source-fire-method
2100 (tempo-define-template
2101 "event source fire method template"
2102 (jde-gen-read-template val)
2104 "Insert event source fire method template."))
2105 (set-default sym val)))
2107 ;; (makunbound 'jde-gen-enity-bean-template)
2108 (defcustom jde-gen-entity-bean-template
2110 "(jde-import-insert-imports-into-buffer "
2111 " (list \"javax.ejb.*\""
2112 " \"java.rmi.RemoteException\"))"
2115 "(jde-gen-method-signature"
2120 " \"RemoteException\""
2124 ;;we open the bracket according to k&r style or not
2132 "(jde-gen-method-signature"
2137 " \"RemoteException\""
2147 "(jde-gen-method-signature"
2152 " \"RemoteException\""
2162 "(jde-gen-method-signature"
2167 " \"RemoteException\""
2177 "(jde-gen-method-signature"
2182 " \"RemoteException\""
2192 "(jde-gen-method-signature"
2195 " \"setEntityContext\""
2196 " \"EntityContext ctx\""
2197 " \"RemoteException\""
2207 "(jde-gen-method-signature"
2210 " \"unsetEntityContext\""
2212 " \"RemoteException\""
2221 "*Template that creates an empty implementation of an EJB Entity Bean."
2223 :type '(repeat string)
2224 :set '(lambda (sym val)
2225 (defalias 'jde-gen-entity-bean
2226 (tempo-define-template
2228 (jde-gen-read-template val)
2230 "Adds an implementation of the EJB Entity Bean interface to the
2231 class in the current buffer at the current point in the buffer. Before invoking
2232 this command, position point at the point in the buffer where you want the first
2233 Entity Bean method to appear. Use `jde-ejb-entity-bean-buffer' to create a complete
2234 skeleton entity bean implementation from scratch."))
2235 (set-default sym val)))
2238 ;; (makunbound 'jde-gen-session-bean-template)
2239 (defcustom jde-gen-session-bean-template
2241 "(jde-import-insert-imports-into-buffer "
2242 " (list \"javax.ejb.*\""
2243 " \"java.rmi.RemoteException\"))"
2246 "(jde-wiz-update-implements-clause \"SessionBean\")"
2249 "(jde-gen-method-signature"
2254 " \"RemoteException\""
2258 ;;we open the bracket according to k&r style or not
2265 "(jde-gen-method-signature"
2270 " \"RemoteException\""
2274 ;;we open the bracket according to k&r style or not
2281 "(jde-gen-method-signature"
2286 " \"RemoteException\""
2290 ;;we open the bracket according to k&r style or not
2297 "(jde-gen-method-signature"
2300 " \"setSessionContext\""
2301 " \"SessionContext ctx\""
2302 " \"RemoteException\""
2306 ;;we open the bracket according to k&r style or not
2313 "(jde-gen-method-signature"
2316 " \"unsetSessionContext\""
2318 " \"RemoteException\""
2322 ;;we open the bracket according to k&r style or not
2330 "*Template that creates an empty implementation of an EJB Session Bean."
2332 :type '(repeat string)
2333 :set '(lambda (sym val)
2334 (defalias 'jde-gen-session-bean
2335 (tempo-define-template
2337 (jde-gen-read-template val)
2339 "Adds an implementation of the EJB Session Bean interface to the
2340 class in the current buffer at the current point in the buffer. Before invoking
2341 this command, position point at the point in the buffer where you want the first
2342 Session Bean method to appear. Use `jde-ejb-session-bean-buffer' to create a complete
2343 skeleton session bean implementation from scratch."))
2344 (set-default sym val)))
2348 ;; (makunbound 'jde-gen-method-javadoc-comment)
2349 (defcustom jde-gen-method-javadoc-comment "template"
2350 "Specifies the type of javadoc comment generated by
2351 the `jde-gen-method-template'. The choices are
2355 Uses `jde-javadoc-autodoc-at-line' function to generate
2360 Generates a javadoc comment containing only the
2361 javadoc (@inheritDoc) tag. This tag causes javadoc
2362 to copy the javadoc comment from the abstract
2363 method that the generated method implements but
2364 only if the javadoc for the abstract method is
2365 also being generated.
2369 Specifies that the method template not generate
2370 a javadoc comment. In this case, javadoc copies
2371 the comment from the abstract method if its doc
2372 is also being generated in the same run."
2375 (const :tag "Template" "template")
2376 (const :tag "Inherit Tag" "inherit")
2377 (const :tag "None" "none")))
2380 ;; (makunbound 'jde-gen-method-template)
2381 (defcustom jde-gen-method-template
2383 "(p \"Method modifiers: \" modifiers 'noinsert)"
2384 "(p \"Method return type: \" return-type 'noinsert)"
2385 "(p \"Method name: \" name 'noinsert)"
2386 "(p \"Method parameters: \" parameters 'noinsert)"
2387 "(p \"Method exceptions: \" exceptions 'noinsert)"
2388 "(p \"Method body: \" default-body 'noinsert)"
2389 "(jde-gen-delete-preceding-whitespace) 'n 'n 'p"
2391 ;; Insert inherit javadoc comment if specified.
2392 "(if (string= jde-gen-method-javadoc-comment \"inherit\")"
2394 "\"* (@inheritDoc)\" 'n>"
2398 ;; Insert method signature.
2399 "(jde-gen-method-signature"
2400 " (tempo-lookup-named 'modifiers)"
2401 " (tempo-lookup-named 'return-type)"
2402 " (tempo-lookup-named 'name)"
2403 " (tempo-lookup-named 'parameters)"
2404 " (tempo-lookup-named 'exceptions)"
2408 "(jde-gen-electric-brace)"
2409 "(s default-body) (jde-gen-indent) 'p'n"
2411 "(if (string= jde-gen-method-javadoc-comment \"template\")"
2412 " (progn (tempo-backward-mark) (tempo-backward-mark) (beginning-of-line)"
2413 " (jde-gen-save-excursion (jde-javadoc-autodoc-at-line))"
2414 " (tempo-forward-mark) nil)"
2415 " (progn (tempo-backward-mark) nil))"
2416 "(setq tempo-marks nil) ;; prevent tempo from moving point"
2418 "*Template for generating a skeleton method. The
2419 `jde-gen-method-javadoc-comment' variable controls whether this
2420 template generates a javadoc comment for the method, and, if so, what
2421 kind of comment. Setting this variable defines a template
2422 instantiation command, `jde-gen-method', as a side-effect."
2424 :type '(repeat string)
2425 :set '(lambda (sym val)
2426 (defalias 'jde-gen-method
2427 (tempo-define-template
2429 (jde-gen-read-template val)
2431 "Insert skeleton method."))
2432 (set-default sym val)))
2435 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2436 ;;;_* equals method generator
2437 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2440 (defcustom jde-gen-equals-trailing-and-operators nil
2441 "Specifies whether the '&&' operators in a generated equals
2442 method are added at the end of the line or at the beginning. If
2443 this variable is t, the operator will be added at the end of the
2444 line, else on the next line before the comparison. With
2445 `jde-gen-equals-trailing-and-operators' set to nil:
2449 && (s == null ? o.s == null : s.equals(o.s));
2451 Or, with `jde-gen-equals-trailing-and-operators' set to t:
2453 return (a == o.a) &&
2455 (s == null ? o.s == null : s.equals(o.s));
2461 (defcustom jde-gen-equals-parens-around-expression nil
2462 "Specifies whether the generated equals expression should be
2463 surrounded by parentheses.
2464 With `jde-gen-equals-trailing-and-operators' set to nil:
2468 && (s == null ? o.s == null : s.equals(o.s)));
2470 Or, with `jde-gen-equals-trailing-and-operators' set to t:
2472 return ((a == o.a) &&
2474 (s == null ? o.s == null : s.equals(o.s)));
2480 (defcustom jde-gen-equals-method-template
2483 "\" * Check if this object is equal to another object.\" '> 'n"
2485 "\" * <p>For the definition of the object equivalence relation\" '> 'n"
2486 "\" * see {@link java.lang.Object#equals(Object)}.</p>\" '> 'n"
2488 "\" * @param obj another, possibly equal object.\" '> 'n"
2490 "\" * @return true if the objects are equal, false otherwise.\" '> 'n"
2492 "\" * @see java.lang.Object#equals(Object)\" '> 'n"
2494 "(jde-gen-method-signature \"public\" \"boolean\" \"equals\" \"Object obj\")"
2495 "(jde-gen-electric-brace)"
2496 "\"if (obj == this)\" '> 'n"
2497 "\"return true;\" '> 'n '> 'n"
2498 "\"if (obj == null || getClass() != obj.getClass())\" '> 'n"
2499 "\"return false;\" '> 'n '> 'n"
2500 "(jde-gen-equals-return \"obj\" \"o\") '> 'n"
2502 "*Template for creating an equals method.
2503 Setting this variable defines a template instantiation command
2504 `jde-gen-equals-method', as a side-effect."
2506 :type '(repeat string)
2507 :set '(lambda (sym val)
2508 (defalias 'jde-gen-equals-method
2509 (tempo-define-template
2510 "java-equals-method"
2511 (jde-gen-read-template val)
2513 "Create an equals method at the current point."))
2514 (set-default sym val)))
2517 (defun jde-gen-equals-return (&optional parm-name var-name class)
2518 "Generate a body of an appropriate override for the
2519 java.lang.Object#equals(Object) function. This function gets the
2520 list of member variables from`jde-parse-get-serializable-members'.
2522 The first optional parameter `parm-name' is the parameter name of
2523 the Object argument of the equals function. Default is \"obj\".
2525 The second optional parameter `var-name' denotes the variable
2526 name used to cast the \"obj\" argument to. The default is \"o\".
2528 The third optional parameter `class' can be a semantic tag, which
2529 is then used instead of the result of `semantic-current-tag'.
2539 Bean o = (Bean) obj;
2543 && (s == null ? o.s == null : s.equals(o.s));
2545 Or, with `jde-gen-equals-trailing-and-operators' set to t:
2546 Bean o = (Bean) obj;
2548 return (a == o.a) &&
2550 (s == null ? o.s == null : s.equals(o.s));
2553 (let* ((parm (or parm-name "obj"))
2554 (var (or var-name "o"))
2555 (class-tag (or class (semantic-current-tag)))
2556 (class-name (semantic-tag-name class-tag))
2557 (members (sort (jde-parse-get-serializable-members class-tag)
2558 'jde-parse-compare-member-types))
2559 (super (car (semantic-tag-type-superclasses class-tag)))
2560 (extends (and super (not (string= "Object" super)))))
2562 class-name " " var " = (" class-name ") " parm ";" '>'n '>'n
2564 (if jde-gen-equals-parens-around-expression "(")
2565 (if extends (list 'l "super.equals(" var ")")) '>
2568 (let ((name (semantic-tag-name tag))
2569 (type (semantic-tag-type tag)))
2570 (list 'l (if extends (jde-gen-equals-add-and-operator)
2571 (setq extends t) nil)
2574 ((and (string-match "\\`\\(byte\\|char\\|short\\|int\\|long\\|float\\|double\\|boolean\\)" type)
2575 (or (string-match "\\[.*\\]" name) (string-match "\\[.*\\]" type)))
2576 (let ((array (replace-regexp-in-string "\\[.*\\]" "" name)))
2577 (concat "java.util.Arrays.equals(" array ", " var "." array ")")))
2580 ((or (string-match "\\[.*\\]" name) (string-match "\\[.*\\]" type))
2581 (let ((array (replace-regexp-in-string "\\[.*\\]" "" name)))
2582 (concat "java.util.Arrays.deepEquals(" array ", " var "." array ")")))
2585 ((or (semantic-tag-of-type-p tag "byte")
2586 (semantic-tag-of-type-p tag "char")
2587 (semantic-tag-of-type-p tag "short")
2588 (semantic-tag-of-type-p tag "int")
2589 (semantic-tag-of-type-p tag "long")
2590 (semantic-tag-of-type-p tag "boolean"))
2591 (concat "(" name " == " var "." name ")"))
2593 ;; floating point; use epsilon?
2594 ((or (semantic-tag-of-type-p tag "float")
2595 (semantic-tag-of-type-p tag "double"))
2596 (concat "(" name " == " var "." name ")"))
2598 ;; object references
2599 (t (concat "(" name " == null ? " var "." name " == null : "
2600 name ".equals(" var "." name "))" )))
2602 (if jde-gen-equals-parens-around-expression ")") ";")))
2604 (defun jde-gen-equals-add-and-operator ()
2605 (if jde-gen-equals-trailing-and-operators
2606 (list 'l " &&" '> 'n '>)
2607 (list 'l '> 'n '> "&& ")))
2609 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2610 ;;;_* hashCode method generator
2611 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2614 (defcustom jde-gen-hashcode-method-template
2617 "\" * Calculate the hash code for this object.\" '> 'n"
2619 "\" * <p>The rules laid out in J. Blosh's Effective Java are used\" '> 'n"
2620 "\" * for the hash code calculation.</p>\" '> 'n"
2622 "\" * @return the hash code.\" '> 'n"
2624 "\" * @see java.lang.Object#hashCode\" '> 'n"
2626 "(jde-gen-method-signature \"public\"\ \"int\" \"hashCode\" nil)"
2627 "(jde-gen-electric-brace)"
2628 "(jde-gen-hashcode-body) '> 'n"
2630 "*Template for creating a hashCode method.
2631 Setting this variable defines a template instantiation command
2632 `jde-gen-hashcode-method', as a side-effect."
2634 :type '(repeat string)
2635 :set '(lambda (sym val)
2636 (defalias 'jde-gen-hashcode-method
2637 (tempo-define-template
2638 "java-hashcode-method"
2639 (jde-gen-read-template val)
2641 "Create a hashCode method at the current point."))
2642 (set-default sym val)))
2644 (defvar jde-gen-hashcode-primes
2645 '(11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97)
2646 "a list of all two digit prime numbers")
2648 (defvar jde-gen-hashcode-current-prime 0
2651 (defun jde-gen-hashcode-next-prime ()
2652 "Get the next prime number"
2653 (let ((last jde-gen-hashcode-current-prime))
2654 (setq jde-gen-hashcode-current-prime (% (+ 1 last)
2655 (length jde-gen-hashcode-primes)))
2656 (int-to-string (nth last jde-gen-hashcode-primes))))
2659 (defun jde-gen-hashcode-body (&optional var-name class)
2660 "Generate a body of a hashCode function.
2661 This function gets the list of member variables of the current
2662 class from `jde-parse-get-serializable-members'.
2664 The first optional parameter `var-name' denotes the variable name used
2665 to calculate the hash code, the default is \"code\".
2667 The second optional parameter `class' can be a semantic tag, which is
2668 then used instead of the result of `semantic-current-tag'.
2671 (let* ((var (or var-name "code"))
2672 (class-tag (or class (semantic-current-tag)))
2673 (members (sort (jde-parse-get-serializable-members class-tag)
2674 'jde-parse-compare-member-types))
2675 (super (car (semantic-tag-type-superclasses class-tag)))
2676 (extends (and super (not (string= "Object" super)))))
2677 (list 'l "int " var " = "
2678 (if extends "super.hashCode()" (jde-gen-hashcode-next-prime)) ";"
2684 (let ((name (semantic-tag-name tag))
2685 (type (semantic-tag-type tag)))
2686 (list 'l var " = " var " * 37 + "
2688 ;; arrays must be first
2691 ((and (string-match "\\`\\(byte\\|char\\|short\\|int\\|long\\|float\\|double\\|boolean\\)" type)
2692 (or (string-match "\\[.*\\]" name) (string-match "\\[.*\\]" type)))
2693 (let ((array (replace-regexp-in-string "\\[.*\\]" "" name)))
2694 (concat "java.util.Arrays.hashCode(" array ")")))
2696 ((or (string-match "\\[.*\\]" name) (string-match "\\[\\]" type))
2697 (let ((array (replace-regexp-in-string "\\[.*\\]" "" name)))
2698 (concat "java.util.Arrays.deepHashCode(" array ")")))
2701 ((or (semantic-tag-of-type-p tag "byte")
2702 (semantic-tag-of-type-p tag "char")
2703 (semantic-tag-of-type-p tag "short"))
2704 (concat "(int) " name))
2706 ((semantic-tag-of-type-p tag "int") name)
2707 ((semantic-tag-of-type-p tag "long")
2708 (concat "(int) (" name " ^ (" name " >> 32))" ))
2710 ((semantic-tag-of-type-p tag "boolean")
2711 (concat "(" name " ? 1 : 0)"))
2714 ((semantic-tag-of-type-p tag "float")
2715 (concat "Float.floatToIntBits(" name ")" ))
2716 ((semantic-tag-of-type-p tag "double")
2717 (concat "(int) (Double.doubleToLongBits(" name ") ^ (Double.doubleToLongBits(" name ") >> 32))" ))
2720 ;; object references
2722 (concat "(" name " == null ? " (jde-gen-hashcode-next-prime)
2723 " : " name ".hashCode())"))) ";"
2726 "return " var ";")))
2728 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2729 ;;;_* toString method generator
2730 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2733 (defcustom jde-gen-tostring-method-template
2736 "\" * Get a string representation of this object.\" '> 'n"
2738 "\" * @return a string representation of this object.\" '> 'n"
2740 "\" * @see java.lang.Object#toString\" '> 'n"
2742 "(jde-gen-method-signature \"public\" \"String\" \"toString\" \"\")"
2743 "(jde-gen-electric-brace)"
2744 "(jde-gen-tostring-return) '> 'n"
2746 "(jde-import-one-class \"org.apache.commons.lang.builder.ToStringBuilder\")")
2747 "*Template for creating an toString method.
2748 Setting this variable defines a template instantiation
2749 command `jde-gen-tostring-method', as a side-effect."
2751 :type '(repeat string)
2752 :set '(lambda (sym val)
2753 (defalias 'jde-gen-tostring-method
2754 (tempo-define-template
2755 "java-tostring-method"
2756 (jde-gen-read-template val)
2758 "Create an toString method at the current point."))
2759 (set-default sym val)))
2762 (defun jde-gen-tostring-return (&optional class)
2763 "Generate a body of an appropriate override for the
2764 java.lang.Object#toString function. This gets the member variables
2765 of the current class from semantic via `semantic-current-tag'.
2767 This uses the ToStringBuilder class from the jakarta commons lang project.
2770 (let* ((class-tag (or class (semantic-current-tag)))
2771 (class-name (semantic-tag-name class-tag))
2772 (members (jde-parse-get-member-variables class-tag))
2773 (super (car (semantic-tag-type-superclasses class-tag)))
2774 (extends (and super (not (string= "Object" super)))))
2776 "return new ToStringBuilder(this)" ' > 'n
2777 (if extends (list 'l ".appendSuper(super.toString())" '> 'n))
2780 (let ((name (semantic-tag-name tag)))
2781 (list 'l ".append(\"" name "\", " name ")" '> 'n))) members))
2784 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2785 ;;;_* Generate all object methods
2786 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2789 (defun jde-gen-object-methods ()
2790 "Generates an equals(), a hashCode() and a toString method."
2792 (jde-gen-equals-method)
2793 (newline-and-indent)
2794 (jde-gen-hashcode-method)
2795 (newline-and-indent)
2796 (jde-gen-tostring-method))
2799 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2800 ;;;_* Exception class wizard
2801 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2804 (defcustom jde-gen-exception-buffer-template
2806 "(open-line 1) (funcall jde-gen-boilerplate-function)"
2807 "(jde-gen-get-package-statement)"
2808 "(progn (require 'jde-javadoc) (jde-javadoc-insert-start-block))"
2809 "\" * Exception <code>\" (jde-parse-get-buffer-unqualified-class) \"</code>.\" '> 'n"
2810 "\" \" (jde-javadoc-insert-empty-line)"
2811 "\" * Created: \" (current-time-string) '> 'n"
2812 "\" \" (jde-javadoc-insert-empty-line)"
2813 "\" \" (jde-gen-save-excursion (jde-javadoc-insert 'tempo-template-jde-javadoc-author-tag))"
2814 "\" \" (jde-gen-save-excursion (jde-javadoc-insert 'tempo-template-jde-javadoc-version-tag))"
2815 "\" \" (jde-javadoc-insert-end-block)"
2817 "(jde-parse-get-buffer-unqualified-class)" "\" \" (jde-gen-get-extend-class)"
2818 "(jde-gen-electric-brace)"
2821 ;; Default constructor
2822 "'> (jde-javadoc-insert-start-block)"
2823 "\"* Constructs a new <code>\" (jde-parse-get-buffer-unqualified-class) \"</code> with\" '>'n"
2824 "\"* <code>null</code> as its detail message.\" '>'n"
2825 "'> (jde-javadoc-insert-end-block)"
2826 "(jde-gen-method-signature \"public\" nil (jde-parse-get-buffer-unqualified-class) nil)"
2827 "(jde-gen-electric-brace)"
2829 ;; leave a blank line with no indentation
2832 ;; Constructor with message
2833 "'> (jde-javadoc-insert-start-block)"
2834 "\"* Constructs a new <code>\" (jde-parse-get-buffer-unqualified-class) \"</code> with\" '>'n"
2835 "\"* the specified detail message.\" '>'n"
2836 "'> (jde-javadoc-insert-empty-line)"
2837 "\"* @param message the detail message string.\" '> 'n"
2838 "'> (jde-javadoc-insert-end-block)"
2839 "(jde-gen-method-signature \"public\" nil (jde-parse-get-buffer-unqualified-class) \"String message\")"
2840 "(jde-gen-electric-brace)"
2841 "\"super(message);\" '> 'n"
2843 ;; leave a blank line with no indentation
2846 ;; Constructor with a cause
2847 "'> (jde-javadoc-insert-start-block)"
2848 "\"* Constructs a new <code>\" (jde-parse-get-buffer-unqualified-class) \"</code> with\" '>'n"
2849 "\"* the specified cause and a detail message of\" '> 'n"
2850 "\"* <code>(cause == null ? null : cause.toString())</code>\" '> 'n"
2851 "\"* (which typically contains the class and detail message of cause).\" '> 'n"
2852 "'> (jde-javadoc-insert-empty-line)"
2853 "\"* @param cause the causing throwable. A null value is permitted\" '> 'n"
2854 "\"* and indicates that the cause is nonexistent or unknown.\" '> 'n"
2855 "'> (jde-javadoc-insert-end-block)"
2856 "(jde-gen-method-signature \"public\" nil (jde-parse-get-buffer-unqualified-class) \"Throwable cause\")"
2857 "(jde-gen-electric-brace)"
2858 "\"super(cause == null ? (String) null : cause.toString());\" '> 'n"
2859 "\"initCause(cause);\" '> 'n"
2861 ;; leave a blank line with no indentation
2864 ;; Constructor with a message and a cause
2865 "'> (jde-javadoc-insert-start-block)"
2866 "\"* Constructs a new <code>\" (jde-parse-get-buffer-unqualified-class) \"</code> with\" '>'n"
2867 "\"* the specified cause and message.\" '> 'n"
2868 "'> (jde-javadoc-insert-empty-line)"
2869 "\"* @param message the detail message string.\" '> 'n"
2870 "\"* @param cause the causing throwable. A null value is permitted\" '> 'n"
2871 "\"* and indicates that the cause is nonexistent or unknown.\" '> 'n"
2872 "'> (jde-javadoc-insert-end-block)"
2873 "(jde-gen-method-signature \"public\" nil (jde-parse-get-buffer-unqualified-class) \"String message,Throwable cause\")"
2874 "(jde-gen-electric-brace)"
2875 "\"super(message);\" '> 'n"
2876 "\"initCause(cause);\" '> 'n"
2878 ;; leave a blank line with no indentation
2880 "\"}\" '>" "(if jde-gen-comments (concat \" // \" (jde-parse-get-buffer-unqualified-class)))"
2882 "*Template for a new exception class.
2883 Setting this variable defines a template instantiation
2884 command `jde-gen-exception', as a side-effect."
2886 :type '(repeat string)
2887 :set '(lambda (sym val)
2888 (tempo-define-template "java-exception-buffer-template"
2889 (jde-gen-read-template val)
2891 "Insert a generic Java exception buffer skeleton.")
2892 (defalias 'jde-gen-exception
2893 (list 'lambda (list)
2895 (list 'tempo-template-java-exception-buffer-template)))
2896 (set-default sym val)))
2899 (defun jde-gen-exception-buffer (file)
2900 "Create a new Java buffer containing an exception class of the same name.
2901 This command inserts the template generated by `jde-gen-exception'.
2902 It then moves the point to the location of the first method."
2905 (jde-gen-exception))
2908 (defcustom jde-gen-code-templates
2909 (list (cons "Get Set Pair" 'jde-gen-get-set)
2910 (cons "main method" 'jde-gen-main-method)
2911 (cons "toString Method (Apache)" 'jde-gen-tostring-method)
2912 (cons "Equals Method" 'jde-gen-equals-method)
2913 (cons "Hash Code Method" 'jde-gen-hashcode-method)
2914 (cons "Deep clone" 'jde-gen-deep-clone)
2915 (cons "Action Listener" 'jde-gen-action-listener)
2916 (cons "Change Listener" 'jde-gen-change-listener)
2917 (cons "Window Listener" 'jde-gen-window-listener)
2918 (cons "Mouse Listener" 'jde-gen-mouse-listener)
2919 (cons "Mouse Motion Listener" 'jde-gen-mouse-motion-listener)
2920 (cons "Inner Class" 'jde-gen-inner-class)
2921 (cons "println" 'jde-gen-println)
2922 (cons "beep" 'jde-gen-beep)
2923 (cons "property change support" 'jde-gen-property-change-support)
2924 (cons "EJB Entity Bean" 'jde-gen-entity-bean)
2925 (cons "EJB Session Bean" 'jde-gen-session-bean)
2927 "*Specifies available autocode templates.
2928 The value of this variable is an association list. The car of
2929 each element specifies a template name. The cdr specifies
2930 a command that inserts the template into a buffer. See the function
2931 `tempo-define-template' for any easy way to create a template
2935 (cons :tag "Template"
2936 (string :tag "Name")
2937 (function :tag "Command")))
2938 :set '(lambda (sym val)
2939 (let ((n (length val))
2941 (setq jde-gen-template-names (list))
2943 (setq jde-gen-template-names
2945 jde-gen-template-names
2946 (list (cons (car (nth i val)) (1+ i)))))
2948 (set-default sym val)))
2950 (defun jde-gen-code (name)
2951 "Insert the code template specified by NAME at point.
2952 The template must be one of those specified by the
2953 variable `jde-gen-code-templates'."
2956 (completing-read "Template name: " jde-gen-template-names)))
2957 (funcall (cdr (assoc name jde-gen-code-templates))))
2961 ;;; Control Flow Templates
2962 ;;; Contributed by Eric D. Friedman <friedman@lmi.net>
2964 (defvar jde-gen-abbrev-templates nil
2965 "List of abbreviation templates defined by
2966 `jde-gen-define-abbrev-template'.")
2968 (defun jde-gen-define-abbrev-template (abbrev template)
2969 "Defines a TEMPLATE that replaces ABBREV when you type ABBREV
2970 in a JDE source buffer. TEMPLATE is a list of tempo template
2971 elements. See `tempo-define-template' for information on
2972 template elements. The resulting template is added to the
2973 list bound to `jde-gen-abbrev-templates'. "
2974 (let ((template-name (concat "jde-gen-" abbrev)))
2975 (defalias (intern template-name)
2976 (tempo-define-template
2980 (format "JDE template for %s control flow abbreviation." abbrev)
2981 'jde-gen-abbrev-templates))))
2983 (defcustom jde-gen-cflow-enable t
2984 "Enables abbreviations for Java control flow constructs."
2989 (defcustom jde-gen-comments nil
2990 "*If no-nil, use comments, else do not use comments.
2995 } catch (Exception e) {
2997 } // end of try-catch
3004 } catch (Exception e) {
3008 Setting this variable to t, uses comments in skeletons and templates."
3012 ;; (makunbound 'jde-gen-cflow-if)
3013 (defcustom jde-gen-cflow-if
3015 "'> \"if\" jde-gen-conditional-padding-1 "
3016 "\"(\" jde-gen-conditional-padding-2 (p \"if-clause: \" clause)"
3017 " jde-gen-conditional-padding-2 \")\""
3018 "(jde-gen-electric-brace jde-gen-conditional-padding-3)"
3021 "(if jde-gen-comments "
3022 "'(l \" // end of if (\" (s clause) \")\"))"
3025 "Skeleton if statement. To insert the if statement at point, type if
3026 and then space. Note that abbrev mode must be enabled. See
3027 `jde-enable-abbrev-mode'"
3029 :type '(repeat string)
3030 :set '(lambda (sym val)
3031 (jde-gen-define-abbrev-template
3033 (jde-gen-read-template val))
3034 (set-default sym val)))
3036 (defcustom jde-gen-cflow-else
3039 "(jde-gen-electric-brace jde-gen-conditional-padding-3)"
3042 "(if jde-gen-comments "
3043 " '(l \" // end of else\"))"
3046 "Skeleton else statement. To insert the statement at point, type else
3047 and then space. Note that abbrev mode must be enabled. See
3048 `jde-enable-abbrev-mode' for more information."
3050 :type '(repeat string)
3051 :set '(lambda (sym val)
3052 (jde-gen-define-abbrev-template
3054 (jde-gen-read-template val))
3055 (set-default sym val)))
3057 (defcustom jde-gen-cflow-if-else
3059 "'> \"if\" jde-gen-conditional-padding-1 "
3060 "\"(\" jde-gen-conditional-padding-2 (p \"if-clause: \" clause)"
3061 " jde-gen-conditional-padding-2 \")\""
3062 "(jde-gen-electric-brace jde-gen-conditional-padding-3)"
3065 "(if jde-gen-comments "
3066 " '(l \" // end of if (\" (s clause) \")\" '>'n)"
3068 " jde-gen-conditional-padding-3 "
3071 "(jde-gen-electric-brace jde-gen-conditional-padding-3)"
3074 "(if jde-gen-comments "
3075 " '(l \" // end of if (\" (s clause) \") else\"))"
3078 "Skeleton if-else statement. To insert the statement at point, type ife
3079 and then space. Note that abbrev mode must be enabled. See
3080 `jde-enable-abbrev-mode' for more information."
3082 :type '(repeat string)
3083 :set '(lambda (sym val)
3084 (jde-gen-define-abbrev-template
3086 (jde-gen-read-template val))
3087 (set-default sym val)))
3089 (defcustom jde-gen-cflow-else-if
3091 "'> \"else if\" jde-gen-conditional-padding-1 "
3092 "\"(\" jde-gen-conditional-padding-2 (p \"else-if-clause: \" clause) "
3093 " jde-gen-conditional-padding-2 \")\""
3094 "(jde-gen-electric-brace jde-gen-conditional-padding-3)"
3097 "(if jde-gen-comments "
3098 " '(l \" // end of else if (\" (s clause) \")\"))"
3101 "Skeleton else-if statement. To insert the statement at point, type eif
3102 and then space. Note that abbrev mode must be enabled. See
3103 `jde-enable-abbrev-mode' for more information."
3105 :type '(repeat string)
3106 :set '(lambda (sym val)
3107 (jde-gen-define-abbrev-template
3109 (jde-gen-read-template val))
3110 (set-default sym val)))
3112 ;; (makunbound 'jde-gen-cflow-while)
3113 (defcustom jde-gen-cflow-while
3115 "'> \"while\" jde-gen-conditional-padding-1 "
3116 "\"(\" jde-gen-conditional-padding-2 (p \"while-clause: \" clause) "
3117 " jde-gen-conditional-padding-2 \")\""
3118 "(jde-gen-electric-brace jde-gen-conditional-padding-3)"
3121 "(if jde-gen-comments "
3122 " '(l \" // end of while (\" (s clause) \")\"))"
3125 "Skeleton while statement. To insert the statement at point, type while
3126 and then space. Note that abbrev mode must be enabled. See
3127 `jde-enable-abbrev-mode' for more information."
3129 :type '(repeat string)
3130 :set '(lambda (sym val)
3131 (jde-gen-define-abbrev-template
3133 (jde-gen-read-template val))
3134 (set-default sym val)))
3136 (defcustom jde-gen-cflow-for
3138 "'> \"for\" jde-gen-conditional-padding-1 "
3139 "\"(\" jde-gen-conditional-padding-2 (p \"for-clause: \" clause) "
3140 " jde-gen-conditional-padding-2 \")\""
3141 "(jde-gen-electric-brace jde-gen-conditional-padding-3)"
3144 "(if jde-gen-comments "
3145 " '(l \" // end of for (\" (s clause) \")\"))"
3148 "Skeleton for statement. To insert the statement at point, type for
3149 and then space. Note that abbrev mode must be enabled. See
3150 `jde-enable-abbrev-mode' for more information."
3152 :type '(repeat string)
3153 :set '(lambda (sym val)
3154 (jde-gen-define-abbrev-template
3156 (jde-gen-read-template val))
3157 (set-default sym val)))
3159 (defcustom jde-gen-cflow-for-i
3161 "'> \"for\" jde-gen-conditional-padding-1 "
3162 "\"(\" jde-gen-conditional-padding-2 \"int \" (p \"variable: \" var) "
3163 "\" = 0; \" (s var) \" < \" (p \"upper bound: \" upper-bound) \"; \" (s var) \"++\""
3164 " jde-gen-conditional-padding-2 \")\""
3165 "(jde-gen-electric-brace jde-gen-conditional-padding-3)"
3168 "(if jde-gen-comments "
3169 " '(l \" // end of for (int \" (s var) \" = 0; \""
3170 "(s var) \" < \" (s upper-bound) \"; \" (s var) \"++)\"))"
3173 "Skeleton for i statement. To insert the statement at point, type fori
3174 and then space. Note that abbrev mode must be enabled. See
3175 `jde-enable-abbrev-mode' for more information.
3177 Note: `tempo-interactive' must be set to a non-nil value to be prompted
3178 for variable name and upper-bounds information."
3180 :type '(repeat string)
3181 :set '(lambda (sym val)
3182 (jde-gen-define-abbrev-template
3184 (jde-gen-read-template val))
3185 (set-default sym val)))
3187 (defcustom jde-gen-cflow-for-iter
3189 "'> \"for\" jde-gen-conditional-padding-1 "
3190 "\"(\" jde-gen-conditional-padding-2 \"Iterator \" (p \"variable: \" var) "
3191 "\" = \" (p \"collection: \" coll) \".iterator(); \""
3192 "(s var) \".hasNext();\""
3193 " jde-gen-conditional-padding-2 \")\""
3194 "(jde-gen-electric-brace jde-gen-conditional-padding-3)"
3196 "(s var) \".next();\" '>'n'>"
3198 "(if jde-gen-comments "
3199 " '(l \" // end of for (Iterator \" (s var) \" = \" (s coll)"
3200 " \".iterator(); \" (s var) \".hasNext();)\"))"
3203 "Skeleton for iterator statement. To insert the statement at point,
3204 type foriter and then space. Note that abbrev mode must be
3205 enabled. See `jde-enable-abbrev-mode' for more information.
3207 Note: `tempo-interactive' must be set to a non-nil value to be prompted
3208 for variable name and collection name information."
3210 :type '(repeat string)
3211 :set '(lambda (sym val)
3212 (jde-gen-define-abbrev-template
3214 (jde-gen-read-template val))
3215 (set-default sym val)))
3217 (defcustom jde-gen-cflow-switch
3219 "'> \"switch\" jde-gen-conditional-padding-1 "
3220 " \"(\" jde-gen-conditional-padding-2 (p \"switch-condition: \" clause) "
3221 " jde-gen-conditional-padding-2 \")\""
3223 "(jde-gen-electric-brace jde-gen-conditional-padding-3)"
3224 "\"case \" (p \"first value: \" first-value) \":\"'>'n"
3225 "'p'n" ;; point will end up here
3227 "\"default:\"'>'n'>"
3230 "(if jde-gen-comments "
3231 " '(l \" // end of switch (\" (s clause) \")\"))"
3234 "Skeleton switch statement. To insert the statement at point, type switch
3235 and then space. Note that abbrev mode must be enabled. See
3236 `jde-enable-abbrev-mode' for more information."
3238 :type '(repeat string)
3239 :set '(lambda (sym val)
3240 (jde-gen-define-abbrev-template
3242 (jde-gen-read-template val))
3243 (set-default sym val)))
3245 (defcustom jde-gen-cflow-case
3247 "\"case \" (p \"value: \" value) \":\"'>'n"
3248 "'p'n" ;; point will end up here
3251 "Skeleton case statement. To insert the statement at point, type case
3252 and then space. Note that abbrev mode must be enabled. See
3253 `jde-enable-abbrev-mode' for more information."
3255 :type '(repeat string)
3256 :set '(lambda (sym val)
3257 (jde-gen-define-abbrev-template
3259 (jde-gen-read-template val))
3260 (set-default sym val)))
3262 ;; (makunbound 'jde-gen-cflow-try-catch)
3263 (defcustom jde-gen-cflow-try-catch
3266 "(jde-gen-electric-brace)"
3270 ;; "(if jde-gen-k&r "
3271 ;; " jde-gen-conditional-padding-3 "
3274 "(if jde-gen-comments "
3275 " '(l \" // end of try\" '>'n)"
3277 " jde-gen-conditional-padding-3 "
3280 "\"catch\" jde-gen-conditional-padding-1 "
3281 "\"(\" jde-gen-conditional-padding-2 (p \"catch what: \" clause) \" e\""
3282 " jde-gen-conditional-padding-2 \")\" '>"
3283 "(jde-gen-electric-brace jde-gen-conditional-padding-3)"
3286 " (if jde-gen-comments "
3287 " '(l \" // end of try-catch\"))"
3290 "Skeleton try-catch statement. To insert the statement at point, type try
3291 and then space. Note that abbrev mode must be enabled. See
3292 `jde-enable-abbrev-mode' for more information."
3294 :type '(repeat string)
3295 :set '(lambda (sym val)
3296 (jde-gen-define-abbrev-template
3298 (jde-gen-read-template val))
3299 (set-default sym val)))
3301 (defcustom jde-gen-cflow-catch
3303 "'> \"catch\" jde-gen-conditional-padding-1 "
3304 "\"(\" jde-gen-conditional-padding-2 (p \"catch what: \" clause) \" e\""
3305 " jde-gen-conditional-padding-2 \")\""
3306 "(jde-gen-electric-brace jde-gen-conditional-padding-3)"
3309 "(if jde-gen-comments "
3310 " '(l \" // end of catch\"))"
3313 "Skeleton catch statement. To insert the statement at point, type catch
3314 and then space. Note that abbrev mode must be enabled. See
3315 `jde-enable-abbrev-mode' for more information."
3317 :type '(repeat string)
3318 :set '(lambda (sym val)
3319 (jde-gen-define-abbrev-template
3321 (jde-gen-read-template val))
3322 (set-default sym val)))
3324 (defcustom jde-gen-cflow-try-finally
3327 "(jde-gen-electric-brace)"
3331 " jde-gen-conditional-padding-3 "
3333 "\"catch\" jde-gen-conditional-padding-1 "
3334 "\"(\" jde-gen-conditional-padding-2 (p \"catch what: \" clause) \" e\""
3335 " jde-gen-conditional-padding-2 \")\" '>"
3336 "(jde-gen-electric-brace jde-gen-conditional-padding-3)"
3340 " jde-gen-conditional-padding-3 "
3343 "(jde-gen-electric-brace jde-gen-conditional-padding-3)"
3346 "(if jde-gen-comments "
3347 " '(l \" // end of try-finally\"))"
3350 "Skeleton try-catch-finally statement. To insert the statement at point, type
3351 tryf and then space. Note that abbrev mode must be enabled. See
3352 `jde-enable-abbrev-mode' for more information."
3354 :type '(repeat string)
3355 :set '(lambda (sym val)
3356 (jde-gen-define-abbrev-template
3358 (jde-gen-read-template val))
3359 (set-default sym val)))
3361 (defcustom jde-gen-cflow-finally
3364 "(jde-gen-electric-brace jde-gen-conditional-padding-3)"
3367 "(if jde-gen-comments "
3368 " '(l \" // end of finally\"))"
3371 "Skeleton finally statement. To insert the statement at point, type finally
3372 and then space. Note that abbrev mode must be enabled. See
3373 `jde-enable-abbrev-mode' for more information."
3375 :type '(repeat string)
3376 :set '(lambda (sym val)
3377 (jde-gen-define-abbrev-template
3379 (jde-gen-read-template val))
3380 (set-default sym val)))
3382 (defun jde-gen-abbrev-hook ()
3383 "Abbreviation hook. Inserts an abbreviation template.
3384 Abbreviation name is deleted from buffer before the template is inserted.
3385 This function does nothing, if point is in a comment or string.
3386 Returns t, if the template has been inserted, otherwise nil."
3387 (unless (jde-parse-comment-or-quoted-p)
3388 (let* ((abbrev-start
3389 (or abbrev-start-location
3390 (save-excursion (re-search-backward "\\<.*\\="))))
3392 (buffer-substring-no-properties abbrev-start (point)))
3393 (template (assoc-ignore-case abbrev jde-gen-abbrev-templates)))
3396 (delete-backward-char (length abbrev))
3397 ;; Following let avoids infinite expansion.
3398 ;; Infinite expansions could be caused by
3399 ;; (newline) in templates.
3400 ;; e.g. "else" (newline)
3401 (let (local-abbrev-table)
3402 (funcall (cdr template)))
3403 t) ; don't insert self-inserting input character that triggered the expansion.
3404 (error "Template for abbreviation %s not found!" abbrev)))))
3406 ;; The following enables the hook to control the treatment of the
3407 ;; self-inserting input character that triggered the expansion.
3408 (put 'jde-gen-abbrev-hook 'no-self-insert t)
3410 (defun jde-gen-load-abbrev-templates ()
3411 "Defines jde-mode abbrevs for the control flow templates."
3412 (loop for template in jde-gen-abbrev-templates do
3413 (let ((abbrev (car template)))
3417 (if (featurep 'xemacs) abbrev t) ;; Hack (see note below)
3418 'jde-gen-abbrev-hook
3421 ;; Note: the previous function uses the following hack to address the
3422 ;; problem of preventing expansion of control flow abbreviations in
3423 ;; comments and strings. The hack defines the abbreviation such that
3424 ;; abbrev-mode doesn't replace the abbreviation.
3425 ;; If the abbreviation is not in a string or comment, the hook
3426 ;; then erases the abbreviation and replaces it with the corresponding
3427 ;; control flow expansion. If the abbreviation is in a string or
3428 ;; comment, the hook does nothing, simply leaving the abbreviation
3429 ;; as the user typed it.
3431 (defun jde-gen-test-cflow-templates ()
3433 (set-buffer (get-buffer-create "*jde-cflow-test*"))
3436 (insert "public class Test {\n\n}")
3438 (loop for flags in '((t . t) (t . nil) (nil . t) (nil . nil)) do
3439 (let ((jde-gen-k&r (car flags))
3440 (jde-gen-comments (cdr flags)))
3441 (insert (format "/**** jde-gen-comments: %S jde-gen-k&r: %S ****/\n\n"
3442 jde-gen-comments jde-gen-k&r))
3444 '(("if" (clause . "true"))
3446 ("ife" (clause . "true"))
3447 ("eif" (clause . "true"))
3448 ("while" (clause . "true"))
3449 ("for" (clause . "int i = 0; i < 10; i++"))
3450 ("fori" (var . "i") (upper-bound . "10"))
3451 ("foriter" (var . "iter") (coll . "list"))
3452 ("switch" (clause . "digit") (first-value . "1"))
3453 ("case" (value . "2"))
3454 ("try" (clause . "Exception"))
3455 ("catch" (clause . "Exception"))
3456 ("tryf" (clause . "Exception"))
3460 (abbrev-start-location (point)))
3461 (insert (car abbrev))
3462 (while (setq abbrev (cdr abbrev))
3463 (setq insertations (car abbrev))
3464 (tempo-save-named (car insertations) (cdr insertations)))
3465 (jde-gen-abbrev-hook)
3466 (goto-char (- (point-max) 2))
3471 (defun jde-gen-try-catch-wrapper (beg end)
3472 "Wrap the region from BEG to END into a try/catch block.
3473 BEG and END are modified so the region only contains complete lines."
3475 (jde-gen-generic-wrapper beg end "try" "catch"))
3477 (defun jde-gen-try-finally-wrapper (beg end)
3478 "Wrap the region from BEG to END into a try/finally block.
3479 BEG and END are modified so the region only contains complete lines."
3481 (jde-gen-generic-wrapper beg end "try" "finally"))
3483 (defun jde-gen-if-wrapper (beg end)
3484 "Wraps the region from beg to end into an if block."
3486 (jde-gen-generic-wrapper beg end "if"))
3488 (defun jde-gen-if-else-wrapper (beg end)
3489 "Wraps the region from beg to end into an if block."
3491 (jde-gen-generic-wrapper beg end "if" "else"))
3493 ;;This code is a modified version of the method qflib-make-try-wrapper
3494 (defun jde-gen-generic-wrapper (beg end expr1 &optional expr2)
3495 "Wrap the region from BEG to END into a EXPR1 and EXPR2 block. if EXPR2 is
3496 nil it is omitted. BEG and END are modified so the region only contains
3498 (let ((to (make-marker))
3499 indent-region-function)
3511 (if (string= expr1 "if")
3512 (insert (concat jde-gen-conditional-padding-1
3513 "(" jde-gen-conditional-padding-2 ")")))
3521 (indent-for-tab-command)
3522 (indent-region (point) to nil)
3528 (insert jde-gen-conditional-padding-3)
3530 (if (string= expr2 "catch")
3531 (insert (concat expr2 jde-gen-conditional-padding-1
3532 "(" jde-gen-conditional-padding-2 " e"
3533 jde-gen-conditional-padding-2 ")"))
3536 (insert jde-gen-conditional-padding-3)
3539 (if jde-gen-comments
3540 (insert " // end of " expr1
3542 (concat "-" expr2))))))
3544 (indent-region (marker-position to) (point) nil)
3546 (if (string= expr1 "if")
3547 (search-backward (concat "(" jde-gen-conditional-padding-2 ")")))
3548 (if (string= expr2 "catch")
3549 (search-forward "("))))
3552 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3554 ;; Electric Return Mode ;;
3556 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3558 (defcustom jde-electric-return-p nil
3559 "Specifies whether the JDEE's electric return mode is
3560 enabled for this session or project. This mode causes the JDEE to
3561 match an open brace at the end of a line with a closing
3562 brace. You can use `jde-toggle-electric-return' at any
3563 time to enable or disable eelctric return mode."
3566 :set '(lambda (sym val)
3569 (with-current-buffer jde-current-buffer
3570 jde-current-project)))
3573 (with-current-buffer buf
3574 (let ((key (car (read-from-string "[return]"))))
3576 (define-key (current-local-map) key 'jde-electric-return)
3577 (local-unset-key key)))))
3578 (jde-get-project-source-buffers))))
3579 (setq jde-electric-return-mode val)
3580 (set-default sym val)))
3582 (defcustom jde-newline-function '(newline)
3583 "Indent command that `jde-electric-return' calls."
3586 (radio-button-choice
3589 :entry-format " %b %v"
3591 (const newline-and-indent)
3592 (const align-newline-and-indent)
3593 (function my-custom-newline-function))))
3595 (defun jde-gen-embrace()
3596 "Match an open brace at the end of a line
3597 with a closing brace (if required), put point on a
3598 empty line between the braces, and indent the new lines.
3603 pubic void function () {
3607 pubic void function () {
3611 Point must be at the end of the line, or at a } character
3612 followed by the end of the line.
3614 If it thinks a matching close brace already exists a new one is not inserted.
3616 pubic void function () {
3619 pubic void function () {
3623 (if (or (eq (point) (point-min))
3626 (not (looking-at "{}?$"))))
3627 (newline-and-indent)
3630 (newline-and-indent)
3631 (newline-and-indent)
3632 (when (not (looking-at "}"))
3636 (c-indent-command))))
3638 (defun jde-electric-return ()
3639 "Invokes `jde-gen-embrace' to close an open brace at the end of a line."
3641 (if ;; the current line ends at an open brace.
3644 (re-search-backward "{\\s-*" (line-beginning-position) t))
3645 (looking-at "}?\\s-*$"))
3647 (call-interactively (car jde-newline-function))))
3649 (defvar jde-electric-return-mode nil
3650 "Nonnil indicates that electric return mode is on.")
3652 (defun jde-electric-return-mode ()
3653 "Toggles the JDEE's electric return mode. In electric
3654 return mode, pressing the Enter key causes the JDEE to
3655 close open braces at the end of a line. This command enables
3656 eletric return mode by binding `jde-electric-return' to the
3657 Return key on your keyboard. It disables electric return mode
3658 by rebinding the Return key to its original binding."
3660 (when (boundp 'jde-mode-map)
3661 (let ((key (car (read-from-string "[return]"))))
3662 (if jde-electric-return-mode
3663 (local-unset-key key)
3664 (define-key (current-local-map) key 'jde-electric-return))))
3665 (setq jde-electric-return-mode (not jde-electric-return-mode))
3666 (if jde-electric-return-mode
3667 (message "electric return mode on")
3668 (message "electric return mode off")))
3674 ;; Unit Test Table for JDE Gen Methods
3675 ;; -----------------------------------
3677 ;; Comm = jde-gen-comments|Comm t|Comm nil|Comm t |Comm nil
3678 ;; K&R = jde-gen-k&r |K&R t|K&R t |K&R nil|K&R nil
3679 ;; -------------------------------+------+--------+--------+--------
3680 ;; jde-gen-get-set | | | |
3681 ;; jde-gen-inner-class | | | |
3682 ;; jde-gen-action-listener | | | |
3683 ;; jde-gen-change-listener | | | |
3684 ;; jde-gen-window-listener | | | |
3685 ;; jde-gen-mouse-listener | | | |
3686 ;; jde-gen-mouse-motion-listener | | | |
3687 ;; jde-gen-to-string-method | | | |
3688 ;; jde-gen-property-change-support| | | |
3689 ;; jde-gen-entity-bean | | | |
3690 ;; jde-gen-session-bean | | | |
3691 ;; jde-gen-cflow-if | | | |
3692 ;; jde-gen-cflow-else | | | |
3693 ;; jde-gen-cflow-if-else | | | |
3694 ;; jde-gen-cflow-else-if | | | |
3695 ;; jde-gen-cflow-while | | | |
3696 ;; jde-gen-cflow-for | | | |
3697 ;; jde-gen-cflow-for-I | | | |
3698 ;; jde-gen-cflow-for-iter | | | |
3699 ;; jde-gen-cflow-main | | | |
3700 ;; jde-gen-cflow-switch | | | |
3701 ;; jde-gen-cflow-case | | | |
3702 ;; jde-gen-cflow-try-catch | | | |
3703 ;; jde-gen-cflow-catch | | | |
3704 ;; jde-gen-cflow-try-finally | | | |
3705 ;; jde-gen-cflow-finally | | | |
3707 ;; $Log: jde-gen.el,v $
3708 ;; Revision 1.86 2004/12/12 14:27:02 paulk
3709 ;; Add templates provided by Ole Arndt.
3711 ;; Revision 1.85 2004/11/17 04:56:16 paulk
3712 ;; Update several templates to conform to CheckStyle requirements. Thanks to Martin Schwamberger.
3714 ;; Revision 1.84 2004/10/11 03:40:23 paulk
3715 ;; Moved JUnit templates to jde-junit.el.
3717 ;; Revision 1.83 2004/07/06 05:07:27 paulk
3718 ;; Move require for jde-package to jde-compat.el el allow autoloading of
3719 ;; jde-package without causing compile errors.
3721 ;; Revision 1.82 2004/07/06 04:17:13 paulk
3722 ;; Require jde-package and other changes intended to eliminate byte-compilation errors.
3724 ;; Revision 1.81 2004/07/06 01:43:55 paulk
3725 ;; Fix bug that caused inconsistent enabling of electric return mode.
3727 ;; Revision 1.80 2004/06/29 03:39:29 paulk
3730 ;; Revision 1.79 2004/05/28 11:40:12 paulk
3731 ;; Add jde-gen-main-method to jde-gen-code-templates.
3733 ;; Revision 1.78 2004/05/14 03:24:01 paulk
3734 ;; - Compatibility fix to make cflow abbreviations work in XEmacs.
3735 ;; Thanks to Martin Schwamberger.
3736 ;; - Provide a new JDE->Code Generation->Modes menu with items for
3737 ;; enabling abbrev mode and electric return mode.
3739 ;; Revision 1.77 2004/05/14 02:13:04 paulk
3740 ;; Add jde-gen-test-cflow-templates command.
3742 ;; Revision 1.76 2004/05/04 04:35:09 paulk
3743 ;; - Reworks the cflow templates so that tempo is no longer invoked if point is in an comment or string.
3744 ;; - jde-gen-comments now defaults to nil to permit control flow templates to conform to style guidelines.
3745 ;; - Cosmetic changes.
3747 ;; Thanks to Martin Schwamberger.
3749 ;; Revision 1.75 2004/04/30 05:42:59 paulk
3750 ;; Implements electric return mode.
3752 ;; Revision 1.74 2004/03/24 02:32:59 paulk
3753 ;; Correct version of jde-gen-save-excursion from Martin Schwamberger.
3755 ;; Revision 1.73 2004/03/22 06:11:32 paulk
3756 ;; Changes by made Martin Schwamberg as part of his project to make the JDEE templates
3757 ;; conform to CheckStyle default style:
3759 ;; jde-gen-read-template
3760 ;; - separates lines by newline in order to allow lisp comments.
3762 ;; jde-gen-final-argument-modifier
3763 ;; - inserts final modifier to each method argument
3764 ;; if jde-gen-final-arguments is t.
3766 ;; jde-gen-final-method-modifier
3767 ;; - inserts final modifier to methods if jde-gen-final-methods is t
3768 ;; and the class itself is not final.
3770 ;; jde-gen-save-excursion
3771 ;; - allows invocation of tempo-templates within tempo-templates.
3773 ;; jde-gen-electric-brace
3774 ;; - named after c-electric-brace, which is a candidate
3775 ;; as a replacement of the current code once all
3776 ;; templates use this function.
3777 ;; - inserts brace according to jde-gen-k&r.
3779 ;; jde-gen-class-buffer-template
3780 ;; jde-gen-interface-buffer-template
3781 ;; jde-gen-get-set-var-template
3782 ;; jde-gen-method-template
3785 ;; - indents a line only if it is empty
3787 ;; jde-gen-get-interface-implementation
3788 ;; - new argument insert-immediately.
3789 ;; - made insertion point a marker.
3791 ;; jde-gen-method-signature
3792 ;; - inserts final modifiers using jde-gen-final-argument-modifier
3793 ;; and jde-gen-final-methods.
3795 ;; jde-gen-class-buffer-template
3796 ;; - completely reworked.
3798 ;; jde-gen-class-buffer
3799 ;; - subsequent template manipulation removed.
3801 ;; jde-gen-interface-buffer-template
3802 ;; - completely reworked.
3804 ;; jde-gen-interface-buffer
3805 ;; - subsequent template manipulation removed.
3807 ;; jde-gen-get-set-var-template
3810 ;; jde-gen-method-template
3813 ;; jde-gen-section-comment-template
3814 ;; - removed: "(end-of-line) '&"
3816 ;; Revision 1.72 2004/03/04 05:19:38 paulk
3817 ;; Adds the jde-gen-embrace command. Thanks to Suraj Acharya.
3819 ;; Revision 1.71 2004/02/02 07:31:13 paulk
3820 ;; Adds jde-gen-bean-template. Thanks to Paul Landes.
3822 ;; Revision 1.70 2003/11/30 05:00:50 paulk
3823 ;; Fix control flow templates to preserve case of unexpanded
3824 ;; abbreviations in comments and strings.
3826 ;; Revision 1.69 2003/09/22 03:14:55 paulk
3827 ;; Restore missing parentheses.
3829 ;; Revision 1.68 2003/09/22 02:44:04 paulk
3830 ;; Fix bug that was causing an extraneous space to be inserted in the
3831 ;; condition clause of control flow expansions, such as if. Thanks to
3834 ;; Revision 1.67 2003/09/01 03:04:23 paulk
3835 ;; Updates docstring for jde-gen-method-template to document its
3836 ;; dependence on the new jde-gen-method-javadoc-comment variable.
3838 ;; Revision 1.66 2003/09/01 02:53:30 paulk
3839 ;; Adds a customization variable, jde-gen-method-javadoc-comment,
3840 ;; that enables you to specify the type of javadoc comment
3841 ;; that the jde-gen-method-template generates for a skeleton method.
3843 ;; Revision 1.65 2003/07/26 04:22:46 paulk
3844 ;; Removed superfluous c-indent-function from control flow templates.
3846 ;; Revision 1.64 2003/06/13 12:11:30 paulk
3847 ;; Fix typo. Update copyright.
3849 ;; Revision 1.63 2003/03/03 14:51:26 jslopez
3850 ;; Fixes a few formatting problems with jde-gen-generic-wrapper.
3852 ;; Revision 1.62 2003/03/01 00:04:29 jslopez
3853 ;; Add jde-gen-if-wrapper and jde-gen-if-else-wrapper.
3855 ;; Revision 1.61 2003/02/17 21:39:43 jslopez
3856 ;; Fixes bug with jde-gen-change-listener-template.
3858 ;; Revision 1.60 2003/01/21 14:15:53 jslopez
3859 ;; Adds jde-gen-change-listener template.
3861 ;; Revision 1.59 2002/12/19 06:36:00 paulk
3862 ;; Changed to permit autoloading of jde-package.el file.
3864 ;; Revision 1.58 2002/12/13 08:33:23 paulk
3865 ;; Enhance the following code templates
3867 ;; - jde-gen-interface-buffer-template
3868 ;; - jde-gen-console-buffer-template
3869 ;; - jde-gen-jfc-app-buffer-template
3870 ;; - jde-gen-junit-test-class-buffer-template
3872 ;; to use the following javadoc templates instead of
3875 ;; - jde-javadoc-author-tag-template
3876 ;; - jde-javadoc-version-tag-template
3877 ;; - jde-javadoc-end-block-template
3879 ;; Thanks to Peter Dobratz <dobratzp@ele.uri.edu>.
3881 ;; Revision 1.57 2002/11/30 03:59:27 paulk
3882 ;; Changes the default value for jde-gen-class-buffer-template to use the
3883 ;; relevant tempo-template-jde-javadoc instead of literal text. This way
3884 ;; jde-gen-class-buffer reflects, for example, a change to
3885 ;; tempo-template-jde-javadoc-author-tag. Thanks to Peter Dobratz <dobratzp@ele.uri.edu>.
3887 ;; Revision 1.56 2002/09/30 04:22:45 paulk
3888 ;; Expanded doc strings for jde-gen-entity/session-bean template commands to
3889 ;; explain their usage and to mention the existence of the more complete
3890 ;; jde-ejb-session/entity-buffer commands.
3892 ;; Revision 1.55 2002/08/30 14:52:24 jslopez
3893 ;; Adds new method jde-gen-try-catch-wrapper and jde-gen-try-finally-wrapper.
3894 ;; You can select a region and call this method to wrap the area withing a
3897 ;; Revision 1.54 2002/08/11 14:03:53 paulk
3898 ;; Expanded doc for jde-gen-junit-test-class-buffer.
3900 ;; Revision 1.53 2002/08/11 13:34:18 paulk
3901 ;; Add jde-gen-junit-test-class to list of class buffer templates.
3903 ;; Revision 1.52 2002/06/21 06:42:20 paulk
3904 ;; Fixed bug in interface implementation code for class templates. Thanks to
3905 ;; Phillip Lord for reporting the bug.
3907 ;; Revision 1.51 2002/05/31 19:02:27 mnl
3908 ;; Added new template to generate a new interface from scratch.
3910 ;; Revision 1.50 2002/05/14 06:29:56 paulk
3911 ;; Enhances code generation wizards for implementing interfaces, abstract
3912 ;; classes, etc., to use customizable templates to generate skeleton methods
3913 ;; instead of hard-wired skeletons. Thanks to "Dr. Michael Lipp" <lipp@danet.de>
3914 ;; for proposing and implementing this improvement.
3916 ;; Revision 1.49 2002/04/10 04:18:28 paulk
3917 ;; The JDEE now imports the superclasses of classes that it creates. Thanks
3918 ;; to "Timothy Babin"<tbabin@nortelnetworks.com>.
3920 ;; Revision 1.48 2002/02/03 07:51:16 paulk
3921 ;; Fixes spacing bug in jde-gen-class-buffer-template.
3922 ;; Thanks to Petter Mahlen.
3924 ;; Revision 1.47 2002/01/06 05:59:32 paulk
3925 ;; Changed the name of the println and toString templates to println
3926 ;; and to-string-method, respectively, thereby eliminating the
3927 ;; spaces that were in the previous names.
3929 ;; Revision 1.46 2001/11/21 06:48:09 paulk
3930 ;; Fixed typo jde-gen-signature-padding-3. Thanks to David A. Ventimiglia.
3932 ;; Revision 1.45 2001/11/05 05:01:51 paulk
3933 ;; Removed debugging form.
3935 ;; Revision 1.44 2001/11/03 06:32:11 paulk
3936 ;; Restore JUnit templates.
3938 ;; Revision 1.43 2001/11/02 06:59:58 paulk
3939 ;; Revamps code generation templates to make them more
3940 ;; consistent among themselves and with Java coding
3941 ;; conventions. Specific changes include:
3943 ;; - Generates consistent formats for method signatures.
3944 ;; - Strips prefix and suffix of variable names (if configured)
3945 ;; - Adds jde-gen-conditional-padding-1 to -3 to allow for
3946 ;; configurability of the jde-gen-cflow-* templates
3947 ;; - Changes many default templates to conform to Java code
3949 ;; - Fixes many subtle inconsistencies in templates when used
3950 ;; with different values for jde-gen-comments and jde-gen-k&r
3951 ;; - All templates now have consistent coding structure
3952 ;; and indentation, as well as reduced insertion of white-space.
3953 ;; - Modifies Javadoc comments to be less descriptive of implementation
3954 ;; (e.g. instead of "Get the value of _flag", now is
3955 ;; "Get the Flag value")
3957 ;; Thanks to Greg Fenton.
3959 ;; Revision 1.42 2001/10/25 15:08:30 jslopez
3960 ;; Fixing hard coded strings in the javadoc
3961 ;; for the junit test class template.
3963 ;; Revision 1.41 2001/10/25 02:58:34 jslopez
3964 ;; Fixing bug in JUnit template caused by a class
3965 ;; whose name does not contain the word Test.
3967 ;; Revision 1.40 2001/10/25 02:14:45 jslopez
3968 ;; Adds JUnit supports
3969 ;; Add templates jde-gen-junit-test-class
3970 ;; and jde-gen-junit-add-test-to-suite
3972 ;; Revision 1.39 2001/10/21 06:10:40 paulk
3973 ;; Extends the jde-gen-comments flag to all cflow templates.
3974 ;; Thanks to Robert Mecklenburg <mecklen@cimsoft.com>.
3976 ;; Revision 1.38 2001/08/26 02:14:37 paulk
3977 ;; Fixed catch and tryf templates. Thanks to Javier Lopes.
3979 ;; Revision 1.37 2001/06/30 12:35:28 paulk
3980 ;; Adds jde-gen-define-abbrev-template function.
3982 ;; Revision 1.36 2001/06/10 04:07:05 paulk
3983 ;; Adds a control flow template for a for iterator loop. Thanks to Robert Mecklenburg <mecklen@cimsoft.com>.
3985 ;; Revision 1.35 2001/06/05 05:33:10 paulk
3986 ;; Added else-f control flow template. Thanks to "Javier Lopez" <jlopez@cellexchange.com>.
3988 ;; Revision 1.34 2001/06/05 04:54:49 paulk
3991 ;; Revision 1.33 2001/05/21 06:48:16 paulk
3992 ;; The class buffer template now generates skeletal implementations of interfaces that the class implements. Thanks to Javier Lopez for this enhancement.
3994 ;; The inner class template now generates skeletal implementations of interfaces implemented by the class.
3996 ;; Revision 1.32 2001/03/16 03:57:37 paulk
3997 ;; Fixed author line in javadoc comments. Thanks to Karel.Sprenger@compaq.com.
3999 ;; Revision 1.31 2001/02/22 05:05:29 paulk
4000 ;; The class, console app, and Swing app templates now prompt you to enter a package name. The prompt includes a suggested package name based on the location of the current directory in the classpath.
4002 ;; Revision 1.30 2001/01/19 04:28:09 paulk
4003 ;; Adds cflow expansions for try, catch, and finally. Thanks to Venkatesh Prasad Ranganath <rvprasad@ksu.edu> for these expansions.
4005 ;; Revision 1.29 2000/12/18 05:22:45 paulk
4006 ;; *** empty log message ***
4008 ;; Revision 1.28 2000/09/30 16:50:20 paulk
4009 ;; Correct type in jde-gen-cflow-enable.
4011 ;; Revision 1.27 2000/09/07 04:37:28 paulk
4012 ;; Tweaked get-set pair template to indent correctly. Thanks to Lou Aloia <xlxa@rims.com> for this fix.
4014 ;; Revision 1.26 2000/08/19 05:10:05 paulk
4015 ;; Adds jde-gen-cflow-enable variable.
4017 ;; Revision 1.25 2000/07/23 02:44:44 paulk
4018 ;; Templates now indent correctly when inserted in a buffer. Thanks to el mono <mono@utp.edu.co> for this enhancement.
4020 ;; Revision 1.24 2000/07/20 06:08:59 paulk
4021 ;; Extended K&R coding style to all templates. Thanks to Stephane Nicolas <s.nicolas@videotron.ca> for doing this.
4023 ;; Revision 1.23 2000/06/28 02:46:48 paulk
4024 ;; Get/set pair template now generates correct method name for getting the value of boolean variables. Thanks to Stephane <s.nicolas@videotron.ca> for contributing this fix.
4026 ;; Revision 1.22 2000/06/01 06:43:01 paulk
4027 ;; Added control flow templates contributed by Eric D. Friedman <friedman@lmi.net>.
4029 ;; Revision 1.21 2000/02/01 05:22:51 paulk
4030 ;; Provide choice of coding styles for code generated by templates. Thanks to Jari Aalto for this enhancement.
4032 ;; Revision 1.20 1999/09/23 03:23:41 paulk
4033 ;; Added code templates implementing EJB EntityBean and SessionBean
4034 ;; interfaces. Thanks to Brendan.Burns@tfsma-ims.tfn.com for contributing
4037 ;; Revision 1.19 1999/08/29 04:29:18 paulk
4038 ;; Patches provided by Michael Ernst <mernst@alum.mit.edu>
4040 ;; Revision 1.18 1999/02/11 17:03:00 paulk
4041 ;; Updated the Swing application template to the JDK 1.2 Swing package
4042 ;; scheme and expanded the template to provide a menu and scrollable
4045 ;; Revision 1.17 1998/09/16 22:55:51 paulk
4046 ;; Added template for Java bean property change support.
4048 ;; Revision 1.16 1998/09/13 00:34:28 paulk
4049 ;; Added a template for generating a System.out.println statement.
4051 ;; Revision 1.15 1998/07/22 00:28:04 paulk
4052 ;; Modified class buffer creation templates to use tempo-marks
4053 ;; to mark initial position for user to insert code. Thanks
4054 ;; to David Hull <david.hull@trw.com> for suggesting this.
4056 ;; Revision 1.14 1998/07/06 06:39:42 paulk
4057 ;; class buffer template now prompts for super class and
4060 ;; Revision 1.13 1998/07/06 05:06:13 paulk
4061 ;; Added boilerlate to other buffer generation templates.
4063 ;; Revision 1.12 1998/07/01 03:54:40 paulk
4064 ;; Added source file boilerplate support.
4066 ;; Revision 1.11 1998/06/27 03:04:46 paulk
4067 ;; Fixed capitalization on get-set method pair. Thanks to Jere_McDevitt@HomeDepot.COM
4069 ;; Revision 1.10 1998/06/17 03:49:21 paulk
4070 ;; Fixed bug that caused jfc-app to be generated instead of console app.
4071 ;; Added a mouse motion listener template.
4072 ;; Added a toString method template.
4074 ;; Revision 1.9 1998/05/27 05:55:20 paulk
4075 ;; Added autoload comments.
4077 ;; Revision 1.8 1998/05/27 05:51:20 paulk
4078 ;; *** empty log message ***
4080 ;; Revision 1.7 1998/05/17 06:20:37 paulk
4081 ;; Added templates for a Swing application and an inner class.
4083 ;; Fixed a bug in jde-gen-buffer
4085 ;; Revision 1.6 1998/04/18 14:08:55 kinnucan
4086 ;; Fixes some bugs in the generated code.
4088 ;; Revision 1.5 1998/04/10 02:55:00 kinnucan
4089 ;; * Updated some of the doc strings.
4091 ;; Revision 1.4 1998/04/09 04:51:09 kinnucan
4092 ;; * Added the capability to define your own custom autocode templates.
4093 ;; The facility consists of the following items:
4095 ;; - jde-gen-code-templates
4097 ;; Defines a list of templates for code inserted at point. The
4098 ;; list by default contains the templates defined by the JDE.
4099 ;; You can define your own templates and add them to the list,
4100 ;; using the Emacs customization feature. See tempo.el for
4101 ;; information on creating templates.
4103 ;; - jde-gen-buffer-templates
4105 ;; Defines a list of templates for code to be inserted in a
4106 ;; newly created Java buffer.
4108 ;; - jde-gen-code (JDE->Generate->Custom)
4111 ;; This command inserts a specified code template at point.
4113 ;; - jde-gen-buffer (Files->JDE New->Custom)
4115 ;; This command creates the specified buffer and inserts
4116 ;; a specified template at the beginning of the buffer.
4118 ;; Revision 1.3 1998/04/08 04:38:16 kinnucan
4119 ;; * Provided each template variable with a set function that regenerates
4120 ;; the corresponding template command whenever the template is changed.
4122 ;; Revision 1.2 1998/04/06 03:47:20 kinnucan
4123 ;; * Added jde-gen-class-buffer and jde-gen-console-buffer functions.
4125 ;; Revision 1.1 1998/04/01 05:33:43 kinnucan
4129 ;; End of jde-gen.el