mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 00:35:49 +02:00
Bug 510289 - Fix implementation refactoring with template parameters
The implementation of methods with parameter declaration or with template template parameters didn't work. Change-Id: I783dedc5ffecd6721293d52f13548fd9e73999bc Signed-off-by: Marco Stornelli <marco.stornelli@gmail.com>
This commit is contained in:
parent
b5cde3b61c
commit
6647808d0e
2 changed files with 61 additions and 0 deletions
|
@ -825,4 +825,43 @@ public class ImplementMethodRefactoringTest extends RefactoringTestBase {
|
|||
assertRefactoringSuccess();
|
||||
}
|
||||
|
||||
//A.h
|
||||
//template <int N>
|
||||
//struct Waldo {
|
||||
// /*$*/void find();/*$$*/
|
||||
//};
|
||||
//
|
||||
//====================
|
||||
//template <int N>
|
||||
//struct Waldo {
|
||||
// void find();
|
||||
//};
|
||||
//
|
||||
//template<int N>
|
||||
//inline void Waldo<N>::find() {
|
||||
//}
|
||||
public void testTemplateParameters_Bug510289() throws Exception {
|
||||
expectedFinalInfos = 1;
|
||||
assertRefactoringSuccess();
|
||||
}
|
||||
|
||||
//A.h
|
||||
//template <template<class> class N>
|
||||
//struct Waldo {
|
||||
// /*$*/void find();/*$$*/
|
||||
//};
|
||||
//
|
||||
//====================
|
||||
//template <template<class> class N>
|
||||
//struct Waldo {
|
||||
// void find();
|
||||
//};
|
||||
//
|
||||
//template<template<class > class N>
|
||||
//inline void Waldo<N>::find() {
|
||||
//}
|
||||
public void testTemplateTemplateParameters_Bug510289() throws Exception {
|
||||
expectedFinalInfos = 1;
|
||||
assertRefactoringSuccess();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,8 +26,10 @@ import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNamedTypeSpecifier;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleTypeTemplateParameter;
|
||||
|
@ -119,6 +121,26 @@ public class NamespaceHelper {
|
|||
namedTypeSpecifier.setName(simpleTypeTemplateParameter.getName().copy(CopyStyle.withLocations));
|
||||
id.setDeclSpecifier(namedTypeSpecifier);
|
||||
|
||||
templateId.addTemplateArgument(id);
|
||||
} else if (templateParameter instanceof ICPPASTParameterDeclaration) {
|
||||
ICPPASTParameterDeclaration parDecl = (ICPPASTParameterDeclaration) templateParameter;
|
||||
|
||||
CPPASTTypeId id = new CPPASTTypeId();
|
||||
|
||||
CPPASTNamedTypeSpecifier namedTypeSpecifier = new CPPASTNamedTypeSpecifier();
|
||||
namedTypeSpecifier.setName(parDecl.getDeclarator().getName().copy(CopyStyle.withLocations));
|
||||
id.setDeclSpecifier(namedTypeSpecifier);
|
||||
|
||||
templateId.addTemplateArgument(id);
|
||||
} else if (templateParameter instanceof ICPPASTTemplatedTypeTemplateParameter) {
|
||||
ICPPASTTemplatedTypeTemplateParameter parDecl = (ICPPASTTemplatedTypeTemplateParameter) templateParameter;
|
||||
|
||||
CPPASTTypeId id = new CPPASTTypeId();
|
||||
|
||||
CPPASTNamedTypeSpecifier namedTypeSpecifier = new CPPASTNamedTypeSpecifier();
|
||||
namedTypeSpecifier.setName(parDecl.getName().copy(CopyStyle.withLocations));
|
||||
id.setDeclSpecifier(namedTypeSpecifier);
|
||||
|
||||
templateId.addTemplateArgument(id);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue