Re: xrefdb/semantic overlay bug
vedm <mlist <at> rogers.com>
2006-05-08 19:20:37 GMT
OK, seems that this is fixed: I applied the patch below in David's email
and then substituted semantic-java-type for semantic-token-type only in
one place in the function jde-xref-class-and-token-to-signature:
So this is the original form in jde-xref-class-and-token-to-signature:
(if (eq tclass 'function)
(mapcar (lambda (arg)
(jde-parse-get-unqualified-name
(semantic-token-type arg)))
(semantic-token-function-args token))
(list (jde-parse-get-unqualified-name ttype)))
and this is how I modified it (the only difference being the 4th line):
(if (eq tclass 'function)
(mapcar (lambda (arg)
(jde-parse-get-unqualified-name
(semantic-java-type arg)))
(semantic-token-function-args token))
(list (jde-parse-get-unqualified-name ttype)))
After this I get a correct result and jde-xref-display-call-tree
displays the correct call tree.
Thanks David!
--
vedm
David PONCE <david.ponce <at> wanadoo.fr> writes:
> Hi Eric,
>
> Sorry for this late reply.
>
> [...]
>> I don't know enough of Java to know if:
>>
>> String[] args
>>
>> is different from
>>
>> String args[]
>
> There is no difference. It seems that the first notation is the
> one used in most of the examples in the "Java Language Specifications"
> manual.
>
> Also notice that "String[] args[]" is allowed and equivalent to
> "String[][] args" or "String args[][]"!
>
>> but either way, these [] could be stored as attributes on the tag,
>> and then exposed later by whatever java specific function is needed
>> to do the query described below.
>>
>> In the c/c++ these are stored in a :dereference attribute, and later
>> extracted, and the [] are put in a consistent place.
>
> You're right. So I took a few time to works on that
And, below is
> a patch
It would be nice If some Java developer could try it (I
> don't program much in Java now).
>
> wisent-java-tags is used to parse Java <=1.4 declarations (the
> default), wisent-java is used to fully parse Java 1.5 syntax. To
> enable the latter, add the following after loading cedet:
>
> ;; Use the full Java 1.5 grammar to parse Java files
> (autoload 'wisent-java-default-setup "wisent-java"
> "Hook run to setup Semantic in `java-mode'." nil nil)
>
> I updated the prototyping functions in semantic-java to restore the
> array notation (that suffixes the type) from the :dereference
> attribute.
>
> Please tell me if you want I commit these changes before the release.
>
> Enjoy!
> David
>
> 2006-04-19 David Ponce <david <at> dponce.com>
>
> * cedet/semantic/bovine/semantic-java.el
>
> (semantic-java-dim, semantic-java-expand-tag): New functions.
> (semantic-java-type): New function.
> (semantic-java-prototype-function)
> (semantic-java-prototype-variable): Use it.
>
> * cedet/semantic/wisent/wisent-java.el
> * cedet/semantic/wisent/wisent-java-tags.el
>
> (wisent-java-expand-tag): Remove.
> (wisent-java-default-setup): Use `semantic-java-expand-tag'.
>
> Index: bovine/semantic-java.el
> ===================================================================
> RCS file: /cvsroot/cedet/cedet/semantic/bovine/semantic-java.el,v
> retrieving revision 1.12
> diff -u -r1.12 semantic-java.el
> --- bovine/semantic-java.el 30 Sep 2005 20:22:22 -0000 1.12
> +++ bovine/semantic-java.el 19 Apr 2006 09:49:26 -0000
> <at> <at> -1,6 +1,7 <at> <at>
> ;;; semantic-java.el --- Semantic functions for Java
>
> -;;; Copyright (C) 1999, 2000, 2001, 2002, 2003 David Ponce
> +;;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
> +;;; David Ponce
>
> ;; Author: David Ponce <david <at> dponce.com>
> ;; X-RCS: $Id: semantic-java.el,v 1.12 2005/09/30 20:22:22 zappo Exp $
> <at> <at> -35,7 +36,6 <at> <at>
>
> ;;; Lexical analysis
> ;;
> -
> (defconst semantic-java-number-regexp
> (eval-when-compile
> (concat "\\("
> <at> <at> -83,6 +83,65 <at> <at>
> | [0-9]+<EXPONENT>?[fFdD]
> ;")
>
> +;;; Parsing
> +;;
> +(defsubst semantic-java-dim (id)
> + "Split ID string into a pair (NAME . DIM).
> +NAME is ID without trailing brackets: \"[]\".
> +DIM is the dimension of NAME deduced from the number of trailing
> +brackets, or 0 if there is no trailing brackets."
> + (let ((dim (string-match "\\(\\[]\\)+\\'" id)))
> + (if dim
> + (cons (substring id 0 dim)
> + (/ (length (match-string 0 id)) 2))
> + (cons id 0))))
> +
> +(defsubst semantic-java-type (tag)
> + "Return the type of TAG, taking care of array notation."
> + (let ((type (semantic-tag-type tag))
> + (dim (semantic-tag-get-attribute tag :dereference)))
> + (when dim
> + (while (> dim 0)
> + (setq type (concat type "[]")
> + dim (1- dim))))
> + type))
> +
> +(defun semantic-java-expand-tag (tag)
> + "Expand compound declarations found in TAG into separate tags.
> +TAG contains compound declarations when its class is `variable', and
> +its name is a list of elements (NAME START . END), where NAME is a
> +compound variable name, and START/END are the bounds of the
> +corresponding compound declaration."
> + (let* ((class (semantic-tag-class tag))
> + (elts (semantic-tag-name tag))
> + dim dim0 elt clone start end xpand)
> + (cond
> + ((and (eq class 'function)
> + (> (cdr (setq dim (semantic-java-dim elts))) 0))
> + (setq clone (semantic-tag-clone tag (car dim))
> + xpand (cons clone xpand))
> + (semantic-tag-put-attribute clone :dereference (cdr dim)))
> + ((eq class 'variable)
> + (or (consp elts) (setq elts (list (list elts))))
> + (setq dim (semantic-java-dim (semantic-tag-get-attribute tag :type))
> + type (car dim)
> + dim0 (cdr dim))
> + (while elts
> + ;; For each compound element, clone the initial tag with the
> + ;; name and bounds of the compound variable declaration.
> + (setq elt (car elts)
> + elts (cdr elts)
> + start (if elts (cadr elt) (semantic-tag-start tag))
> + end (if xpand (cddr elt) (semantic-tag-end tag))
> + dim (semantic-java-dim (car elt))
> + clone (semantic-tag-clone tag (car dim))
> + xpand (cons clone xpand))
> + (semantic-tag-put-attribute clone :type type)
> + (semantic-tag-put-attribute clone :dereference (+ dim0 (cdr dim)))
> + (semantic-tag-set-bounds clone start end)))
> + )
> + xpand))
> +
> ;;; Environment
> ;;
>
> <at> <at> -103,7 +162,7 <at> <at>
> Optional argument COLOR indicates that color should be mixed in.
> See also `semantic-format-prototype-tag'."
> (let ((name (semantic-tag-name tag))
> - (type (semantic-tag-type tag))
> + (type (semantic-java-type tag))
> (args (semantic-tag-function-arguments tag))
> (argp "")
> arg argt)
> <at> <at> -113,8 +172,8 <at> <at>
> (if (semantic-tag-p arg)
> (setq argt (if color
> (semantic--format-colorize-text
> - (semantic-tag-type arg) 'type)
> - (semantic-tag-type arg))
> + (semantic-java-type arg) 'type)
> + (semantic-java-type arg))
> argp (concat argp argt (if args "," "")))))
> (if color
> (progn
> <at> <at> -130,8 +189,8 <at> <at>
> See also `semantic-format-prototype-tag'."
> (concat (if color
> (semantic--format-colorize-text
> - (semantic-tag-type tag) 'type)
> - (semantic-tag-type tag))
> + (semantic-java-type tag) 'type)
> + (semantic-java-type tag))
> " "
> (if color
> (semantic--format-colorize-text
> Index: wisent/wisent-java-tags.el
> ===================================================================
> RCS file: /cvsroot/cedet/cedet/semantic/wisent/wisent-java-tags.el,v
> retrieving revision 1.31
> diff -u -r1.31 wisent-java-tags.el
> --- wisent/wisent-java-tags.el 30 Sep 2005 20:25:20 -0000 1.31
> +++ wisent/wisent-java-tags.el 19 Apr 2006 09:49:31 -0000
> <at> <at> -1,6 +1,6 <at> <at>
> ;;; wisent-java-tags.el --- Java LALR parser for Emacs
>
> -;; Copyright (C) 2001, 2002 David Ponce
> +;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 David Ponce
>
> ;; Author: David Ponce <david <at> dponce.com>
> ;; Maintainer: David Ponce <david <at> dponce.com>
> <at> <at> -96,7 +96,7 <at> <at>
> semantic-lex-number-expression semantic-java-number-regexp
> semantic-lex-analyzer 'wisent-java-tags-lexer
> ;; Parsing
> - semantic-tag-expand-function 'wisent-java-expand-tag
> + semantic-tag-expand-function 'semantic-java-expand-tag
> ;; Environment
> semantic-imenu-summary-function 'semantic-format-tag-prototype
> imenu-create-index-function 'semantic-create-imenu-index
> <at> <at> -122,32 +122,8 <at> <at>
> ;; Setup javadoc stuff
> (semantic-java-doc-setup))
>
> -(defun wisent-java-expand-tag (tag)
> - "Expand TAG into a list of equivalent tags, or nil.
> -Expand multiple variable declarations in the same statement, that is
> -tags of class `variable' whose name is equal to a list of elements of
> -the form (NAME START . END). NAME is a variable name. START and END
> -are the bounds in the declaration, related to this variable NAME."
> - (let (elts elt clone start end xpand)
> - (when (and (eq 'variable (semantic-tag-class tag))
> - (consp (setq elts (semantic-tag-name tag))))
> - ;; There are multiple names in the same variable declaration.
> - (while elts
> - ;; For each name element, clone the initial tag and give it
> - ;; the name of the element.
> - (setq elt (car elts)
> - elts (cdr elts)
> - clone (semantic-tag-clone tag (car elt))
> - start (if elts (cadr elt) (semantic-tag-start tag))
> - end (if xpand (cddr elt) (semantic-tag-end tag))
> - xpand (cons clone xpand))
> - ;; Set the bounds of the cloned tag with those of the name
> - ;; element.
> - (semantic-tag-set-bounds clone start end))
> - xpand)))
> -
> ;;;###autoload
> -(add-hook 'java-mode-hook #'wisent-java-default-setup)
> +(add-hook 'java-mode-hook 'wisent-java-default-setup)
>
> (provide 'wisent-java-tags)
>
> Index: wisent/wisent-java.el
> ===================================================================
> RCS file: /cvsroot/cedet/cedet/semantic/wisent/wisent-java.el,v
> retrieving revision 1.48
> diff -u -r1.48 wisent-java.el
> --- wisent/wisent-java.el 30 Sep 2005 20:25:17 -0000 1.48
> +++ wisent/wisent-java.el 19 Apr 2006 09:49:31 -0000
> <at> <at> -1,6 +1,6 <at> <at>
> ;;; wisent-java.el --- Java LALR parser for Emacs
>
> -;; Copyright (C) 2001, 2002 David Ponce
> +;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 David Ponce
>
> ;; Author: David Ponce <david <at> dponce.com>
> ;; Maintainer: David Ponce <david <at> dponce.com>
> <at> <at> -45,27 +45,6 <at> <at>
>
> ;;; Enable Semantic in `java-mode'.
> ;;
> -(defun wisent-java-expand-tag (tag)
> - "Expand compound declarations found in TAG into separate tags.
> -TAG contains compound declarations when its class is `variable', and
> -its name is a list of elements (NAME START . END), where NAME is a
> -compound variable name, and START/END are the bounds of the
> -corresponding compound declaration."
> - (let (elts elt clone start end xpand)
> - (when (and (semantic-tag-of-class-p tag 'variable)
> - (consp (setq elts (semantic-tag-name tag))))
> - (while elts
> - ;; For each compound element, clone the initial tag with the
> - ;; name and bounds of the compound variable declaration.
> - (setq elt (car elts)
> - elts (cdr elts)
> - start (if elts (cadr elt) (semantic-tag-start tag))
> - end (if xpand (cddr elt) (semantic-tag-end tag))
> - clone (semantic-tag-clone tag (car elt))
> - xpand (cons clone xpand))
> - (semantic-tag-set-bounds clone start end))
> - xpand)))
> -
> (defun wisent-java-init-parser-context ()
> "Initialize context of the LR parser engine.
> Used as a local `wisent-pre-parse-hook' to cleanup the stack of enum
> <at> <at> -85,7 +64,7 <at> <at>
> semantic-lex-depth nil
> semantic-lex-analyzer 'wisent-java-lexer
> ;; Parsing
> - semantic-tag-expand-function 'wisent-java-expand-tag
> + semantic-tag-expand-function 'semantic-java-expand-tag
> ;; Environment
> semantic-imenu-summary-function 'semantic-format-tag-prototype
> semantic-imenu-expandable-tag-classes '(type variable)
>
>
>
>
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642