mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 374694. CompositeCPPAliasTemplate class and a test that fails
without it.
This commit is contained in:
parent
5e30602ff3
commit
fc2cb1aaed
3 changed files with 76 additions and 14 deletions
|
@ -2046,4 +2046,19 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
public void testMemberOfTemplateTemplateParameter_Bug381824() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T t;
|
||||
// };
|
||||
// template<typename T>
|
||||
// using TAlias = S<T>;
|
||||
|
||||
// void foo() {
|
||||
// TAlias<int> myA;
|
||||
// myA.t = 42;
|
||||
// }
|
||||
public void testAliasTemplate() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue