mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Bug 389009 - Enumerator with dependent value. Fixed issues described in
comments #24 and #25.
This commit is contained in:
parent
185fe357cf
commit
f331210279
4 changed files with 96 additions and 0 deletions
|
@ -280,6 +280,8 @@ public class Value implements IValue {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IValue incrementedValue(IValue value, int increment) {
|
public static IValue incrementedValue(IValue value, int increment) {
|
||||||
|
if (value == UNKNOWN)
|
||||||
|
return UNKNOWN;
|
||||||
Long val = value.numericalValue();
|
Long val = value.numericalValue();
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
return create(val.longValue() + increment);
|
return create(val.longValue() + increment);
|
||||||
|
|
|
@ -535,6 +535,10 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
||||||
return new CompositeCPPTypedefSpecialization(this, (ICPPBinding) binding);
|
return new CompositeCPPTypedefSpecialization(this, (ICPPBinding) binding);
|
||||||
} else if (binding instanceof ICPPUsingDeclaration) {
|
} else if (binding instanceof ICPPUsingDeclaration) {
|
||||||
return new CompositeCPPUsingDeclarationSpecialization(this, (ICPPUsingDeclaration) binding);
|
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 {
|
} 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$
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue