Getting more info about function calls.

Bertjan Broeksema bertjan at kdab.net
Fri Oct 23 14:08:24 UTC 2009


Hi all,

I'd like to do the following.

Given the use of a function, how can I get the following information:

* The range of the function name of the specific call.
* The range of the accessor (in case of a non-global method  or calls on this)
* The range of the expression on which the method is called (in case of non 
global methods or calls on this)

I have the idea that non of this information is currently accessible given the 
use of a function (i.e. one of the SimpleRange objects returned by 
ClassFunctionDeclaration::uses() or FunctionDeclaration::uses()). I think this 
needs work in the DUChain builder but I dont' understand it well enough yet.

My idea would be to add a new structure FunctionCall, which will be stored in 
the DUChain and contain the above information. In addition it could also store 
a pointer to the declaration of the this object (i.e. the object on which it 
is called) in case of non global functions. Any suggestions on how to 
implement this would be more than welcome. If you think this is an useful 
addition for KDevelop in general I'd of course be more than happy to add it to 
the (cpp)duchain directly.

By the way, the use case is this: In my transform language i'd like to provide 
access to different parts of a call.

before transform:
Class *obj2 = (Class*)someObj->child("name", "Class");
Class *obj3 = (Class*)child("name", "Class");

After transform:
Class *obj2 = (Class*)qFindChild<Class>(someObj, "name");
Class *obj3 = (Class*)qFindChild<Class>("name", "Class");

Rule:
<action type="Replace" item="*">
qFindChild<${literalVal(MemberArg[1])}>(${Object},${MemberArg[0]})
</action>

Cheers,

Bertjan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20091023/7267f083/attachment.html>


More information about the KDevelop-devel mailing list