When it comes to pulling symbols in from include files, there are a few
ways to do it. The best is a combination of an ede project to pull in
local files that are in different directories in the same project, and a
system include path.
The ede-simple project type is a dead end that I never finished and
should be superseded by the generic project type which is only in
CEDET/CVS at the moment. There is no php support there, but it would be
pretty easy to add.
Anyway, converting an include tag into a file name is a multi-step
process. The first step is via `semantic-tag-include-filename'. In
Emacs Lisp, this is overloaded like this:
(define-mode-local-override semantic-tag-include-filename emacs-lisp-mode
"Return the name of the tag with .el appended.
If there is a detail, prepend that directory."
(let ((name (semantic-tag-name tag))
(detail (semantic-tag-get-attribute tag :directory)))
(concat (expand-file-name name detail) ".el")))
so you can see it will take something like:
and append ".el" to the end of the name to get "foo.el".
The next step that semanticdb takes is to start referencing the
semanticdb-find-default-throttle which will need the symbol 'project to
be in the list of places to look.
Next, it will use the dependency system in semantic-tag-file.el and call
semantic-dependency-tag-file. For project files this just uses
ede-expand-filename. It also looks in the include path derived from
semantic-dep.el which you can set on a per-mode basis with
You can also overload semantic-dependency-tag-file for PHP to do
something custom, as seen in Emacs Lisp mode. If possible, try not to
do this. Emacs does this because it can use built-in features to
discover the location of files very fast.
The ede function ede-expand-filename-impl can be overriden by different
project types, though the default just scans the project directories,
and should be sufficient.
Anyway, I don't know what PHP uses for a build infrastructure... if
anything, so I don't know if the generic project will support your
feature or not.
A quick way to debug the finding of includes is to enable
semantic-decoration-mode. Decorating includes is enabled by default,
and you can use the context menu to ask it questions about the include.
Unfortunately when it goes into EDE, not much is revealed.
On 07/25/2010 12:15 AM, michael wrote:
> I recently began study cedet tools to use in php programming. I wrote
> own wisent grammar implementation, which provide fair parsing for
> structures and major types definitions. I tried to get semantic follow
> include-tags, foremost I assume the parsing thing does its part well, I
> get following results running `semanticdb-ref-test' from the file with
> two include statements:
> ] Name: "DEBUG"
> ] Class: #'semanticdb-ref-adebug
> ] :i-depend-on : nil
> ] :local-table #<semanticdb-table test.php (8 tags)>
> ] :i-include #<TAG LIST: 2 entries>
> * "test1.php"
> * "test2.php"
> I reached testing with `semanticdb-find-test-translate-path'. According
> to documentation it will provide the list of tables which semantic will
> search through, and I expect it will pick-up include statements, however
> it's not happening and I get the following result:
> *#<semanticdb-table test.php (8 tags)>
> ] Name: "test.php"
> ] Class: #'semanticdb-table
> ] parent-db #<semanticdb-project-database-file test/ (4 tables)>
> ] :major-mode #'php-mode
> ] :tags #<TAG LIST: 8 entries>
> ] index #<semanticdb-find-search-index #<semanticdb-table test.php>
> ] cache #<list o' stuff: 1 entries>
> ] :file "test.php"
> ] buffer #<buffer test.php>
> ] dirty : nil
> ] db-refs : nil
> ] :pointmax 362
> ] :fsize 361
> ] :lastmodtime #<list o' stuff: 2 entries>
> ] :unmatched-syntax : nil
> ] :lexical-table : nil
> I also tried to have Simple EDE project created in the same directory
> with no luck, although my wishful destination is to have a tag scope
> from associated files as easy as they are being retrieved from active
> buffer and without project declaration. Isn't it disagree with semantic
> I would like to ask respected community if I missed something from
> understanding how semantic associate files and what is required besides
> include-tags and literal to filename translation?
> (`semantic-tag-include-filename' current realization of which performs
> filename excision from quotes)
> This SF.net email is sponsored by Sprint
> What will you do first with EVO, the first 4G phone?
> Visit sprint.com/first -- http://p.sf.net/sfu/sprint-com-first
> cedet-semantic mailing list