Getting more info about function calls.
Milian Wolff
mail at milianw.de
Fri Oct 23 15:17:20 UTC 2009
On Friday, 23. October 2009 16:08:24 Bertjan Broeksema wrote:
> 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 Use-Range should be the function name in the 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)
You'll have to use a tokenizer or something there afaik. I don't think such
access is in the DUChain API so far. A candidate maybe?
> 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
>
--
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20091023/ab3dcaee/attachment.sig>
More information about the KDevelop-devel
mailing list