Bug 371217

Summary: Code completion for templated classes is incorrect
Product: [Applications] kdevelop Reporter: Ian H <master.haber>
Component: Code completionAssignee: kdevelop-bugs-null
Status: CONFIRMED ---    
Severity: normal CC: amhndu, gael.lebaccon, kde, sumeettulsani1
Priority: NOR    
Version: 5.2.80   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:

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.