Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc-Andre Laperle2011-03-12 15:03:04 -0500
committerMarc-Andre Laperle2011-03-12 15:03:04 -0500
commitef5c018b2752bfe5f6b060652cf2ba8c05756f3a (patch)
treec2a629fff4c2b844d2cbb626531231aa69b73860
parent2c1d3433ab55f88d1b9cc91a9cf776281742b1e4 (diff)
downloadorg.eclipse.cdt-ef5c018b2752bfe5f6b060652cf2ba8c05756f3a.tar.gz
org.eclipse.cdt-ef5c018b2752bfe5f6b060652cf2ba8c05756f3a.tar.xz
org.eclipse.cdt-ef5c018b2752bfe5f6b060652cf2ba8c05756f3a.zip
Bug 335122 - DeclarationGenerator asserts for templated types with namespace. Restored assert in CPPASTTemplateId
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java2
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java43
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java11
3 files changed, 46 insertions, 10 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java
index f5fd10662b..a6b05cc27e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateId.java
@@ -76,7 +76,7 @@ public class CPPASTTemplateId extends CPPASTNameBase implements ICPPASTTemplateI
public void setTemplateName(IASTName name) {
assertNotFrozen();
- assert !(name instanceof ICPPASTTemplateId);
+ assert !(name instanceof ICPPASTQualifiedName) && !(name instanceof ICPPASTTemplateId);
templateName = name;
if (name != null) {
name.setParent(this);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java
index 0762fb7d60..3b24951995 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/DeclarationGeneratorImpl.java
@@ -303,19 +303,46 @@ public class DeclarationGeneratorImpl extends DeclarationGenerator {
private IASTDeclSpecifier getDeclSpecForTemplate(ICPPTemplateInstance type) {
IASTName name = getName(type);
if (factory instanceof ICPPNodeFactory) {
- ICPPNodeFactory cppFactory = (ICPPNodeFactory) factory;
- ICPPASTTemplateId tempId = cppFactory.newTemplateId(name);
- for (ICPPTemplateArgument arg : type.getTemplateArguments()) {
- IASTDeclSpecifier argDeclSpec = createDeclSpecFromType(arg.isTypeValue() ? arg
- .getTypeValue() : arg.getTypeOfNonTypeValue());
- IASTTypeId typeId = cppFactory.newTypeId(argDeclSpec, null);
- tempId.addTemplateArgument(typeId);
+
+ if (name instanceof ICPPASTQualifiedName) {
+ ICPPASTQualifiedName fullQualifiedName = (ICPPASTQualifiedName) name;
+ IASTName templateName = fullQualifiedName.getLastName();
+ ICPPASTTemplateId tempId = getTemplateId(type, templateName);
+
+ ICPPASTQualifiedName newQualifiedName = ((ICPPNodeFactory) factory)
+ .newQualifiedName();
+ int nbQualifiedNames = fullQualifiedName.getNames().length;
+ if (nbQualifiedNames > 1) {
+ for (int i = 0; i < nbQualifiedNames - 1; i++) {
+ newQualifiedName.addName(fullQualifiedName.getNames()[i].copy());
+ }
+ }
+ newQualifiedName.addName(tempId);
+
+ return factory.newTypedefNameSpecifier(newQualifiedName);
+
+ } else {
+ IASTName templateName = getName(type);
+ ICPPASTTemplateId tempId = getTemplateId(type, templateName);
+ return factory.newTypedefNameSpecifier(tempId);
}
- return factory.newTypedefNameSpecifier(tempId);
}
+
return factory.newTypedefNameSpecifier(name);
}
+ private ICPPASTTemplateId getTemplateId(ICPPTemplateInstance type, IASTName templateName) {
+ ICPPNodeFactory cppFactory = (ICPPNodeFactory) factory;
+ ICPPASTTemplateId tempId = cppFactory.newTemplateId(templateName.copy());
+ for (ICPPTemplateArgument arg : type.getTemplateArguments()) {
+ IASTDeclSpecifier argDeclSpec = createDeclSpecFromType(arg.isTypeValue() ? arg
+ .getTypeValue() : arg.getTypeOfNonTypeValue());
+ IASTTypeId typeId = cppFactory.newTypeId(argDeclSpec, null);
+ tempId.addTemplateArgument(typeId);
+ }
+ return tempId;
+ }
+
private IASTNamedTypeSpecifier getDeclSpecForBinding(IBinding binding) {
IASTName name = getName(binding);
return factory.newTypedefNameSpecifier(name);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java
index 2e4fc73eac..a4f4c4c5fa 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CRefactoring.java
@@ -207,7 +207,16 @@ public abstract class CRefactoring extends Refactoring {
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
ModificationCollector collector = new ModificationCollector();
collectModifications(pm, collector);
- CCompositeChange finalChange = collector.createFinalChange();
+ CCompositeChange finalChange = null;
+ try {
+ lockIndex();
+ finalChange = collector.createFinalChange();
+ } catch (InterruptedException e) {
+ throw new OperationCanceledException();
+ } finally {
+ unlockIndex();
+ }
+
finalChange.setDescription(new RefactoringChangeDescriptor(getRefactoringDescriptor()));
return finalChange;
}

Back to the top