Re: Typecache does not contain include tags created at expansion

Eric Ludlam <[email protected]> Sat, 03 Jan 2015 15:20:01 -0500
Newsgroups gmane.emacs.cedet
Message-ID <[email protected]>
On 01/03/2015 08:24 AM, Steven Rémot wrote:
> Hello,
>
> I was trying to properly support PHP "use" statement in CEDET and I got
> some difficulties that looks like a bug in semanticdb caching.
>
> Just to recall, PHP use statement is something like a name aliasing.
> When you write, for example
>
>     use MyNamespace\MyClass as TheClass;
>
>
> Then you can refer to "MyNamespace\MyClass" by the name "TheClass".
>
> However, in PHP, types are loaded automatically when they are used, you
> do not need to use some "include" or "require" statement.
>
> To include "MyNamespace\MyClass" in the buffer, I though I could create
> an include tag when expanding the aliases created by the use statement
> (I need to expand them anyway), so I did it.
>
> So now, when I am working in this PHP file :
>
>     <?php
>     namespace AnotherNs;
>
>     use NewNs\SuperGreeter as Greeter;
>
>     class SuperGreeterCaller
>     {
>          public function callSuperGreeter(Greeter $greeter)
>          {
>              $greeter->
>          }
>     }
>
>
> I get the following structure (result simplified from bovinate) :
>
>     (("AnotherNs" type
>        (:members
>         (("SuperGreeterCaller" type
>           (:members
>            ( ... )
>            :type "class"))
>
>          ("/<project dir>/src/NewNs/SuperGreeter.php" include nil)
>
>          ("Greeter" type
>           (:superclasses "\\NewNs\\SuperGreeter" :type "use")))
>
>         :type "namespace")))
>
> So the include tag has succesfully been integrated into the tag table.
>
> However, when I run "M-x semanticdb-typecache-dump" in a recently
> started emacs, I get :
>
>     ]#<semanticdb-typecache /<project
>     dit>/src/AnotherNs/SuperGreeterCaller.php>
>         ] Name: "/<project dir>/src/AnotherNs/SuperGreeterCaller.php"
>         ] Class: #'semanticdb-typecache
>         ] filestream #<TAG LIST: 1 entries>
>         ] includestream : nil
>         ] stream : nil
>         ] dependants #<list o' stuff: 1 entries>
>
> There is nothing in includestream. When I run emacs for a while, it
> happens includestream contains the expected included tags !
>
> Am I doing something wrong, or could it be an unwanted behaviour ?

Howdy,

Using the 'dump' feature should force the include stream to be filled, 
so there is some other reason why it is empty.  Since 'dependents' has 
an entry, I'll assume that is your include tag.   It is possible that 
since you are developing your grammar as you go, some buffers are in 
different parsing states.  I recently patched CEDET in bzr (and now git) 
back in.. November? to better update buffers when you compile your grammar.

A way to check is to get the above output, immediately visit the 
included file, and use 'bovinate' in there to see what the content is. 
If it has no types, it won't be in the typecache.  If it does, and you 
go back and re-request the typecache and the content is there, then 
there is some update issue.  Those are puzzling to debug.

In your output, I notice that you tags are saved in :members in an order 
different than the text of the parsed buffer.  Is that a cut and paste 
error in your email, or is that real?  I also noticed the output 
excludes an positional information, either in [ start end ] or overlay 
form.  Is that on purpose?


Lastly, if "use" acts both as include and using statement, you could try 
can use wisent-php-expand-tag to convert the include to also be a 
'using' statement at the same location.  That way the scope calculation 
engine could identify and convert "Greeter" into the other type when 
found.   I'm guessing a bit about that, so you could just wait until you 
need it to give it a try.

I hope this helps.
Eric










------------------------------------------------------------------------------
Dive into the World of Parallel Programming! The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net