When declaring a class, completion and highlighting within the list of superclasses incorrectly includes members of the class itself. For example: import foo class Derived(foo.Base): foo=42 KDevelop thinks the 'foo' in the list of superclasses (between parentheses) is the 'foo' variable I declared inside the class, rather than the module imported earlier, so naturally it doesn't find the Base object in it.
I'm using the latest version of the 1.4 branch.
Git commit 4c76d85731e01a6691b71b314f20fa1a573dae62 by Sven Brauch. Committed on 09/11/2012 at 19:39. Pushed by brauch into branch '1.4'. Correctly build uses for declarations in some corner cases If the context opened by a node begins after that node does, which is for example the case for class declarations, then stuff that was being parsed between the node start and the start of the context was considered to be in the wrong context. Fixes 309817. M +2 -0 duchain/tests/pyduchaintest.cpp M +17 -2 duchain/usebuilder.cpp M +1 -0 duchain/usebuilder.h http://commits.kde.org/kdev-python/4c76d85731e01a6691b71b314f20fa1a573dae62
Git commit d74d1f413669c45e4610a5da4591002b424f6e7f by Sven Brauch. Committed on 09/11/2012 at 19:39. Pushed by brauch into branch 'master'. Correctly build uses for declarations in some corner cases If the context opened by a node begins after that node does, which is for example the case for class declarations, then stuff that was being parsed between the node start and the start of the context was considered to be in the wrong context. Fixes 309817. M +2 -0 duchain/tests/pyduchaintest.cpp M +17 -2 duchain/usebuilder.cpp M +1 -0 duchain/usebuilder.h http://commits.kde.org/kdev-python/d74d1f413669c45e4610a5da4591002b424f6e7f
Note: This corner-case is still broken (discivered by Nicolas): class Derived(foo.Base): foo=42 class Derived2(foo.Base): pass with *no* empty line between them, the foo.Base in Derived2 still points at the Derived.foo variable To be fixed for 1.5.
(In reply to Sven Brauch from comment #4) > Note: This corner-case is still broken (discivered by Nicolas): > [...] > To be fixed for 1.5. I confirm this is still broken in 5.0.1...
The remaining case seems much simpler - class contexts are simply one line too long. ``` foo = "jkj" class Test: foo=42 bar # int, should be str bar # str ```
Git commit d324e78c60cda606c661f01b4b49defd93829c00 by Francis Herne. Committed on 30/11/2016 at 14:51. Pushed by flherne into branch 'master'. Shorten class context range by one line. Class contexts behave in some ways (tooltips, completion) as if they're one line longer than they ought to be: ``` a = 2 class M: a = "text" b = a # tooltip of `a` says 'str', should be 'int' a # 'int' ``` Expression-visitor doesn't have that problem, i.e. `b` is 'int' in the example above. Shortening the class context range by one line fixes tooltips, uses and completions, and doesn't seem to break the expression visitor. Test case "class_scope_end_outside" is fixed by this patch, the others are unchanged. M +17 -0 codecompletion/tests/pycompletiontest.cpp M +2 -0 codecompletion/tests/pycompletiontest.h M +1 -1 duchain/contextbuilder.cpp M +5 -0 duchain/tests/pyduchaintest.cpp https://commits.kde.org/kdev-python/d324e78c60cda606c661f01b4b49defd93829c00