Show uses for __call__() and __{get,set}item__()
ClosedPublic

Authored by flherne on Nov 25 2016, 11:42 PM.

Details

Summary

Uses of __getitem__() and __setitem__() weren't shown at all.
Uses of __call__() were incorrectly shown as uses of __init__().

This removes ExpressionAst::belongsToCall, because it's always equal to ExpressionAst::parent or null.

This adds a new parameter isAlias to functionForCalled(), which allows it to distinguish between calling a class object (constructor __init__()) and calling an instance of that class with __call__().

This parameter can (and probably should) be used in other callers to improve parsing or just simplify code. For now, the default value of true causes functionForCalled() to behave as before.

Test Plan

No test regressions. No new tests, because the test framework doesn't seem to support use ranges currently.

Tested on some real projects, didn't crash.

Diff Detail

Repository
R53 KDevelop: Python Support
Lint
Lint Skipped
Unit
Unit Tests Skipped
flherne updated this revision to Diff 8527.Nov 25 2016, 11:42 PM
flherne retitled this revision from to Show uses for __call__() and __{get,set}item__().
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 25 2016, 11:42 PM
brauch accepted this revision.Nov 26 2016, 1:54 AM
brauch edited edge metadata.

Looks good to me. Feel free to rename things, esp. lots of functions could really have better names. Using what is now called functionDeclarationForCalledDeclaration in more places sounds very sensible as well.

As a regression test by the way, I recommend downloading a large python project (e.g. pypy) and just running duchainify on it (built in debug). That is quite good in triggering obscure crashes.

Very nice of you to tidy this up!

This revision is now accepted and ready to land.Nov 26 2016, 1:54 AM
nalvarez updated this object.Nov 26 2016, 2:34 AM
nalvarez edited edge metadata.
flherne updated this revision to Diff 8557.Nov 27 2016, 10:30 PM
flherne updated this object.
flherne edited the test plan for this revision. (Show Details)

Rebased on top of https://paste.kde.org/pk5cglavm (patch to rename functionDeclarationForCalledDeclaration to functionForCalled, and change its signature slightly).

Split visitCall() into its own method, where it was previously bodged into visitName().

flherne updated this revision to Diff 8580.Nov 29 2016, 12:49 AM

Now show uses for call() when the value doesn't have a declaration (most commonly, like container[0](args)).

This revision was automatically updated to reflect the committed changes.