Paul,

Actually I have a question about region based cflow templates. How do I
use them?

I ask because, with region, as soon as I type first letter of 'if' or
'try' the mark (region) is deactivated.

Or the only way to use the functionality is by marking a region and then
doing one of:

1. M-x jde-gen-try-catch-wrapper RET
2. Bing the function to some key or menu and use that keystroke/menu
selection

Am I missing something here?

cheers,
sandip

> -----Original Message-----
> From: Paul Kinnucan [mailto:[EMAIL PROTECTED] 
> Sent: Monday, August 04, 2003 9:45 AM
> To: Nascif Abousalh-Neto
> Cc: Robert Mecklenburg; JDE Users
> Subject: RE: Useful helper functions
> 
> 
> Nascif Abousalh-Neto writes:
>  > Cool stuff, thanks for sharing.
>  > 
>  > Would there be a way to implement the try/catch wrapper 
> with a more precise  > catch statement? I guess it would 
> require some introspection on the method  > calls inside the 
> region. Is that information easily available somewhere in  > 
> JDEE, say in the new xref database?  > 
> 
> The JDEE already includes a function for wrapping a region
> in a try-catch form. See the doc string for 
> jde-gen-try-catch-wrapper. It does not try to guess the 
> exception that you want to catch.
> 
> - Paul
> 
> 
>  > Regards,
>  >    Nascif
>  > 
>  > > -----Original Message-----
>  > > From: Robert Mecklenburg [mailto:[EMAIL PROTECTED] 
>  > > Sent: Monday, July 28, 2003 12:31 AM
>  > > To: JDE Users
>  > > Subject: Useful helper functions
>  > > 
>  > > 
>  > > Here is some code I've written that seems useful here.  
>  > > Include it in JDEE if you feel any are worthy.  There's quite 
>  > > a span of time represented by these so some use more or less 
>  > > advanced features as my understanding evolved.  If you'd like 
>  > > me to rework them for jdee, give me specific poniters and 
>  > > I'll resubmit with changes.
>  > > 
>  > > ================================================================
>  > > 
>  > > (defun insert-fully-qualified-name (name)
>  > >   "Transform the class name at point into a fully qualified 
>  > > name. This is useful when writing @{link name} and name is 
>  > > not in the import list."
>  > >   (interactive (list (read-string "Class name: " 
>  > > (thing-at-point 'word))))
>  > >   (save-excursion
>  > >     (save-window-excursion
>  > >       (let* ((full-name 
> (jde-parse-select-qualified-class-name name)))
>  > >  (if (not (looking-at "\\<"))
>  > >    (forward-word -1))
>  > >  (kill-word 1)
>  > >  (insert-before-markers full-name)))))
>  > > 
>  > > 
>  > > (defun make-word-a-link ()
>  > > "Transform the class name at point into a javadoc @link.  If 
>  > > the class name does not occur in the current package insert 
>  > > the fully qualified name, too."
>  > >   (interactive)
>  > >   (if (not (looking-at "\\<"))
>  > >       (forward-word -1))
>  > >   (insert "[EMAIL PROTECTED] ")
>  > >   (let ((word (buffer-substring (point) (save-excursion 
>  > > (forward-word 1) (point)))))
>  > >     (if (not (file-exists-p (concat word ".java")))
>  > >  (progn 
>  > >    (insert-fully-qualified-name word)
>  > >    (insert " " word)))
>  > >     (insert "}")))
>  > > 
>  > > ================================================================
>  > > 
>  > > (defun wrap-region-in-try-catch (start end)
>  > >   (interactive "r")
>  > >   (save-excursion
>  > >     (goto-char start)
>  > >     (beginning-of-line)
>  > >     (let (region-ends-with-newline (e (make-marker)))
>  > >       (set-marker e end)
>  > >       (insert "try\n{\n")
>  > >       (goto-char e)
>  > >       (setq region-ends-with-newline (eolp))
>  > >       (if region-ends-with-newline
>  > >    (insert "\n"))
>  > >       (insert "}\ncatch ( Exception error )\n{\n}")
>  > >       (if (not region-ends-with-newline)
>  > >    (insert "\n"))
>  > >       (set-marker e (point))
>  > >       (goto-char start)
>  > >       (forward-line -2)
>  > >       (c-indent-region (point) e))))
>  > > 
>  > > ================================================================
>  > > 
>  > > (defun jde-run-with-arguments (arg)
>  > > "Run the class in the current buffer.  If a prefix argument 
>  > > is given, prompt for different command line arguments and 
>  > > remember them for subsequent runs."
>  > >   (interactive "P")
>  > >   (if arg
>  > >       (jde-run-set-app-args (read-string "Enter arguments: ")))
>  > >   (jde-run nil))
>  > > 
>  > > ================================================================
>  > > 
>  > > (defun jde-replace-in-defun (old-word new-word)
>  > > "Replace the word under the cursor within the current method."
>  > >   (interactive
>  > >    (list (read-string "Query replace: " (car 
>  > > (semantic-ctxt-current-symbol)))
>  > >   (read-string "Replace with: ")))
>  > >   (senator-mark-defun)
>  > >   (perform-replace old-word new-word t nil t nil nil 
> (point) (mark)))
>  > > 
>  > > ================================================================
>  > > 
>  > > ;;; This uses the hash method from Josh Bloch's Effective 
>  > > Java Programming. (jde-gen-define-abbrev-template 
> "hash-code-method"
>  > >                          '("private int hashCode()" '> 'n 
>  > >                            "{" '>'n
>  > >                            "int result = 17;" '>'n
>  > >                            "result = result * 37 + /* 
>  > > data member */;" '>'n
>  > >                            "/* Add more result lines 
>  > > here */" '>'n
>  > >                            "return result;" '>'n
>  > >                            "}" '>))
>  > > 
>  > > (jde-gen-define-abbrev-template "equals-method"
>  > >                          '("private boolean equals( 
>  > > Object o )" '> 'n 
>  > >                            "{" '>'n
>  > >                            "if ( this == o )" '>'n
>  > >                            "{" '>'n
>  > >                            "return true;" '>'n
>  > >                            "}" '>'n '>'n
>  > >                            "if ( ! ( o instanceof "
>  > >                            (file-name-sans-extension
>  > >                             (file-name-nondirectory 
>  > > buffer-file-name))
>  > >                            " ) )" '>'n
>  > >                            "{" '>'n
>  > >                            "return false;" '>'n
>  > >                            "}" '>'n '>'n
>  > >                            (file-name-sans-extension
>  > >                             (file-name-nondirectory 
>  > > buffer-file-name))
>  > >                            " "
>  > >                            (downcase
>  > >                             (substring (file-name-sans-extension
>  > >                                         
>  > > (file-name-nondirectory buffer-file-name)) 0 1))
>  > >                            " = ("
>  > >                            (file-name-sans-extension
>  > >                             (file-name-nondirectory 
>  > > buffer-file-name))
>  > >                            ") o;" '>'n '>'n
>  > >                            "/* Test class members here. 
>  > > */" '>'n '>'n
>  > >                            "return true;" '>'n
>  > >                            "}" '>))
>  > > 
>  > > 
>  > > Cheers,
>  > > -- 
>  > > Robert
>  > > 
>  > > 
> 
> 

Reply via email to