D18218: Properly display argument names of template functions
Thomas Schöps
noreply at phabricator.kde.org
Sat Jan 12 21:48:31 GMT 2019
thomassc created this revision.
Herald added a project: KDevelop.
Herald added a subscriber: kdevelop-devel.
thomassc requested review of this revision.
REVISION SUMMARY
When hovering over a C++ template function, the function argument names were shown incorrectly. For example, for the following function definition:
template <int a>
void foo(char b, char c) {}
The function would be displayed like this in the toolip:
void foo(char a, char b)
This is because argument names, different from argument types, are fetched from argumentContext->localDeclarations() for display.
In case of template functions, both the template arguments and the function arguments are in this list, which was not accounted for.
This diff changes the behavior to count the function arguments from the end of the local declarations instead of the start, which fixes the bug.
(Note: I am not sure whether it is possible that the local declarations list also contains other entries. I did not observe
this during some short testing. Also, not sure what the situation is for other languages than C++.)
Note to reviewers: Before realizing that the issue can be solved as easily as in this diff, I implemented a solution
which associates template function parameters with that function, in the same way that template class parameters are
associated with that class (in the Identifier class). I could also post this if you think it is useful.
TEST PLAN
Some manual testing.
REPOSITORY
R32 KDevelop
BRANCH
fix_template_function_arguments_3 (branched from master)
REVISION DETAIL
https://phabricator.kde.org/D18218
AFFECTED FILES
kdevplatform/language/duchain/navigation/abstractdeclarationnavigationcontext.cpp
To: thomassc
Cc: kdevelop-devel, glebaccon, hase, antismap, iodelay, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20190112/4aa9ef7a/attachment.html>
More information about the KDevelop-devel
mailing list