Better unpacking and iteration
ClosedPublic

Authored by flherne on Nov 12 2016, 9:57 PM.

Details

Summary

Improve the assignment-unpacking code to handle unsure-types and dicts properly, then reimplement visitFor() and visitComprehension() to use assignment code.

Test Plan

Added a couple of tests, fixes one previously-XFAIL test.

Doesn't seem to crash.

Diff Detail

Repository
R53 KDevelop: Python Support
Lint
Lint Skipped
Unit
Unit Tests Skipped
flherne updated this revision to Diff 8117.Nov 12 2016, 9:57 PM
flherne retitled this revision from to Better unpacking and iteration.
flherne updated this object.
flherne edited the test plan for this revision. (Show Details)
flherne added a reviewer: brauch.
flherne set the repository for this revision to R53 KDevelop: Python Support.
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptNov 12 2016, 9:57 PM
brauch edited edge metadata.Nov 13 2016, 12:18 PM

Thank you very much for looking into this and cleaning it up, simply the amount of removed code makes this a very welcome patch already :)
I added a few small comments, otherwise this looks good to me. Much appreciated!

duchain/declarationbuilder.cpp
1279

I think you shouldn't use this function if you only want to loop over the types. Feel free to add a foreach_unsure_type function or so, or just write out the loop.
auto containers is unused (and useless anyways)

1283

probably more readable with an or

1284

make this a qCDebug() with a better message

duchain/helpers.cpp
497

True, good find ;)

flherne updated this revision to Diff 8119.Nov 13 2016, 1:56 PM
flherne edited edge metadata.
flherne removed R53 KDevelop: Python Support as the repository for this revision.
flherne marked an inline comment as done.

Used loop instead of filterType().
Used or...and instead of ?:
Removed leftover debug text.

brauch accepted this revision.Nov 13 2016, 2:25 PM
brauch edited edge metadata.

Looks good except for the comment below. To master branch please (not 5.0). Thanks again!

duchain/declarationbuilder.cpp
98 ↗(On Diff #8119)

wait, now you iterate twice over the same thing, once with the size and once with the foreach, no?

This revision is now accepted and ready to land.Nov 13 2016, 2:25 PM
flherne updated this revision to Diff 8120.Nov 13 2016, 2:43 PM
flherne edited edge metadata.
flherne set the repository for this revision to R53 KDevelop: Python Support.
flherne marked 2 inline comments as done.

Removed redundant loop (oops).

This revision was automatically updated to reflect the committed changes.