diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java index 8c00a830dd1..691fee0e752 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java @@ -2046,4 +2046,19 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa public void testMemberOfTemplateTemplateParameter_Bug381824() throws Exception { checkBindings(); } + + // template + // struct S { + // T t; + // }; + // template + // using TAlias = S; + + // void foo() { + // TAlias myA; + // myA.t = 42; + // } + public void testAliasTemplate() throws Exception { + checkBindings(); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java index 2c067f2bbab..66d8f36bef8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CPPCompositesFactory.java @@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.IValue; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; @@ -129,9 +130,9 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { return new CompositeCPPNamespaceScope(this, namespaces); } throw new CompositingNotImplementedError(rscope.getClass().getName()); - } catch(CoreException ce) { - CCorePlugin.log(ce); - throw new CompositingNotImplementedError(ce.getMessage()); + } catch (CoreException e) { + CCorePlugin.log(e); + throw new CompositingNotImplementedError(e.getMessage()); } } @@ -482,7 +483,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { } else if (binding instanceof ICPPFunction) { return new CompositeCPPFunctionInstance(this, (ICPPFunction) binding); } else { - throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } } } else if (binding instanceof ICPPTemplateDefinition) { @@ -499,7 +500,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { } else if (binding instanceof ICPPFunctionType) { return new CompositeCPPFunctionTemplateSpecialization(this, (ICPPFunction) binding); } else { - throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } } else { if (binding instanceof ICPPClassType) { @@ -519,10 +520,10 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { } else if (binding instanceof ICPPUsingDeclaration) { return new CompositeCPPUsingDeclarationSpecialization(this, (ICPPUsingDeclaration) binding); } else { - throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } } - } else if(binding instanceof ICPPTemplateParameter) { + } else if (binding instanceof ICPPTemplateParameter) { if (binding instanceof ICPPTemplateTypeParameter) { result = new CompositeCPPTemplateTypeParameter(this, (ICPPTemplateTypeParameter) binding); } else if (binding instanceof ICPPTemplateNonTypeParameter) { @@ -530,7 +531,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { } else if (binding instanceof ICPPTemplateTemplateParameter) { result = new CompositeCPPTemplateTemplateParameter(this, (ICPPTemplateTemplateParameter) binding); } else { - throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } } else if (binding instanceof ICPPTemplateDefinition) { if (binding instanceof ICPPClassTemplate) { @@ -542,8 +543,10 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { return new CompositeCPPMethodTemplate(this, (ICPPMethod) binding); } else if (binding instanceof ICPPFunctionTemplate) { return new CompositeCPPFunctionTemplate(this, (ICPPFunction) binding); + } else if (binding instanceof ICPPAliasTemplate) { + return new CompositeCPPAliasTemplate(this, (ICPPBinding) binding); } else { - throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } } else if (binding instanceof ICPPParameter) { result = new CompositeCPPParameter(this, (ICPPParameter) binding); @@ -569,7 +572,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { return new CompositeCPPUnknownMethod(b, def.getNameCharArray()); } } - throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } else if (binding instanceof ICPPClassType) { ICPPClassType def = (ICPPClassType) findOneBinding(binding); result = def == null ? null : new CompositeCPPClassType(this, def); @@ -596,11 +599,11 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { } else if (binding instanceof IIndexMacroContainer) { result= new CompositeMacroContainer(this, binding); } else { - throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ + throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } - } catch(CoreException ce) { - CCorePlugin.log(ce); - throw new CompositingNotImplementedError(ce.getMessage()); + } catch (CoreException e) { + CCorePlugin.log(e); + throw new CompositingNotImplementedError(e.getMessage()); } return result; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPAliasTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPAliasTemplate.java new file mode 100644 index 00000000000..96d7b06a739 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPAliasTemplate.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2012 Google, Inc and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Sergey Prigogin (Google) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.index.composite.cpp; + +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; +import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; + +class CompositeCPPAliasTemplate extends CompositeCPPBinding implements ICPPAliasTemplate { + public CompositeCPPAliasTemplate(ICompositesFactory cf, ICPPBinding delegate) { + super(cf, delegate); + } + + @Override + public Object clone() { + fail(); return null; + } + + @Override + public IType getType() { + IType type = ((ICPPAliasTemplate) rbinding).getType(); + return cf.getCompositeType(type); + } + + @Override + public boolean isSameType(IType type) { + return ((ICPPAliasTemplate) rbinding).isSameType(type); + } + + @Override + public ICPPTemplateParameter[] getTemplateParameters() { + return TemplateInstanceUtil.convert(cf, ((ICPPAliasTemplate) rbinding).getTemplateParameters()); + } +}