Inconsistent behaviour of AliasDeclarations + DUContext::localDeclarations()?

David Nolden zwabel at googlemail.com
Sun Apr 15 20:18:15 UTC 2012


Am 15. April 2012 21:08 schrieb Sven Brauch <svenbrauch at googlemail.com>:
> Hello David,
>
> thanks for your answer. Yes, I meant that
> findLocalDeclarationsInternal function, as you said; but I didn't find
> a reference to it in functions like allDeclarations(), so I assumed
> something else was used there.
> I'll just add two new search flags then, that's fine.
>
> Regarding the range check, tough: Yes, it checks whether the *aliased*
> declaration is created before the current position, but it doesn't
> verify that for the declaration itself in case of an alias
> declaration. If you have code like this:
>
> # a.py
> class foo: pass
> # b.py
> import a
> bar = foo # creates an alias to "foo" in "a.py"
>
> then it will currently compare the position of *foo* with the current
> cursor, instead of comparing the position of *bar* with the current
> cursor, which would make sense (i.e. it will compare cursors from two
> different top-contexts, which is not useful in any case). This is
> because the declaration is just replaced by its aliasedDeclaration if
> it's an alias before the check is performed. Or do I misunderstand
> something here? If not, is the second search flag (for the range/top
> context check) really necessary, or is this behaviour desired in
> general? In that case, it would probably make sense to check the range
> of the original declaration instead of checking the aliased
> declaration.
> Still, if you feel this might screw something up, I'm also happy to
> add a flag instead.

Ah yes, that check is actually broken. It should check the position of
the declaration before aliasing I guess.




More information about the KDevelop-devel mailing list