On Sun, 2009-07-12 at 13:33 +0200, David Engster wrote:
> David Engster <deng@...> writes:
> > Semantic is not able to provide completions for 'b'. Currently, I have
> > this problem with the vmime library, which is using nested namespaces
> > with additional 'using' statements like above for some types.
>
> There seems to be a more general problem with 'using' statements not
> done in the global scope. For example:
>
> namespace test {
> struct foo {
> int bar;
> };
> }
>
> int main(void) {
> using namespace test;
> foo var;
> var. // Completion fails
> }
>
> If the 'using namespace test' is put in the global scope (i.e. before
> the 'main' function), completions works.
>
> Is this a problem with the grammar, or is there maybe something missing
> in the code?
Hi,
I think the parser is working fine. The piece of code that calculates
completions, however, runs backward from what a typical parser/compiler
does. In a compiler, it starts at the beginning, maintains a current
"state", then it knows what's going on.
For the Semamtic, it just builds up a big set of tables, mostly during
idle time, and maintains them as current as possible. When an analysis
is requested, it parses the context around the cursor, then starts
working backwards though the tables of data.
The pieces that deals with 'using' statements is an overload function
of semantic-ctxt-scoped-types written for C++ in semantic-c.el. I'll
take a guess that this function is missing for you case. I usually
debug stuff like this by just calling the function directly, ie:
M-: (semantic-ctxt-scoped-types) RET
to see what it says.
In your original example, which has "inner" squeezed out when you refer
to it as outer::foo, instead of outer::inner::foo, this is because I did
not know this was valid syntax, so it needs to be added. Somewhere. I
don't know if it is in semantic-ctxt-scoped-types, or not. Does the
scoped types fcn need to derive all possible squeezed out names?
Eric
|