Re: how to help? (patch to jde-parse.el, for jde-which-method)
"Jeff Peck" <[email protected]>
| Newsgroups | gmane.emacs.jdee.devel |
|---|---|
| Message-ID | <8BFB537480D54533893863DCDB24B81F@blue> |
Eric, again thanks for responding.
My question about where to put is really targetted to the JDEE folks...
Where in the JDEE (load ...) should it be so everyone gets it by default.
And again, armed with your reassurance that it should work,
I looked a little deeper in JDEE to find why jde-which-method is failing
(failing to recognise any class name that has a Generic declaration)
Turns out Semantic and wisent-java or ok!
but jde-parse.el does its own regex to find the class name (looking before the c-parse-state)
And the regex does not expect <>! (Len, that is why we saw 'nil' in the jde-which-method output)
Patch:
Index: lisp/jde-parse.el
===================================================================
--- lisp/jde-parse.el (revision 173)
+++ lisp/jde-parse.el (working copy)
@@ -507,7 +507,7 @@
;; classname:
"\\([a-zA-Z0-9_]+\\)"
;; everything between classname and curly brace:
- "\\(?:" jde-parse-java-comment-or-ws-re "\\|[a-zA-Z0-9_.,()]\\)*"
+ "\\(?:" jde-parse-java-comment-or-ws-re "\\|[a-zA-Z0-9_.,()<>]\\)*"
"\\=")
"Regular expression matching class declarations before point.
Point must be at opening curly brace of class.
Since I have some deeply nested class/interface files, I also [re]submit this patch to jde-which-method.el
That will display the full class name: OuterA.OuterB.Inner.method
Index: lisp/jde-which-method.el
===================================================================
--- lisp/jde-which-method.el (revision 173)
+++ lisp/jde-which-method.el (working copy)
@@ -70,6 +70,14 @@
"Format for the JDE source buffer mode line."
:group 'jde
:type 'sexp)
+
+(defcustom jde-which-full-class-name nil
+ "Display full inner-class name in JDE's which method mode.
+If nil then display only the last component of class name.
+\(see `jde-which-method-max-length', `jde-which-method-class-min-length')
+"
+ :group 'jde-which-method
+ :type 'boolean)
(defcustom jde-which-method-max-length 20
"Specify the maximum length of the which-method-string \(see
@@ -147,7 +155,7 @@
))
(if name
(let* ((name-pair (car name))
- (class (car name-pair))
+ (class (jde-which-method-class-name name))
(method (cdr name-pair))
(bounds (cdr name))
(class-length (length class))
@@ -190,7 +198,7 @@
(setq jde-which-method-current-point-loc p)
(setq jde-which-method-current-method-bounds bounds))
(progn
- (setq name (jde-parse-get-innermost-class-at-point))
+ (setq name (jde-which-class-name (jde-parse-get-innermost-class-at-point)))
(setq jde-which-method-current-point-loc p)
(setq jde-which-method-current-method-bounds (cons -1 -1))
(if name
@@ -213,6 +221,27 @@
(setq jde-which-method-idle-timer nil)
(message "Error in jde-which-method-update: %s" info)))))
+(defun jde-which-full-class-namef (name)
+ ;; name and return value is: (string . point) or nil.
+ (save-excursion
+ (do ((rv name)) ((not name) rv)
+ (goto-char (cdr name))
+ (setq name (jde-parse-get-innermost-class-at-point))
+ (if name (setf (car rv) (concat (car name) "." (car rv)))))))
+
+(defun jde-which-class-name(name)
+ ;; use given name or gather full-name:
+ (if jde-which-full-class-name
+ (jde-which-full-class-namef name)
+ name
+ ))
+
+(defun jde-which-method-class-name(name)
+ (if jde-which-full-class-name
+ (car (jde-which-full-class-namef (jde-parse-get-innermost-class-at-point)))
+ (caar name)
+ ))
+
(defun jde-which-method-update-on-entering-buffer ()
;; This is a hook function. Catch all errors to
;; avoid canceling other hooks.
------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev
_______________________________________________
jdee-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jdee-devel
parse-and-which.patch
(application/octet-stream, 2.8 KB)
Index: lisp/jde-parse.el =================================================================== --- lisp/jde-parse.el (revision 173) +++ lisp/jde-parse.el (working copy) @@ -507,7 +507,7 @@ ;; classname: "\\([a-zA-Z0-9_]+\\)" ;; everything between classname and curly brace: - "\\(?:" jde-parse-java-comment-or-ws-re "\\|[a-zA-Z0-9_.,()]\\)*" + "\\(?:" jde-parse-java-comment-or-ws-re "\\|[a-zA-Z0-9_.,()<>]\\)*" "\\=") "Regular expression matching class declarations before point. Point must be at opening curly brace of class. Index: lisp/jde-which-method.el =================================================================== --- lisp/jde-which-method.el (revision 173) +++ lisp/jde-which-method.el (working copy) @@ -70,6 +70,14 @@ "Format for the JDE source buffer mode line." :group 'jde :type 'sexp) + +(defcustom jde-which-full-class-name nil + "Display full inner-class name in JDE's which method mode. +If nil then display only the last component of class name. +\(see `jde-which-method-max-length', `jde-which-method-class-min-length') +" + :group 'jde-which-method + :type 'boolean) (defcustom jde-which-method-max-length 20 "Specify the maximum length of the which-method-string \(see @@ -147,7 +155,7 @@ )) (if name (let* ((name-pair (car name)) - (class (car name-pair)) + (class (jde-which-method-class-name name)) (method (cdr name-pair)) (bounds (cdr name)) (class-length (length class)) @@ -190,7 +198,7 @@ (setq jde-which-method-current-point-loc p) (setq jde-which-method-current-method-bounds bounds)) (progn - (setq name (jde-parse-get-innermost-class-at-point)) + (setq name (jde-which-class-name (jde-parse-get-innermost-class-at-point))) (setq jde-which-method-current-point-loc p) (setq jde-which-method-current-method-bounds (cons -1 -1)) (if name @@ -213,6 +221,27 @@ (setq jde-which-method-idle-timer nil) (message "Error in jde-which-method-update: %s" info))))) +(defun jde-which-full-class-namef (name) + ;; name and return value is: (string . point) or nil. + (save-excursion + (do ((rv name)) ((not name) rv) + (goto-char (cdr name)) + (setq name (jde-parse-get-innermost-class-at-point)) + (if name (setf (car rv) (concat (car name) "." (car rv))))))) + +(defun jde-which-class-name(name) + ;; use given name or gather full-name: + (if jde-which-full-class-name + (jde-which-full-class-namef name) + name + )) + +(defun jde-which-method-class-name(name) + (if jde-which-full-class-name + (car (jde-which-full-class-namef (jde-parse-get-innermost-class-at-point))) + (caar name) + )) + (defun jde-which-method-update-on-entering-buffer () ;; This is a hook function. Catch all errors to ;; avoid canceling other hooks.