[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Stange code in semantic/db-el.el
From: |
Eric Ludlam |
Subject: |
Re: Stange code in semantic/db-el.el |
Date: |
Thu, 12 Feb 2015 21:04:39 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
On 02/12/2015 09:49 AM, Stefan Monnier wrote:
In semanticdb-elisp-sym->tag (cedet/semantic/db-el.el) I see the code below:
[ This is the code in the emacs-24 branch. ]
((and (eq toktype 'type) (class-p sym))
(semantic-tag-new-type
(symbol-name sym)
"class"
(semantic-elisp-desymbolify
(eieio--class-public-a (class-v semanticdb-project-database))) ;;
slots
(semantic-elisp-desymbolify (eieio-class-parents sym)) ;; parents
))
I'm not exactly sure what this code is supposed to do, but I have the
impression that `semanticdb-project-database' above makes no sense:
I would expect to see `sym' there instead.
Is my intuition correct, or else what is this
`semanticdb-project-database' doing there?
Wow, it is surprising this never came up as a bug.
The entire file (db-el.el) is a custom semantic database back end for
Emacs Lisp. Typically tags parsed by the parser are stashed in a
database saved to disk. You can create databases that specialize in
extracting symbol information from other sources. ie - you can pull
java symbols from a jar file using a javap command. In this case, the
Emacs Lisp database extracts symbols directly from Emacs for performing
searches.
This specific chunk of code is getting the slots from an eieio class so
it can fabricate a tag to return. The emacs lisp semantic database
search methods uses this technique as a way to return the search results.
I agree with your assessment and I was able to validate incorrect
behavior, and that putting in sym as you suggest is correct.
If you use semantic and have EDE loaded, you can do this in an Emacs
Lisp buffer:
M-: (semanticdb-find-tags-by-name "ede-project-autoload") RET
and see the semanticdb project database's members in the results, and
when you put in 'sym' instead, the correct list of 12 entries should be
in the results. This is easier to check if you use the
`data-debug-eval-expression'. ielm doesn't work since the right
overloads aren't active.
If you have multiple hits, then you need to pick the one that lines up
with the emacs lisp semantic database, not the hit from the file.
Eric