How to register uses for declarations which are outside of the current file?

Sven Brauch svenbrauch at googlemail.com
Sun Mar 13 13:57:46 UTC 2011


Hi!

I'm currently trying to enable support for the python "import foo"
statement (which will search for a file named "foo.py" and pack its
whole contents into a module named "foo" -- in contrast to "#include
"foo.xyz" in c++ or "include(foo.php)" in php, which will both simply
import all declarations of that file into the current context). I need
something like foo.bar() to be recognized as a use of the bar()
function defined in the top context (!) of foo.py. Thus, i cannot use
addImportedParentContexts or such (like php does, which is my usual
well of information in difficult cases), because that's what "from foo
import *" would do.

Anyway, the situation is like this: I can find the Declaration
instance for bar(). I also know which context it is in. I'd now like
to register a new use for it, but when simply callind newUse(node,
range, DeclarationForBar) it's highlighted as an error (in that
dark-red "declaration-not-found" color). Reading the source code of
newUse, i noticed it uses currentContext()->topContext() (instead of
declaration->topContext(), which is what I'd have expected) and then
searches the Declarations range() in that context. This seems odd for
me.
Did I just not understand this right, or is there another way to do
what I want to do...?

Thanks in advance,
Bye,
Sven




More information about the KDevelop-devel mailing list