DUContext types for source information
Martin Bednar <martin-bVyCAMn5I1PtwjQa/[email protected]>
| Newsgroups | gmane.comp.kde.devel.kdevelop |
|---|---|
| Message-ID | <[email protected]> |
Hi, I'm trying to port the sourceinfo[1] plugin to new APIs, to actually make it useful, and I'd appreciate insight into the DUChain. What I'm trying to do at the moment is draw function parameter names at callsites. So far I've tried : - Creating a new interface that each language plugin could implement to provide the ranges of the function arguments. This felt like a lot of work to put on various language plugins. And with the language plugin having to rewalk its AST specifically for function arguments (I did use IAST), it had a discernible delay. - Creating a DUContext of type Function for arguments at every callsite, with all arguments being either Use or another DUContext. I had to hack in Literals and implicit conversions as DUContext of type Other. Then I hit passing in an address of an object: > foo ( &value); I'm stuck on this because AFAIU there is currently no DUChain reason to create a cursor/range for '&' (unless it's overloaded). I'm now thinking of creating a FunctionContext subclass of DUContext which would contain a list of Cursors/Ranges that are the entire argument. This is about as complex for language plugins as my first approach, but the info is already in the DUChain, so at least it should be faster. To be honest, my preferred approach is #2, but I'm unsure if it's workable. Any insight would be more than welcome. Second question : currently the clang plugin includes Template parameters in the Function DUContext. Making the pattern of querying the function context for all local declarations to get parameters wrong : > fCtx->localDeclarations(decl->topContext()); This pattern is in the outline plugin, and in the signature assistant, making them incorrect for templated functions. My first idea is to create a separate Template type DUContext for template params. What I do not see is how it gets connected to the function itself. If anyone with DUChain knowledge could enlighten me, I'd be very grateful. Thanks for any comments. Martin. [1] https://invent.kde.org/bednar/kdevelop/-/tree/sourceinfo
signature.asc
(application/pgp-signature, 265 B)
-----BEGIN PGP SIGNATURE----- iJEEABYKADkWIQSQahp3QLKdvHTT9rcGyo/AjsPylgUCanjDxhsUgAAAAAAEAA5t YW51MiwyLjUrMS4xMiwyLDIACgkQBsqPwI7D8pY5cwEA2wSkIfOb7T3kvdv3fu6r HS3WWnZJIOnpd+mQREtNPAoBAPLhpOsIezJOlrhkxDCU41WuGapTbzyWU32ciHTI T4wL =5rQw -----END PGP SIGNATURE-----