Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 331963

Summary: Extract local variable doesn't put template type parameters
Product: [Tools] CDT Reporter: xeor
Component: cdt-refactoringAssignee: Emanuel Graf <emanuel>
Status: RESOLVED FIXED QA Contact: Emanuel Graf <emanuel>
Severity: normal    
Priority: P3 CC: cdtdoug
Version: 8.0   
Target Milestone: 7.0.2   
Hardware: PC   
OS: Windows Vista   
Whiteboard:
Attachments:
Description Flags
Patch incl. test cases emanuel: iplog-

Description xeor CLA 2010-12-06 18:21:30 EST
Build Identifier: M20100909-0800

When extracted expression is of template type, the resulting variable will be declared with type name only, without template parameters.

The source of the problem problem seems to be in org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateDefinition.getNameCharArray() called by org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor.getQualifiedNameCharArray(IBinding) - only template name is returned 

Reproducible: Always

Steps to Reproduce:
The following sample code:
template<class T>
class Foo
{
};

Foo<int> getFoo();

int main() {

	getFoo(); // This line is selected

	return 0;
}

will result in proposal

Foo getFoo0 = getFoo();
getFoo0;

instead of

Foo<int> getFoo0 = getFoo();
getFoo0;
Comment 1 xeor CLA 2010-12-06 18:44:36 EST
(In reply to comment #0)

> The source of the problem problem seems to be in
> org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateDefinition.getNameCharArray()

Provided the wrong name, the right one is org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSpecialization.getNameCharArray()
Comment 2 Emanuel Graf CLA 2011-01-04 04:04:55 EST
Created attachment 185984 [details]
Patch incl. test cases
Comment 3 Emanuel Graf CLA 2011-01-04 04:17:43 EST
Fixed in HEAD an 7.0 > 20110104