Bug 371217 - Code completion for templated classes is incorrect
Summary: Code completion for templated classes is incorrect
Status: CONFIRMED
Alias: None
Product: kdevelop
Classification: Applications
Component: Code completion (show other bugs)
Version: 5.2.80
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-10-19 13:04 UTC by Ian H
Modified: 2018-10-19 16:54 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ian H 2016-10-19 13:04:08 UTC
it seems like all? templated code in qt (QList,QVector,QPair,QMap...) does not get the correct responses from the code completion.

When getting code completion for one of these classes, it properly gives a list of all functions, but it does not mark them as functions, same thing happens for qpair's member variables(first,second). Instead the completion thinks they are just text. hitting enter on one of them will just put in the text, but does not act like a method normally acts(adding parenthesis, etc).

the detailed completion recognizes the functions and return types etc, but still does not mark them with the function or variable type(gray or purple symbol), and does the same thing as above.


Reproducible: Always

Steps to Reproduce:
1. declare any templated class on the stack in a function:
void foo()
{
 QList<int> bar;
}

2. attempt to use the variable and ask for code completion, detailed or not:
int i=bar. {ctrl+space)


Actual Results:  
code completion will appear, but it thinks none of the methods are methods and none of the variables are variables.

Expected Results:  
The code completion should detect what are methods and variables and act as such, like it does for every non-templated class( QDir, QString, QDateTime, QFile...)
Comment 1 Gaël Le Baccon 2018-09-28 14:11:41 UTC
In fact the code completion is " partially broken" for all template type not just for Qt.

Steps to reproduce:

template<class T>
class Foo
{
public:
    void bar(int i);
};

Foo<int> foo;
foo. {ctrl + space}


It's because in ClangCodeCompletionContext::completionItems the clang_getCompletionParent function return "Foo" for "bar" function so the QualifiedIdentifier is "Foo::bar" when the KDevelop::Declaration QualifiedIdentifier is "Foo< T >::bar".

As the declaration identifier does not match, KDevelop does not find informations extracted during parse process and create simple completion item with minimal information.
Comment 2 Amish Naidu 2018-10-19 16:30:39 UTC
*** Bug 363057 has been marked as a duplicate of this bug. ***
Comment 3 Amish Naidu 2018-10-19 16:54:50 UTC
Accidentally marked the wrong bug, please ignore the previous comment.