Bug 338348 - failed to parse template<typename> parameter of a template
Summary: failed to parse template<typename> parameter of a template
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-18 11:05 UTC by Dmitry
Modified: 2016-09-08 16:08 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In: 5.0.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry 2014-08-18 11:05:43 UTC
Consider the code below. I'm trying to write rather complex template which in turn accepts a template parameter. Seems that KDevelop is completely unaware of such syntax, so it could not provide any completion for it.

It does not matter what actual contents are used. Neither fields nor functions are completed.


template<typename T>
class Parameter {
	std::vector<T> param_field;
};

template < template<typename> TemplateParam >
class Example {
         // completing type passed as parameter
	typedef TemplateParam<int> SpecializedParam;

        // using typedef to define a field
	SpecializedParam field; 
};

void foo() {
        // Instantiating outer template
	Example<Parameter> instance;

        // trying to invoke field completion (| is the cursor)
	instance.|
}
Comment 1 Dmitry 2014-08-18 11:14:48 UTC
Sorry, by bad. Provided example was written by simplifying a real code, but I just oversimplified it.

In order to reproduce the bug we need to make fields public and try to access param_field. So either s/class/struct/g or add 'public:'.

Also we need to modify the last line as:
instance.field.|

It shows that `instance.field' is detected as SpecializedParam, but no further completion or code assist is provided when we try `instance.field.|'
Comment 2 Dmitry 2014-08-18 11:55:54 UTC
Missed the `class' keyword before TemplateParam.

P.S.: Need more sleep though...
Comment 3 Milian Wolff 2014-08-18 17:14:00 UTC
so is there a bug or not? please close this if the issue went away by getting more sleep :) otherwise, please attach an updated code snippet.

though maybe even then safe your time, since this is fixed with kdev-clang which will supersede our old c++ language plugin soon.
Comment 4 Dmitry 2014-08-19 05:15:40 UTC
Wow, kdev-clang sounds pretty cool. Looking forward to see it in the next release :)

Well, I'll fix the code snippet nevertheless.

The following code is compiling and working perfectly, still code highlight/completion is not working as one may expect:

#include <iostream>
#include <vector>

template<typename T>
struct Parameter {
	std::vector<T> vector_field;

	T get_first() { return vector_field.front(); }
};

template < template<typename> class TemplateParam >
struct Example {
	// completing type passed as parameter
	typedef TemplateParam<int> SpecializedParam;

        // using typedef to define a field
	SpecializedParam field;
};

int main(int argc, char** argv) {
	// Instantiating outer template
	Example<Parameter> instance;

	// Using inner template type
	instance.field.vector_field.push_back(42);
	std::cout << instance.field.get_first() << std::endl;
}

Neither `vector_field.push_back(42);' nor '.get_first()' is highlighted.

As I see, it's very hard to deal with template features in internal C++ parser, so it's probably never happen. 

Well, waiting for kdev-clang :)

P.S.: Thank you guys, you're doing fantastic job and an awesome IDE! In my opinion, KDevelop is just the best, because it simply doing it's job without bitching and complaining here and there as other IDEs often do. Just thanks!
Comment 5 Milian Wolff 2016-09-08 16:08:02 UTC
just checked again, with kdev 5.0 I don't see any obvious issues here anymore, you even get code completion.