Rewrite declarationForName()

Authored by flherne on Jul 27 2017, 12:54 PM.



Rewrite declarationForName()

This causes the correct declaration to be found in some unusual cases that previously failed.

Only names declared before a function definition, or at module scope, were found in its body. Names may be declared later (but before the function is called); these were not found.

BUG: 378083

  • Class attributes from any enclosing class definition were found in default arguments, not only those from a method's parent class.
  • Class or instance attributes were, correctly, not directly visible inside a method body (only with self. or similar), but hid declarations of the same name in outer contexts that should be found.
Test Plan

All existing tests pass.

Add some new tests, of which four previously failed (declaration_order_func_defarg2, intermediate_vs_class/instance_attrs, top_level_vs_nested_*).

Quite a lot of manual testing.

Diff Detail

R53 KDevelop: Python Support
Lint Skipped
Unit Tests Skipped
flherne created this revision.Jul 27 2017, 12:54 PM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptJul 27 2017, 12:54 PM
flherne edited the summary of this revision. (Show Details)Jul 27 2017, 12:55 PM
flherne edited the summary of this revision. (Show Details)Jul 27 2017, 1:15 PM
flherne updated this revision to Diff 17288.Jul 27 2017, 1:25 PM

Had old version without the tests.

flherne updated this revision to Diff 17289.Jul 27 2017, 1:26 PM

Bleh. /still/ had old version without the tests.

brauch accepted this revision.Jul 27 2017, 5:38 PM

Looks sensible to me -- can you maybe add a unit test which tests the now-fixed behaviour? Should be simple enough. Then just submit it and let's see if there are any issues :)

Thank you very much for looking into this!

This revision is now accepted and ready to land.Jul 27 2017, 5:38 PM

Never mind me -- didn't reload the page after you added the tests ;) Just ship it.