This is a problem with how the completion engine has been simplified.
It is assumed most code is:
----
includes/imports
declarations
fcns
-----
and when a request for completion/scope is called, it just asks "give me
all the * in this file" The only time order is used is when scope is
parsed upwards out of a function. (ie, each level of code/scope in the
function)
Compilers make decisions based on the current state at the time of the
calculation. The Emacs Lisp parser isn't fast enough to make a decision
like that by reparsing everything that comes before, so I parse
everything up ahead of time, store the results, and then query the
database.
It might make sense to add some sort of scoped search function that says
"give me all the * in this file before POINT". One thing that I've
gathered from many email, however, is that refusal to make a completion
decision based on some filter like that often makes folks confused or
cranky, so why bother? :)
If, in your example below, it is getting the *wrong* answer among
several possible answers, then there is probably some sort of
order-priority that could be used to fix it. If it only that there is
an answer when there shouldn't be, it is probably best to leave it be.
I've often wanted to convert the parsers in Semantic to underline bad
stuff like that in red as you type. In that case, this should
definitely be something worth fixing.
Eric
On Tue, 2009-07-21 at 01:05 +0200, David Engster wrote:
> Hi Eric,
>
> another small question: Consider this code snippet
>
> -----------------------
> #include <iostream>
>
> int main(void)
> {
> cout << "test";
> return 0;
> }
> using namespace std;
> -----------------------
>
> If I put the cursor on "cout" and call semantic-calculate-scope, I get
>
> ] scopetypes #<TAG LIST: 1 entries>
> * std : namespace
>
> but the 'using namespace std;' statement does not apply to the code
> preceding it. Is this a misunderstanding of mine regarding scope, a
> principal limitation in the parses, or maybe a bug?
>
> -David
|