Hi again!
Some weeks ago I saw some guys on this list who are using the same great
IDE as I do: emacs with JDE and pcl-cvs.

Up to now it was always a big problem for me to keep the bean
implementation and the bean remote interface consistent. So I wrote a
short (but cute?) elisp program for the java mode. 

What it does is:
- starting from the actual "point" in emacs all the bodies from public
methods are erased. SO SAVE YOUR bean before you start that script and
DONT SAVE it to the same file afterwards!
- a "throws RemoteException" clause is added to every method or just the
"RemoteException" if there is already a throws clause without that
exeception included.

After that just copy and paste the method descriptions to your interface
file and you're set.

Use with caution, check the results, don't overwrite your original file,
give me feedback :-) !

For installation just copy the following lines to your .emacs file in
~/. You may want ro adjust the key binding in the last line (which is
C-c C-v ! at the moment).

Cheers,
Tobias
------------------------------------------------
(defun ejb-bean-to-remote-interface ()
  "converting public bean methods to remote interface declarations"
  (interactive)

  (while (re-search-forward "^ *public " nil t)

    (setq throwsclause nil)
    (setq remoteexception nil)
    
    ;; look which keyword are there
    (while (progn
             (re-search-forward "throws\\|RemoteException\\|{\\|;")
             (memq (preceding-char) '(?s ?n)))
      (cond ((equal (preceding-char) ?s) (setq throwsclause t))
            ((equal (preceding-char) ?n) (setq remoteexception t))))

    ;; did find a body ?
    (if (equal (preceding-char) ?\{)
        (setq killbody t)
      (setq killbody nil))

    ;; backtrack over whitespaces and inserting missing text
    (re-search-backward "[a-zA-Z()_$]")
    (forward-char 1)
    (if throwsclause
        (if remoteexception
            ()
          (insert ", RemoteException"))
      (insert " throws RemoteException"))
    
    ;; kill body if there
    (if killbody 
        (progn
          (insert ";")
          (setq start (point))
          (forward-list)
          (kill-region start (point))))))

(global-set-key [?\C-c ?\C-v ?!] 'ejb-bean-to-remote-interface)


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Problems?:           [EMAIL PROTECTED]

Reply via email to