diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java index 5a5673d05f8..dbb79403e81 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/Value.java @@ -280,6 +280,8 @@ public class Value implements IValue { } public static IValue incrementedValue(IValue value, int increment) { + if (value == UNKNOWN) + return UNKNOWN; Long val = value.numericalValue(); if (val != null) { return create(val.longValue() + increment); 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 3589b59cfa7..476aa1d9f30 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 @@ -535,6 +535,10 @@ public class CPPCompositesFactory extends AbstractCompositeFactory { return new CompositeCPPTypedefSpecialization(this, (ICPPBinding) binding); } else if (binding instanceof ICPPUsingDeclaration) { return new CompositeCPPUsingDeclarationSpecialization(this, (ICPPUsingDeclaration) binding); + } else if (binding instanceof ICPPEnumeration) { + return new CompositeCPPEnumerationSpecialization(this, (ICPPEnumeration) binding); + } else if (binding instanceof IEnumerator) { + return new CompositeCPPEnumeratorSpecialization(this, (IEnumerator) binding); } else { throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumerationSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumerationSpecialization.java new file mode 100644 index 00000000000..139f53ecf68 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumerationSpecialization.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2013 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.IBinding; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.parser.util.ObjectMap; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap; +import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; + +class CompositeCPPEnumerationSpecialization extends CompositeCPPEnumeration implements ICPPSpecialization { + public CompositeCPPEnumerationSpecialization(ICompositesFactory cf, ICPPEnumeration delegate) { + super(cf, delegate); + } + + @Override + public IBinding getSpecializedBinding() { + return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding); + } + + @Override + public ICPPTemplateParameterMap getTemplateParameterMap() { + IBinding owner= getOwner(); + if (owner instanceof ICPPSpecialization) { + return ((ICPPSpecialization) owner).getTemplateParameterMap(); + } + return CPPTemplateParameterMap.EMPTY; + } + + @Override + @Deprecated + public ObjectMap getArgumentMap() { + return TemplateInstanceUtil.getArgumentMap(cf, rbinding); + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumeratorSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumeratorSpecialization.java new file mode 100644 index 00000000000..bc6ad7c1ec6 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPEnumeratorSpecialization.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2013 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.IBinding; +import org.eclipse.cdt.core.dom.ast.IEnumerator; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap; +import org.eclipse.cdt.core.parser.util.ObjectMap; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap; +import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; + +class CompositeCPPEnumeratorSpecialization extends CompositeCPPEnumerator implements ICPPSpecialization { + public CompositeCPPEnumeratorSpecialization(ICompositesFactory cf, IEnumerator delegate) { + super(cf, delegate); + } + + @Override + public IBinding getSpecializedBinding() { + return TemplateInstanceUtil.getSpecializedBinding(cf, rbinding); + } + + @Override + public ICPPTemplateParameterMap getTemplateParameterMap() { + IBinding owner= getOwner(); + if (owner instanceof ICPPSpecialization) { + return ((ICPPSpecialization) owner).getTemplateParameterMap(); + } + return CPPTemplateParameterMap.EMPTY; + } + + @Override + @Deprecated + public ObjectMap getArgumentMap() { + return TemplateInstanceUtil.getArgumentMap(cf, rbinding); + } +}