1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 02:36:01 +02:00

toString methods.

This commit is contained in:
Sergey Prigogin 2008-03-16 04:53:12 +00:00
parent c09235c6d1
commit ce309040bd
9 changed files with 1216 additions and 1149 deletions

View file

@ -42,22 +42,22 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
/** /**
* @param instance * @param instance
*/ */
public CPPClassSpecializationScope( ICPPSpecialization specialization ) { public CPPClassSpecializationScope(ICPPSpecialization specialization) {
this.specialization = specialization; this.specialization = specialization;
} }
private ICPPClassType getOriginalClass(){ private ICPPClassType getOriginalClass() {
return (ICPPClassType) specialization.getSpecializedBinding(); return (ICPPClassType) specialization.getSpecializedBinding();
} }
private IBinding getInstance(IBinding binding) { private IBinding getInstance(IBinding binding) {
if( instanceMap.containsKey( binding ) ) { if (instanceMap.containsKey(binding)) {
return (IBinding) instanceMap.get( binding ); return (IBinding) instanceMap.get(binding);
} else if (!(binding instanceof ICPPClassTemplatePartialSpecialization)) { } else if (!(binding instanceof ICPPClassTemplatePartialSpecialization)) {
IBinding spec = CPPTemplates.createSpecialization( this, binding, specialization.getArgumentMap() ); IBinding spec = CPPTemplates.createSpecialization(this, binding, specialization.getArgumentMap());
if( instanceMap == ObjectMap.EMPTY_MAP ) if (instanceMap == ObjectMap.EMPTY_MAP)
instanceMap = new ObjectMap(2); instanceMap = new ObjectMap(2);
instanceMap.put( binding, spec ); instanceMap.put(binding, spec);
return spec; return spec;
} }
return null; return null;
@ -71,38 +71,43 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY); return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY);
} }
public IBinding getBinding( IASTName name, boolean forceResolve, IIndexFileSet fileSet) throws DOMException { public IBinding getBinding(IASTName name, boolean forceResolve, IIndexFileSet fileSet) throws DOMException {
char [] c = name.toCharArray(); char[] c = name.toCharArray();
if( CharArrayUtils.equals( c, specialization.getNameCharArray() ) ) if (CharArrayUtils.equals(c, specialization.getNameCharArray()) &&
if (!CPPClassScope.isConstructorReference( name )) !CPPClassScope.isConstructorReference(name)) {
return specialization; return specialization;
}
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding(); ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
IScope classScope = specialized.getCompositeScope(); IScope classScope = specialized.getCompositeScope();
IBinding[] bindings = classScope != null ? classScope.getBindings(name, forceResolve, false) : null; IBinding[] bindings = classScope != null ? classScope.getBindings(name, forceResolve, false) : null;
if (bindings == null) return null; if (bindings == null)
return null;
IBinding[] specs = new IBinding[0]; IBinding[] specs = new IBinding[0];
for (int i = 0; i < bindings.length; i++) { for (int i = 0; i < bindings.length; i++) {
specs = (IBinding[]) ArrayUtil.append(IBinding.class, specs, getInstance(bindings[i])); specs = (IBinding[]) ArrayUtil.append(IBinding.class, specs, getInstance(bindings[i]));
} }
specs = (IBinding[]) ArrayUtil.trim(IBinding.class, specs); specs = (IBinding[]) ArrayUtil.trim(IBinding.class, specs);
return CPPSemantics.resolveAmbiguities( name, specs ); return CPPSemantics.resolveAmbiguities(name, specs);
} }
public IBinding[] getBindings( IASTName name, boolean forceResolve, boolean prefixLookup, IIndexFileSet fileSet ) throws DOMException { public IBinding[] getBindings(IASTName name, boolean forceResolve, boolean prefixLookup,
char [] c = name.toCharArray(); IIndexFileSet fileSet) throws DOMException {
char[] c = name.toCharArray();
IBinding[] result = null; IBinding[] result = null;
if( (!prefixLookup && CharArrayUtils.equals( c, specialization.getNameCharArray() )) if ((!prefixLookup && CharArrayUtils.equals(c, specialization.getNameCharArray())) ||
|| (prefixLookup && CharArrayUtils.equals(specialization.getNameCharArray(), 0, c.length, c, true)) ) (prefixLookup && CharArrayUtils.equals(specialization.getNameCharArray(), 0, c.length, c, true))) {
result = new IBinding[] { specialization }; result = new IBinding[] { specialization };
}
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding(); ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
IScope classScope = specialized.getCompositeScope(); IScope classScope = specialized.getCompositeScope();
IBinding[] bindings = classScope != null ? classScope.getBindings(name, forceResolve, prefixLookup, fileSet) : null; IBinding[] bindings = classScope != null ?
classScope.getBindings(name, forceResolve, prefixLookup, fileSet) : null;
if (bindings != null) { if (bindings != null) {
for (int i = 0; i < bindings.length; i++) { for (int i = 0; i < bindings.length; i++) {
@ -124,7 +129,7 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getImplicitMethods() * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getImplicitMethods()
*/ */
public ICPPMethod[] getImplicitMethods() { public ICPPMethod[] getImplicitMethods() {
//implicit methods shouldn't have implicit specializations // Implicit methods shouldn't have implicit specializations
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
} }
@ -138,7 +143,7 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
return null; return null;
} }
protected ICPPConstructor [] getConstructors() throws DOMException { protected ICPPConstructor[] getConstructors() throws DOMException {
ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding(); ICPPClassType specialized = (ICPPClassType) specialization.getSpecializedBinding();
ICPPConstructor[] bindings = specialized.getConstructors(); ICPPConstructor[] bindings = specialized.getConstructors();
@ -175,12 +180,12 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
public IScope getParent() throws DOMException { public IScope getParent() throws DOMException {
ICPPClassType cls = getOriginalClass(); ICPPClassType cls = getOriginalClass();
ICPPClassScope scope = (ICPPClassScope)cls.getCompositeScope(); ICPPClassScope scope = (ICPPClassScope)cls.getCompositeScope();
if( scope != null ) if (scope != null)
return scope.getParent(); return scope.getParent();
if( cls instanceof ICPPInternalBinding ){ if (cls instanceof ICPPInternalBinding) {
IASTNode [] nds = ((ICPPInternalBinding)cls).getDeclarations(); IASTNode[] nds = ((ICPPInternalBinding)cls).getDeclarations();
if( nds != null && nds.length > 0 ) if (nds != null && nds.length > 0)
return CPPVisitor.getContainingScope( nds[0] ); return CPPVisitor.getContainingScope(nds[0]);
} }
return null; return null;
} }
@ -189,7 +194,7 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
*/ */
public IBinding[] find(String name) throws DOMException { public IBinding[] find(String name) throws DOMException {
return CPPSemantics.findBindings( this, name, false ); return CPPSemantics.findBindings(this, name, false);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -200,18 +205,24 @@ public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternal
if (!ASTInternal.isFullyCached(origScope)) { if (!ASTInternal.isFullyCached(origScope)) {
CPPSemantics.LookupData data = new CPPSemantics.LookupData(); CPPSemantics.LookupData data = new CPPSemantics.LookupData();
try { try {
CPPSemantics.lookupInScope( data, origScope, null ); CPPSemantics.lookupInScope(data, origScope, null);
} catch (DOMException e) { } catch (DOMException e) {
} }
} }
return true; return true;
} }
//this scope does not cache its own names // This scope does not cache its own names
public void setFullyCached(boolean b) {} public void setFullyCached(boolean b) {}
public void flushCache() {} public void flushCache() {}
public void addName(IASTName name) {} public void addName(IASTName name) {}
public IASTNode getPhysicalNode() {return null;} public IASTNode getPhysicalNode() { return null; }
public void removeBinding(IBinding binding) {} public void removeBinding(IBinding binding) {}
public void addBinding(IBinding binding) {} public void addBinding(IBinding binding) {}
@Override
public String toString() {
IName name = getScopeName();
return name != null ? name.toString() : "<unnamed scope>"; //$NON-NLS-1$
}
} }

View file

@ -12,6 +12,7 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
@ -35,23 +36,24 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
*/ */
public class CPPFunctionSpecialization extends CPPSpecialization implements ICPPFunction, ICPPInternalFunction { public class CPPFunctionSpecialization extends CPPSpecialization implements ICPPFunction, ICPPInternalFunction {
private IFunctionType type = null; private IFunctionType type = null;
private IParameter [] specializedParams = null; private IParameter[] specializedParams = null;
public CPPFunctionSpecialization(IBinding orig, ICPPScope scope, ObjectMap argMap ) { public CPPFunctionSpecialization(IBinding orig, ICPPScope scope, ObjectMap argMap) {
super(orig, scope, argMap); super(orig, scope, argMap);
} }
private ICPPFunction getFunction(){ private ICPPFunction getFunction() {
return (ICPPFunction) getSpecializedBinding(); return (ICPPFunction) getSpecializedBinding();
} }
public IParameter[] getParameters() throws DOMException { public IParameter[] getParameters() throws DOMException {
if( specializedParams == null ){ if (specializedParams == null) {
ICPPFunction function = (ICPPFunction) getSpecializedBinding(); ICPPFunction function = (ICPPFunction) getSpecializedBinding();
IParameter [] params = function.getParameters(); IParameter[] params = function.getParameters();
specializedParams = new IParameter[ params.length]; specializedParams = new IParameter[params.length];
for( int i = 0; i < params.length; i++ ){ for (int i = 0; i < params.length; i++) {
specializedParams[i] = new CPPParameterSpecialization( (ICPPParameter)params[i], (ICPPScope) getScope(), argumentMap ); specializedParams[i] = new CPPParameterSpecialization((ICPPParameter)params[i],
(ICPPScope) getScope(), argumentMap);
} }
} }
return specializedParams; return specializedParams;
@ -59,7 +61,7 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
public IScope getFunctionScope() { public IScope getFunctionScope() {
// resolveAllDeclarations(); // resolveAllDeclarations();
// if( definition != null ){ // if (definition != null) {
// return definition.getFunctionScope(); // return definition.getFunctionScope();
// } // }
// //
@ -68,10 +70,10 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
} }
public IFunctionType getType() throws DOMException { public IFunctionType getType() throws DOMException {
if( type == null ){ if (type == null) {
ICPPFunction function = (ICPPFunction) getSpecializedBinding(); ICPPFunction function = (ICPPFunction) getSpecializedBinding();
type = function.getType(); type = function.getType();
type = (IFunctionType) CPPTemplates.instantiateType( type, argumentMap ); type = (IFunctionType) CPPTemplates.instantiateType(type, argumentMap);
} }
return type; return type;
@ -82,9 +84,9 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
} }
public boolean isInline() throws DOMException { public boolean isInline() throws DOMException {
if( getDefinition() != null ){ if (getDefinition() != null) {
IASTNode def = getDefinition(); IASTNode def = getDefinition();
while( !(def instanceof IASTFunctionDefinition) ) while (!(def instanceof IASTFunctionDefinition))
def = def.getParent(); def = def.getParent();
return ((IASTFunctionDefinition)def).getDeclSpecifier().isInline(); return ((IASTFunctionDefinition)def).getDeclSpecifier().isInline();
} }
@ -104,48 +106,48 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
public boolean isStatic(boolean resolveAll) { public boolean isStatic(boolean resolveAll) {
//TODO resolveAll //TODO resolveAll
IBinding f = getSpecializedBinding(); IBinding f = getSpecializedBinding();
if( f instanceof ICPPInternalFunction) if (f instanceof ICPPInternalFunction)
return ((ICPPInternalFunction)f).isStatic( resolveAll); return ((ICPPInternalFunction)f).isStatic(resolveAll);
if( f instanceof IIndexBinding && f instanceof ICPPFunction ) { if (f instanceof IIndexBinding && f instanceof ICPPFunction) {
try { try {
return ((ICPPFunction) f).isStatic(); return ((ICPPFunction) f).isStatic();
} catch(DOMException de) { /* cannot occur as we query the index */} } catch(DOMException de) { /* cannot occur as we query the index */}
} }
return CPPFunction.hasStorageClass( this, IASTDeclSpecifier.sc_static); return CPPFunction.hasStorageClass(this, IASTDeclSpecifier.sc_static);
} }
public boolean isExtern() throws DOMException { public boolean isExtern() throws DOMException {
ICPPFunction f = (ICPPFunction) getSpecializedBinding(); ICPPFunction f = (ICPPFunction) getSpecializedBinding();
if( f != null ) if (f != null)
return f.isExtern(); return f.isExtern();
return CPPFunction.hasStorageClass( this, IASTDeclSpecifier.sc_extern ); return CPPFunction.hasStorageClass(this, IASTDeclSpecifier.sc_extern);
} }
public boolean isAuto() throws DOMException { public boolean isAuto() throws DOMException {
ICPPFunction f = (ICPPFunction) getSpecializedBinding(); ICPPFunction f = (ICPPFunction) getSpecializedBinding();
if( f != null ) if (f != null)
return f.isAuto(); return f.isAuto();
return CPPFunction.hasStorageClass( this, IASTDeclSpecifier.sc_auto ); return CPPFunction.hasStorageClass(this, IASTDeclSpecifier.sc_auto);
} }
public boolean isRegister() throws DOMException { public boolean isRegister() throws DOMException {
ICPPFunction f = (ICPPFunction) getSpecializedBinding(); ICPPFunction f = (ICPPFunction) getSpecializedBinding();
if( f != null ) if (f != null)
return f.isRegister(); return f.isRegister();
return CPPFunction.hasStorageClass( this, IASTDeclSpecifier.sc_register ); return CPPFunction.hasStorageClass(this, IASTDeclSpecifier.sc_register);
} }
public boolean takesVarArgs() throws DOMException { public boolean takesVarArgs() throws DOMException {
ICPPFunction f = (ICPPFunction) getSpecializedBinding(); ICPPFunction f = (ICPPFunction) getSpecializedBinding();
if( f != null ) if (f != null)
return f.takesVarArgs(); return f.takesVarArgs();
ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) getDefinition(); ICPPASTFunctionDeclarator dtor = (ICPPASTFunctionDeclarator) getDefinition();
if( dtor != null ){ if (dtor != null) {
return dtor.takesVarArgs(); return dtor.takesVarArgs();
} }
ICPPASTFunctionDeclarator [] ds = (ICPPASTFunctionDeclarator[]) getDeclarations(); ICPPASTFunctionDeclarator[] ds = (ICPPASTFunctionDeclarator[]) getDeclarations();
if( ds != null && ds.length > 0 ){ if (ds != null && ds.length > 0) {
return ds[0].takesVarArgs(); return ds[0].takesVarArgs();
} }
return false; return false;
@ -154,33 +156,33 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction#resolveParameter(org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration) * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction#resolveParameter(org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration)
*/ */
public IBinding resolveParameter( IASTParameterDeclaration param ) { public IBinding resolveParameter(IASTParameterDeclaration param) {
IASTDeclarator dtor = param.getDeclarator(); IASTDeclarator dtor = param.getDeclarator();
while( dtor.getNestedDeclarator() != null ) while (dtor.getNestedDeclarator() != null)
dtor = dtor.getNestedDeclarator(); dtor = dtor.getNestedDeclarator();
IASTName name = dtor.getName(); IASTName name = dtor.getName();
IBinding binding = name.getBinding(); IBinding binding = name.getBinding();
if( binding != null ) if (binding != null)
return binding; return binding;
ICPPASTFunctionDeclarator fdtor = (ICPPASTFunctionDeclarator) param.getParent(); ICPPASTFunctionDeclarator fdtor = (ICPPASTFunctionDeclarator) param.getParent();
IASTParameterDeclaration [] ps = fdtor.getParameters(); IASTParameterDeclaration[] ps = fdtor.getParameters();
int i = 0; int i = 0;
for( ; i < ps.length; i++ ){ for (; i < ps.length; i++) {
if( param == ps[i] ) if (param == ps[i])
break; break;
} }
try { try {
IParameter [] params = getParameters(); IParameter[] params = getParameters();
if( i < params.length ){ if (i < params.length) {
name.setBinding( params[i] ); name.setBinding(params[i]);
if( params[i] instanceof ICPPInternalBinding ) if (params[i] instanceof ICPPInternalBinding)
((ICPPInternalBinding)params[i]).addDeclaration( name ); ((ICPPInternalBinding)params[i]).addDeclaration(name);
return params[i]; return params[i];
} }
} catch ( DOMException e ) { } catch (DOMException e) {
return e.getProblem(); return e.getProblem();
} }
return null; return null;
@ -189,42 +191,61 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
@Override @Override
public void addDefinition(IASTNode node) { public void addDefinition(IASTNode node) {
IASTNode n = node; IASTNode n = node;
while( n instanceof IASTName ) while (n instanceof IASTName)
n = n.getParent(); n = n.getParent();
if( !(n instanceof ICPPASTFunctionDeclarator) ) if (!(n instanceof ICPPASTFunctionDeclarator))
return; return;
updateParameterBindings( (ICPPASTFunctionDeclarator) n ); updateParameterBindings((ICPPASTFunctionDeclarator) n);
super.addDefinition( n ); super.addDefinition(n);
} }
@Override @Override
public void addDeclaration(IASTNode node) { public void addDeclaration(IASTNode node) {
IASTNode n = node; IASTNode n = node;
while( n instanceof IASTName ) while (n instanceof IASTName)
n = n.getParent(); n = n.getParent();
if( !(n instanceof ICPPASTFunctionDeclarator) ) if (!(n instanceof ICPPASTFunctionDeclarator))
return; return;
updateParameterBindings( (ICPPASTFunctionDeclarator) n ); updateParameterBindings((ICPPASTFunctionDeclarator) n);
super.addDeclaration( n ); super.addDeclaration(n);
} }
protected void updateParameterBindings( ICPPASTFunctionDeclarator fdtor ){
IParameter [] params = null; protected void updateParameterBindings(ICPPASTFunctionDeclarator fdtor) {
IParameter[] params = null;
try { try {
params = getParameters(); params = getParameters();
} catch ( DOMException e ) { } catch (DOMException e) {
return; return;
} }
IASTParameterDeclaration [] nps = fdtor.getParameters(); IASTParameterDeclaration[] nps = fdtor.getParameters();
for( int i = 0; i < nps.length; i++ ){ for (int i = 0; i < nps.length; i++) {
//temp = (CPPParameter) ops[i].getDeclarator().getName().getBinding(); //temp = (CPPParameter) ops[i].getDeclarator().getName().getBinding();
if( params[i] != null ){ if (params[i] != null) {
IASTDeclarator dtor = nps[i].getDeclarator(); IASTDeclarator dtor = nps[i].getDeclarator();
while( dtor.getNestedDeclarator() != null ) while (dtor.getNestedDeclarator() != null)
dtor = dtor.getNestedDeclarator(); dtor = dtor.getNestedDeclarator();
IASTName name = dtor.getName(); IASTName name = dtor.getName();
name.setBinding( params[i] ); name.setBinding(params[i]);
if( params[i] instanceof ICPPInternalBinding ) if (params[i] instanceof ICPPInternalBinding)
((ICPPInternalBinding)params[i]).addDeclaration( name ); ((ICPPInternalBinding) params[i]).addDeclaration(name);
} }
} }
} }
@Override
public String toString() {
StringBuilder result = new StringBuilder();
result.append(getName());
IFunctionType t = null;
try {
t = getType();
} catch (DOMException e) {
}
result.append(t != null ? ASTTypeUtil.getParameterTypeString(t) : "()"); //$NON-NLS-1$
if (argumentMap != null) {
result.append(" ");
result.append(argumentMap.toString());
}
return result.toString();
}
} }

View file

@ -51,15 +51,17 @@ import org.eclipse.core.runtime.NullProgressMonitor;
*/ */
abstract public class CPPScope implements ICPPScope, IASTInternalScope { abstract public class CPPScope implements ICPPScope, IASTInternalScope {
private static final IProgressMonitor NPM = new NullProgressMonitor(); private static final IProgressMonitor NPM = new NullProgressMonitor();
private IASTNode physicalNode;
private boolean isfull = false;
protected CharArrayObjectMap bindings = null;
public static class CPPScopeProblem extends ProblemBinding implements ICPPScope { public static class CPPScopeProblem extends ProblemBinding implements ICPPScope {
public CPPScopeProblem( IASTNode node, int id, char[] arg ) { public CPPScopeProblem(IASTNode node, int id, char[] arg) {
super( node, id, arg ); super(node, id, arg);
} }
} }
private IASTNode physicalNode; public CPPScope(IASTNode physicalNode) {
public CPPScope( IASTNode physicalNode ) {
this.physicalNode = physicalNode; this.physicalNode = physicalNode;
} }
@ -67,46 +69,44 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
* @see org.eclipse.cdt.core.dom.ast.IScope#getParent() * @see org.eclipse.cdt.core.dom.ast.IScope#getParent()
*/ */
public IScope getParent() throws DOMException { public IScope getParent() throws DOMException {
return CPPVisitor.getContainingScope( physicalNode ); return CPPVisitor.getContainingScope(physicalNode);
} }
public IASTNode getPhysicalNode() { public IASTNode getPhysicalNode() {
return physicalNode; return physicalNode;
} }
protected CharArrayObjectMap bindings = null;
public void addName(IASTName name) throws DOMException { public void addName(IASTName name) throws DOMException {
if( bindings == null ) if (bindings == null)
bindings = new CharArrayObjectMap(1); bindings = new CharArrayObjectMap(1);
char[] c; char[] c;
if (name instanceof ICPPASTQualifiedName) { if (name instanceof ICPPASTQualifiedName) {
if (physicalNode instanceof ICPPASTCompositeTypeSpecifier == false && if (!(physicalNode instanceof ICPPASTCompositeTypeSpecifier) &&
physicalNode instanceof ICPPASTNamespaceDefinition == false) !(physicalNode instanceof ICPPASTNamespaceDefinition)) {
return; return;
}
//name belongs to a different scope, don't add it here except it names this scope //name belongs to a different scope, don't add it here except it names this scope
final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name; final ICPPASTQualifiedName qname = (ICPPASTQualifiedName) name;
final IASTName[] ns= qname.getNames(); final IASTName[] ns= qname.getNames();
if (!canDenoteScopeMember(qname)) if (!canDenoteScopeMember(qname))
return; return;
c= ns[ns.length-1].toCharArray(); c= ns[ns.length - 1].toCharArray();
} } else {
else {
c= name.toCharArray(); c= name.toCharArray();
} }
Object o = bindings.get( c ); Object o = bindings.get(c);
if( o != null ){ if (o != null) {
if( o instanceof ObjectSet ){ if (o instanceof ObjectSet) {
((ObjectSet)o).put( name ); ((ObjectSet)o).put(name);
} else { } else {
ObjectSet temp = new ObjectSet( 2 ); ObjectSet temp = new ObjectSet(2);
temp.put( o ); temp.put(o);
temp.put( name ); temp.put(name);
bindings.put( c, temp ); bindings.put(c, temp);
} }
} else { } else {
bindings.put( c, name ); bindings.put(c, name);
} }
} }
@ -114,7 +114,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
IScope scope= this; IScope scope= this;
IASTName[] na= name.getNames(); IASTName[] na= name.getNames();
try { try {
for (int i= na.length-2; i >= 0; i++) { for (int i= na.length - 2; i >= 0; i++) {
if (scope == null) if (scope == null)
return false; return false;
IASTName n= na[i]; IASTName n= na[i];
@ -141,32 +141,34 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
// Try looking this up in the PDOM // Try looking this up in the PDOM
if (physicalNode instanceof IASTTranslationUnit) { if (physicalNode instanceof IASTTranslationUnit) {
try { try {
IBinding[] bindings= index.findBindings(name.toCharArray(), IndexFilter.CPP_DECLARED_OR_IMPLICIT, NPM); IBinding[] bindings= index.findBindings(name.toCharArray(),
IndexFilter.CPP_DECLARED_OR_IMPLICIT, NPM);
if (fileSet != null) { if (fileSet != null) {
bindings= fileSet.filterFileLocalBindings(bindings); bindings= fileSet.filterFileLocalBindings(bindings);
} }
binding= CPPSemantics.resolveAmbiguities(name, bindings); binding= CPPSemantics.resolveAmbiguities(name, bindings);
if( binding instanceof ICPPUsingDeclaration ){ if (binding instanceof ICPPUsingDeclaration) {
binding= CPPSemantics.resolveAmbiguities( name, ((ICPPUsingDeclaration)binding).getDelegates() ); binding= CPPSemantics.resolveAmbiguities(name,
((ICPPUsingDeclaration)binding).getDelegates());
} }
} catch (CoreException e) { } catch (CoreException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
} }
} } else if (physicalNode instanceof ICPPASTNamespaceDefinition) {
else if (physicalNode instanceof ICPPASTNamespaceDefinition) {
ICPPASTNamespaceDefinition nsdef = (ICPPASTNamespaceDefinition)physicalNode; ICPPASTNamespaceDefinition nsdef = (ICPPASTNamespaceDefinition)physicalNode;
IASTName nsname = nsdef.getName(); IASTName nsname = nsdef.getName();
IBinding nsbinding= nsname.resolveBinding(); IBinding nsbinding= nsname.resolveBinding();
if(nsbinding instanceof ICPPNamespace) { if (nsbinding instanceof ICPPNamespace) {
ICPPNamespace nsbindingAdapted = (ICPPNamespace) index.adaptBinding(nsbinding); ICPPNamespace nsbindingAdapted = (ICPPNamespace) index.adaptBinding(nsbinding);
if(nsbindingAdapted!=null) { if (nsbindingAdapted!=null) {
IBinding[] bindings = nsbindingAdapted.getNamespaceScope().find(name.toString()); IBinding[] bindings = nsbindingAdapted.getNamespaceScope().find(name.toString());
if (fileSet != null) { if (fileSet != null) {
bindings= fileSet.filterFileLocalBindings(bindings); bindings= fileSet.filterFileLocalBindings(bindings);
} }
binding= CPPSemantics.resolveAmbiguities(name, bindings); binding= CPPSemantics.resolveAmbiguities(name, bindings);
if( binding instanceof ICPPUsingDeclaration ){ if (binding instanceof ICPPUsingDeclaration) {
binding= CPPSemantics.resolveAmbiguities( name, ((ICPPUsingDeclaration)binding).getDelegates() ); binding= CPPSemantics.resolveAmbiguities(name,
((ICPPUsingDeclaration)binding).getDelegates());
} }
} }
} }
@ -177,45 +179,46 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
} }
public IBinding getBindingInAST(IASTName name, boolean forceResolve) throws DOMException { public IBinding getBindingInAST(IASTName name, boolean forceResolve) throws DOMException {
char [] c = name.toCharArray(); char[] c = name.toCharArray();
//can't look up bindings that don't have a name //can't look up bindings that don't have a name
if( c.length == 0 ) if (c.length == 0)
return null; return null;
Object obj = bindings != null ? bindings.get( c ) : null; Object obj = bindings != null ? bindings.get(c) : null;
if( obj != null ){ if (obj != null) {
if( obj instanceof ObjectSet ) { if (obj instanceof ObjectSet) {
ObjectSet os = (ObjectSet) obj; ObjectSet os = (ObjectSet) obj;
if( forceResolve ) if (forceResolve)
return CPPSemantics.resolveAmbiguities( name, os.keyArray() ); return CPPSemantics.resolveAmbiguities(name, os.keyArray());
IBinding [] bs = null; IBinding[] bs = null;
for( int i = 0; i < os.size(); i++ ){ for (int i = 0; i < os.size(); i++) {
Object o = os.keyAt( i ); Object o = os.keyAt(i);
if( o instanceof IASTName ){ if (o instanceof IASTName) {
IASTName n = (IASTName) o; IASTName n = (IASTName) o;
if( n instanceof ICPPASTQualifiedName ){ if (n instanceof ICPPASTQualifiedName) {
IASTName [] ns = ((ICPPASTQualifiedName)n).getNames(); IASTName[] ns = ((ICPPASTQualifiedName)n).getNames();
n = ns[ ns.length - 1 ]; n = ns[ns.length - 1];
} }
bs = (IBinding[]) ArrayUtil.append( IBinding.class, bs, n.getBinding() ); bs = (IBinding[]) ArrayUtil.append(IBinding.class, bs, n.getBinding());
} else } else {
bs = (IBinding[]) ArrayUtil.append( IBinding.class, bs, o ); bs = (IBinding[]) ArrayUtil.append(IBinding.class, bs, o);
} }
return CPPSemantics.resolveAmbiguities( name, bs ); }
} else if( obj instanceof IASTName ){ return CPPSemantics.resolveAmbiguities(name, bs);
} else if (obj instanceof IASTName) {
IBinding binding = null; IBinding binding = null;
if( forceResolve && obj != name && obj != name.getParent()) if (forceResolve && obj != name && obj != name.getParent()) {
binding = CPPSemantics.resolveAmbiguities(name, new Object[] { obj }); binding = CPPSemantics.resolveAmbiguities(name, new Object[] { obj });
else { } else {
IASTName n = (IASTName) obj; IASTName n = (IASTName) obj;
if( n instanceof ICPPASTQualifiedName ){ if (n instanceof ICPPASTQualifiedName) {
IASTName [] ns = ((ICPPASTQualifiedName)n).getNames(); IASTName[] ns = ((ICPPASTQualifiedName)n).getNames();
n = ns[ ns.length - 1 ]; n = ns[ns.length - 1];
} }
binding = n.getBinding(); binding = n.getBinding();
} }
if( binding instanceof ICPPUsingDeclaration ){ if (binding instanceof ICPPUsingDeclaration) {
return CPPSemantics.resolveAmbiguities( name, ((ICPPUsingDeclaration)binding).getDelegates() ); return CPPSemantics.resolveAmbiguities(name, ((ICPPUsingDeclaration)binding).getDelegates());
} }
return binding; return binding;
} }
@ -224,7 +227,8 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
return null; return null;
} }
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet) throws DOMException { public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet)
throws DOMException {
IBinding[] result = getBindingsInAST(name, resolve, prefixLookup); IBinding[] result = getBindingsInAST(name, resolve, prefixLookup);
final IASTTranslationUnit tu = name.getTranslationUnit(); final IASTTranslationUnit tu = name.getTranslationUnit();
@ -264,8 +268,9 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
return (IBinding[]) ArrayUtil.trim(IBinding.class, result); return (IBinding[]) ArrayUtil.trim(IBinding.class, result);
} }
public IBinding[] getBindingsInAST(IASTName name, boolean forceResolve, boolean prefixLookup) throws DOMException { public IBinding[] getBindingsInAST(IASTName name, boolean forceResolve, boolean prefixLookup)
char [] c = name.toCharArray(); throws DOMException {
char[] c = name.toCharArray();
IBinding[] result = null; IBinding[] result = null;
Object[] obj = null; Object[] obj = null;
@ -278,40 +283,42 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
} }
} }
} else { } else {
obj = bindings != null ? new Object[] {bindings.get( c )} : null; obj = bindings != null ? new Object[] {bindings.get(c)} : null;
} }
obj = ArrayUtil.trim(Object.class, obj); obj = ArrayUtil.trim(Object.class, obj);
for (int i = 0; i < obj.length; i++) { for (int i = 0; i < obj.length; i++) {
if( obj[i] instanceof ObjectSet ) { if (obj[i] instanceof ObjectSet) {
ObjectSet os = (ObjectSet) obj[i]; ObjectSet os = (ObjectSet) obj[i];
for( int j = 0; j < os.size(); j++ ){ for (int j = 0; j < os.size(); j++) {
Object o = os.keyAt( j ); Object o = os.keyAt(j);
if( o instanceof IASTName ){ if (o instanceof IASTName) {
IASTName n = (IASTName) o; IASTName n = (IASTName) o;
if( n instanceof ICPPASTQualifiedName ){ if (n instanceof ICPPASTQualifiedName) {
IASTName [] ns = ((ICPPASTQualifiedName)n).getNames(); IASTName[] ns = ((ICPPASTQualifiedName)n).getNames();
n = ns[ ns.length - 1 ]; n = ns[ns.length - 1];
} }
IBinding binding = forceResolve ? n.resolveBinding() : n.getBinding(); IBinding binding = forceResolve ? n.resolveBinding() : n.getBinding();
result = (IBinding[]) ArrayUtil.append( IBinding.class, result, binding ); result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding);
} else } else {
result = (IBinding[]) ArrayUtil.append( IBinding.class, result, o ); result = (IBinding[]) ArrayUtil.append(IBinding.class, result, o);
} }
} else if( obj[i] instanceof IASTName ){ }
} else if (obj[i] instanceof IASTName) {
IBinding binding = null; IBinding binding = null;
if( forceResolve && obj[i] != name && obj[i] != name.getParent()) if (forceResolve && obj[i] != name && obj[i] != name.getParent()) {
binding = ((IASTName) obj[i]).resolveBinding(); binding = ((IASTName) obj[i]).resolveBinding();
else { } else {
IASTName n = (IASTName) obj[i]; IASTName n = (IASTName) obj[i];
if( n instanceof ICPPASTQualifiedName ){ if (n instanceof ICPPASTQualifiedName) {
IASTName [] ns = ((ICPPASTQualifiedName)n).getNames(); IASTName[] ns = ((ICPPASTQualifiedName)n).getNames();
n = ns[ ns.length - 1 ]; n = ns[ns.length - 1];
} }
binding = n.getBinding(); binding = n.getBinding();
} }
if( binding instanceof ICPPUsingDeclaration ){ if (binding instanceof ICPPUsingDeclaration) {
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, ((ICPPUsingDeclaration)binding).getDelegates()); result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result,
((ICPPUsingDeclaration)binding).getDelegates());
} }
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding); result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding);
} else { } else {
@ -321,12 +328,11 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
return (IBinding[]) ArrayUtil.trim(IBinding.class, result); return (IBinding[]) ArrayUtil.trim(IBinding.class, result);
} }
private boolean isfull = false; public void setFullyCached(boolean full) {
public void setFullyCached( boolean full ){
isfull = full; isfull = full;
} }
public boolean isFullyCached(){ public boolean isFullyCached() {
return isfull; return isfull;
} }
@ -334,31 +340,30 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding)
*/ */
public void removeBinding(IBinding binding) { public void removeBinding(IBinding binding) {
char [] key = binding.getNameCharArray(); char[] key = binding.getNameCharArray();
removeBinding( key, binding ); removeBinding(key, binding);
} }
protected void removeBinding( char [] key, IBinding binding ){ protected void removeBinding(char[] key, IBinding binding) {
if( bindings == null || ! bindings.containsKey( key ) ) if (bindings == null || ! bindings.containsKey(key))
return; return;
Object obj = bindings.get( key ); Object obj = bindings.get(key);
if( obj instanceof ObjectSet ){ if (obj instanceof ObjectSet) {
ObjectSet set = (ObjectSet) obj; ObjectSet set = (ObjectSet) obj;
for ( int i = set.size() - 1; i > 0; i-- ) { for (int i = set.size() - 1; i > 0; i--) {
Object o = set.keyAt( i ); Object o = set.keyAt(i);
if( (o instanceof IBinding && o == binding) || if ((o instanceof IBinding && o == binding) ||
(o instanceof IASTName && ((IASTName)o).getBinding() == binding) ) (o instanceof IASTName && ((IASTName)o).getBinding() == binding)) {
{ set.remove(o);
set.remove( o );
} }
} }
if( set.size() == 0 ) if (set.isEmpty()) {
bindings.remove( key, 0, key.length ); bindings.remove(key, 0, key.length);
} else if( (obj instanceof IBinding && obj == binding) || }
(obj instanceof IASTName && ((IASTName)obj).getBinding() == binding) ) } else if ((obj instanceof IBinding && obj == binding) ||
{ (obj instanceof IASTName && ((IASTName)obj).getBinding() == binding)) {
bindings.remove( key, 0, key.length ); bindings.remove(key, 0, key.length);
} }
isfull = false; isfull = false;
} }
@ -367,31 +372,31 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
* @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String)
*/ */
public IBinding[] find(String name) throws DOMException { public IBinding[] find(String name) throws DOMException {
return CPPSemantics.findBindings( this, name, false ); return CPPSemantics.findBindings(this, name, false);
} }
public void flushCache() { public void flushCache() {
isfull = false; isfull = false;
if( bindings != null ) if (bindings != null)
bindings.clear(); bindings.clear();
} }
public void addBinding(IBinding binding) { public void addBinding(IBinding binding) {
if( bindings == null ) if (bindings == null)
bindings = new CharArrayObjectMap(1); bindings = new CharArrayObjectMap(1);
char [] c = binding.getNameCharArray(); char[] c = binding.getNameCharArray();
Object o = bindings.get( c ); Object o = bindings.get(c);
if( o != null ){ if (o != null) {
if( o instanceof ObjectSet ){ if (o instanceof ObjectSet) {
((ObjectSet)o).put( binding ); ((ObjectSet)o).put(binding);
} else { } else {
ObjectSet set = new ObjectSet(2); ObjectSet set = new ObjectSet(2);
set.put( o ); set.put(o);
set.put( binding ); set.put(binding);
bindings.put( c, set ); bindings.put(c, set);
} }
} else { } else {
bindings.put( c, binding ); bindings.put(c, binding);
} }
} }
@ -402,4 +407,18 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) throws DOMException { public final IBinding[] getBindings(IASTName name, boolean resolve, boolean prefix) throws DOMException {
return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY); return getBindings(name, resolve, prefix, IIndexFileSet.EMPTY);
} }
public IName getScopeName() throws DOMException {
return null;
}
@Override
public String toString() {
IName name = null;
try {
name = getScopeName();
} catch (DOMException e) {
}
return name != null ? name.toString() : "<unnamed scope>"; //$NON-NLS-1$
}
} }

View file

@ -46,8 +46,8 @@ public abstract class CPPSpecialization extends PlatformObject
this.argumentMap = argumentMap; this.argumentMap = argumentMap;
if (specialized instanceof ICPPInternalBinding) { if (specialized instanceof ICPPInternalBinding) {
definition = ((ICPPInternalBinding)specialized).getDefinition(); definition = ((ICPPInternalBinding) specialized).getDefinition();
IASTNode[] decls = ((ICPPInternalBinding)specialized).getDeclarations(); IASTNode[] decls = ((ICPPInternalBinding) specialized).getDeclarations();
if (decls != null && decls.length > 0) if (decls != null && decls.length > 0)
declarations = new IASTNode[] { decls[0] }; declarations = new IASTNode[] { decls[0] };
} }
@ -125,4 +125,14 @@ public abstract class CPPSpecialization extends PlatformObject
public ObjectMap getArgumentMap() { public ObjectMap getArgumentMap() {
return argumentMap; return argumentMap;
} }
@Override
public String toString() {
StringBuilder result = new StringBuilder(getName());
if (argumentMap != null) {
result.append(" ");
result.append(argumentMap.toString());
}
return result.toString();
}
} }

View file

@ -57,158 +57,163 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
super(node, id, arg); super(node, id, arg);
} }
public ICPPTemplateParameter[] getTemplateParameters() throws DOMException { public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
throw new DOMException( this ); throw new DOMException(this);
} }
public ICPPClassTemplatePartialSpecialization[] getTemplateSpecializations() throws DOMException { public ICPPClassTemplatePartialSpecialization[] getTemplateSpecializations() throws DOMException {
throw new DOMException( this ); throw new DOMException(this);
} }
public String[] getQualifiedName() throws DOMException { public String[] getQualifiedName() throws DOMException {
throw new DOMException( this ); throw new DOMException(this);
} }
public char[][] getQualifiedNameCharArray() throws DOMException { public char[][] getQualifiedNameCharArray() throws DOMException {
throw new DOMException( this ); throw new DOMException(this);
} }
public boolean isGloballyQualified() throws DOMException { public boolean isGloballyQualified() throws DOMException {
throw new DOMException( this ); throw new DOMException(this);
} }
} }
//private IASTName templateName; //private IASTName templateName;
protected IASTName [] declarations = null; protected IASTName[] declarations;
protected IASTName definition = null; protected IASTName definition;
private ICPPTemplateParameter [] templateParameters = null; private ICPPTemplateParameter[] templateParameters;
private ObjectMap instances = null; private ObjectMap instances;
public CPPTemplateDefinition( IASTName name ) { public CPPTemplateDefinition(IASTName name) {
if( name != null ){ if (name != null) {
ASTNodeProperty prop = name.getPropertyInParent(); ASTNodeProperty prop = name.getPropertyInParent();
if( prop == ICPPASTQualifiedName.SEGMENT_NAME ){ if (prop == ICPPASTQualifiedName.SEGMENT_NAME) {
prop = name.getParent().getPropertyInParent(); prop = name.getParent().getPropertyInParent();
} }
if( prop == IASTCompositeTypeSpecifier.TYPE_NAME ){ if (prop == IASTCompositeTypeSpecifier.TYPE_NAME) {
definition = name; definition = name;
} else if( prop == IASTElaboratedTypeSpecifier.TYPE_NAME ) { } else if (prop == IASTElaboratedTypeSpecifier.TYPE_NAME) {
declarations = new IASTName [] { name }; declarations = new IASTName[] { name };
} else { } else {
IASTNode parent = name.getParent(); IASTNode parent = name.getParent();
while( !(parent instanceof IASTDeclaration) ) while (!(parent instanceof IASTDeclaration))
parent = parent.getParent(); parent = parent.getParent();
if( parent instanceof IASTFunctionDefinition ) if (parent instanceof IASTFunctionDefinition) {
definition = name; definition = name;
else } else {
declarations = new IASTName [] { name }; declarations = new IASTName[] { name };
}
} }
} }
} }
public abstract ICPPSpecialization deferredInstance( IType [] arguments ); public abstract ICPPSpecialization deferredInstance(IType[] arguments);
public IBinding instantiate(ICPPASTTemplateId templateId ) {//IASTNode[] arguments) { public IBinding instantiate(ICPPASTTemplateId templateId) {//IASTNode[] arguments) {
IASTNode [] args = templateId.getTemplateArguments(); IASTNode[] args = templateId.getTemplateArguments();
IType [] types = CPPTemplates.createTypeArray( args ); IType[] types = CPPTemplates.createTypeArray(args);
return instantiate( types ); return instantiate(types);
} }
public IBinding instantiate( IType [] arguments ){ public IBinding instantiate(IType[] arguments) {
ICPPTemplateDefinition template = null; ICPPTemplateDefinition template = null;
if( this instanceof ICPPClassTemplate ){ if (this instanceof ICPPClassTemplate) {
try { try {
template = CPPTemplates.matchTemplatePartialSpecialization( (ICPPClassTemplate) this, arguments ); template = CPPTemplates.matchTemplatePartialSpecialization((ICPPClassTemplate) this, arguments);
} catch (DOMException e) { } catch (DOMException e) {
return e.getProblem(); return e.getProblem();
} }
} }
if( template instanceof IProblemBinding ) if (template instanceof IProblemBinding) {
return template; return template;
if( template != null && template instanceof ICPPClassTemplatePartialSpecialization ){ }
return ((ICPPInternalTemplateInstantiator)template).instantiate( arguments ); if (template != null && template instanceof ICPPClassTemplatePartialSpecialization) {
return ((ICPPInternalTemplateInstantiator)template).instantiate(arguments);
} }
return CPPTemplates.instantiateTemplate( this, arguments, null ); return CPPTemplates.instantiateTemplate(this, arguments, null);
} }
public ICPPSpecialization getInstance( IType [] arguments ) { public ICPPSpecialization getInstance(IType[] arguments) {
if( instances == null ) if (instances == null)
return null; return null;
int found = -1; int found = -1;
for( int i = 0; i < instances.size(); i++ ){ for (int i = 0; i < instances.size(); i++) {
IType [] args = (IType[]) instances.keyAt( i ); IType[] args = (IType[]) instances.keyAt(i);
if( args.length == arguments.length ){ if (args.length == arguments.length) {
int j = 0; int j = 0;
for(; j < args.length; j++) { for (; j < args.length; j++) {
if( !( args[j].isSameType( arguments[j] ) ) ) if (!(args[j].isSameType(arguments[j])))
break; break;
} }
if( j == args.length ){ if (j == args.length) {
found = i; found = i;
break; break;
} }
} }
} }
if( found != -1 ){ if (found != -1) {
return (ICPPSpecialization) instances.getAt(found); return (ICPPSpecialization) instances.getAt(found);
} }
return null; return null;
} }
public void addSpecialization( IType [] types, ICPPSpecialization spec ){ public void addSpecialization(IType[] types, ICPPSpecialization spec) {
if( types == null ) if (types == null)
return; return;
for( int i = 0; i < types.length; i++ ) for (int i = 0; i < types.length; i++) {
if( types[i] == null ) if (types[i] == null)
return; return;
if( instances == null ) }
instances = new ObjectMap( 2 ); if (instances == null)
instances.put( types, spec ); instances = new ObjectMap(2);
instances.put(types, spec);
} }
public IBinding resolveTemplateParameter(ICPPASTTemplateParameter templateParameter) { public IBinding resolveTemplateParameter(ICPPASTTemplateParameter templateParameter) {
IASTName name = CPPTemplates.getTemplateParameterName( templateParameter ); IASTName name = CPPTemplates.getTemplateParameterName(templateParameter);
IBinding binding = name.getBinding(); IBinding binding = name.getBinding();
if( binding != null ) if (binding != null)
return binding; return binding;
ICPPASTTemplateDeclaration templateDecl = (ICPPASTTemplateDeclaration) templateParameter.getParent(); ICPPASTTemplateDeclaration templateDecl = (ICPPASTTemplateDeclaration) templateParameter.getParent();
ICPPASTTemplateParameter [] ps = templateDecl.getTemplateParameters(); ICPPASTTemplateParameter[] ps = templateDecl.getTemplateParameters();
int i = 0; int i = 0;
for( ; i < ps.length; i++ ){ for (; i < ps.length; i++) {
if( templateParameter == ps[i] ) if (templateParameter == ps[i])
break; break;
} }
if( definition != null || (declarations != null && declarations.length > 0 ) ){ if (definition != null || (declarations != null && declarations.length > 0)) {
IASTName templateName = ( definition != null ) ? definition : declarations[0]; IASTName templateName = (definition != null) ? definition : declarations[0];
ICPPASTTemplateDeclaration temp = CPPTemplates.getTemplateDeclaration( templateName ); ICPPASTTemplateDeclaration temp = CPPTemplates.getTemplateDeclaration(templateName);
ICPPASTTemplateParameter [] params = temp.getTemplateParameters(); ICPPASTTemplateParameter[] params = temp.getTemplateParameters();
if( params.length > i ) { if (params.length > i) {
IASTName paramName = CPPTemplates.getTemplateParameterName( params[i] ); IASTName paramName = CPPTemplates.getTemplateParameterName(params[i]);
if( paramName.getBinding() != null ){ if (paramName.getBinding() != null) {
binding = paramName.getBinding(); binding = paramName.getBinding();
name.setBinding( binding ); name.setBinding(binding);
if( binding instanceof ICPPInternalBinding ) if(binding instanceof ICPPInternalBinding)
((ICPPInternalBinding)binding).addDeclaration( name ); ((ICPPInternalBinding)binding).addDeclaration(name);
return binding; return binding;
} }
} }
} }
//create a new binding and set it for the corresponding parameter in all known decls //create a new binding and set it for the corresponding parameter in all known decls
if( templateParameter instanceof ICPPASTSimpleTypeTemplateParameter ) if (templateParameter instanceof ICPPASTSimpleTypeTemplateParameter) {
binding = new CPPTemplateTypeParameter( name ); binding = new CPPTemplateTypeParameter(name);
else if( templateParameter instanceof ICPPASTParameterDeclaration ) } else if (templateParameter instanceof ICPPASTParameterDeclaration) {
binding = new CPPTemplateNonTypeParameter( name ); binding = new CPPTemplateNonTypeParameter(name);
else } else {
binding = new CPPTemplateTemplateParameter( name ); binding = new CPPTemplateTemplateParameter(name);
}
int length = ( declarations != null ) ? declarations.length : 0; int length = (declarations != null) ? declarations.length : 0;
int j = ( definition != null ) ? -1 : 0; int j = (definition != null) ? -1 : 0;
for( ; j < length; j++ ){ for (; j < length; j++) {
ICPPASTTemplateDeclaration template = ( j == -1 ) ICPPASTTemplateDeclaration template = (j == -1)
? CPPTemplates.getTemplateDeclaration( definition ) ? CPPTemplates.getTemplateDeclaration(definition)
: CPPTemplates.getTemplateDeclaration( declarations[j] ); : CPPTemplates.getTemplateDeclaration(declarations[j]);
if( template == null ) if (template == null)
continue; continue;
ICPPASTTemplateParameter[] temp = template.getTemplateParameters(); ICPPASTTemplateParameter[] temp = template.getTemplateParameters();
@ -216,19 +221,20 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
continue; continue;
IASTName n = CPPTemplates.getTemplateParameterName(temp[i]); IASTName n = CPPTemplates.getTemplateParameterName(temp[i]);
if( n != null && n != name && n.getBinding() == null ) { if (n != null && n != name && n.getBinding() == null) {
n.setBinding( binding ); n.setBinding(binding);
if( binding instanceof ICPPInternalBinding ) if (binding instanceof ICPPInternalBinding)
((ICPPInternalBinding)binding).addDeclaration( n ); ((ICPPInternalBinding)binding).addDeclaration(n);
} }
} }
return binding; return binding;
} }
public IASTName getTemplateName(){ public IASTName getTemplateName() {
return definition != null ? definition : declarations[0]; return definition != null ? definition : declarations[0];
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName() * @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/ */
@ -247,21 +253,21 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
* @see org.eclipse.cdt.core.dom.ast.IBinding#getScope() * @see org.eclipse.cdt.core.dom.ast.IBinding#getScope()
*/ */
public IScope getScope() { public IScope getScope() {
return CPPVisitor.getContainingScope( getTemplateName() ); return CPPVisitor.getContainingScope(getTemplateName());
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName() * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName()
*/ */
public String[] getQualifiedName() { public String[] getQualifiedName() {
return CPPVisitor.getQualifiedName( this ); return CPPVisitor.getQualifiedName(this);
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray() * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray()
*/ */
public char[][] getQualifiedNameCharArray() { public char[][] getQualifiedNameCharArray() {
return CPPVisitor.getQualifiedNameCharArray( this ); return CPPVisitor.getQualifiedNameCharArray(this);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -275,27 +281,27 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition#getParameters() * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition#getParameters()
*/ */
public ICPPTemplateParameter[] getTemplateParameters() { public ICPPTemplateParameter[] getTemplateParameters() {
if( templateParameters == null ){ if (templateParameters == null) {
ICPPASTTemplateDeclaration template = CPPTemplates.getTemplateDeclaration( getTemplateName() ); ICPPASTTemplateDeclaration template = CPPTemplates.getTemplateDeclaration(getTemplateName());
if( template == null ) if (template == null)
return ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY; return ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY;
ICPPASTTemplateParameter [] params = template.getTemplateParameters(); ICPPASTTemplateParameter[] params = template.getTemplateParameters();
ICPPTemplateParameter p = null; ICPPTemplateParameter p = null;
ICPPTemplateParameter [] result = null; ICPPTemplateParameter[] result = null;
for (int i = 0; i < params.length; i++) { for (int i = 0; i < params.length; i++) {
if( params[i] instanceof ICPPASTSimpleTypeTemplateParameter ){ if (params[i] instanceof ICPPASTSimpleTypeTemplateParameter) {
p = (ICPPTemplateParameter) ((ICPPASTSimpleTypeTemplateParameter)params[i]).getName().resolveBinding(); p = (ICPPTemplateParameter) ((ICPPASTSimpleTypeTemplateParameter) params[i]).getName().resolveBinding();
} else if( params[i] instanceof ICPPASTParameterDeclaration ) { } else if (params[i] instanceof ICPPASTParameterDeclaration) {
p = (ICPPTemplateParameter) ((ICPPASTParameterDeclaration)params[i]).getDeclarator().getName().resolveBinding(); p = (ICPPTemplateParameter) ((ICPPASTParameterDeclaration) params[i]).getDeclarator().getName().resolveBinding();
} else if( params[i] instanceof ICPPASTTemplatedTypeTemplateParameter ){ } else if (params[i] instanceof ICPPASTTemplatedTypeTemplateParameter) {
p = (ICPPTemplateParameter) ((ICPPASTTemplatedTypeTemplateParameter)params[i]).getName().resolveBinding(); p = (ICPPTemplateParameter) ((ICPPASTTemplatedTypeTemplateParameter) params[i]).getName().resolveBinding();
} }
if( p != null ){ if (p != null) {
result = (ICPPTemplateParameter[]) ArrayUtil.append( ICPPTemplateParameter.class, result, p ); result = (ICPPTemplateParameter[]) ArrayUtil.append(ICPPTemplateParameter.class, result, p);
} }
} }
templateParameters = (ICPPTemplateParameter[]) ArrayUtil.trim( ICPPTemplateParameter.class, result ); templateParameters = (ICPPTemplateParameter[]) ArrayUtil.trim(ICPPTemplateParameter.class, result);
} }
return templateParameters; return templateParameters;
} }
@ -304,16 +310,16 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode) * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode)
*/ */
public void addDefinition(IASTNode node) { public void addDefinition(IASTNode node) {
if( node instanceof ICPPASTCompositeTypeSpecifier ){ if (node instanceof ICPPASTCompositeTypeSpecifier) {
node = ((ICPPASTCompositeTypeSpecifier)node).getName(); node = ((ICPPASTCompositeTypeSpecifier)node).getName();
if( node instanceof ICPPASTQualifiedName ){ if (node instanceof ICPPASTQualifiedName) {
IASTName [] ns = ((ICPPASTQualifiedName)node).getNames(); IASTName[] ns = ((ICPPASTQualifiedName)node).getNames();
node = ns[ ns.length - 1]; node = ns[ns.length - 1];
} }
} }
if( !(node instanceof IASTName) ) if (!(node instanceof IASTName))
return; return;
updateTemplateParameterBindings( (IASTName) node ); updateTemplateParameterBindings((IASTName) node);
definition = (IASTName) node; definition = (IASTName) node;
} }
@ -321,49 +327,49 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode) * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode)
*/ */
public void addDeclaration(IASTNode node) { public void addDeclaration(IASTNode node) {
if( node instanceof ICPPASTElaboratedTypeSpecifier ){ if (node instanceof ICPPASTElaboratedTypeSpecifier) {
node = ((ICPPASTElaboratedTypeSpecifier)node).getName(); node = ((ICPPASTElaboratedTypeSpecifier)node).getName();
if( node instanceof ICPPASTQualifiedName ){ if (node instanceof ICPPASTQualifiedName) {
IASTName [] ns = ((ICPPASTQualifiedName)node).getNames(); IASTName[] ns = ((ICPPASTQualifiedName)node).getNames();
node = ns[ ns.length - 1]; node = ns[ns.length - 1];
} }
} }
if( !(node instanceof IASTName) ) if (!(node instanceof IASTName))
return; return;
IASTName declName = (IASTName) node; IASTName declName = (IASTName) node;
updateTemplateParameterBindings( declName ); updateTemplateParameterBindings(declName);
if( declarations == null ) if (declarations == null) {
declarations = new IASTName[] { declName }; declarations = new IASTName[] { declName };
else {
//keep the lowest offset declaration in [0]
if( declarations.length > 0 && ((ASTNode)node).getOffset() < ((ASTNode)declarations[0]).getOffset() ){
declarations = (IASTName[]) ArrayUtil.prepend( IASTName.class, declarations, declName );
} else { } else {
declarations = (IASTName[]) ArrayUtil.append( IASTName.class, declarations, declName ); // keep the lowest offset declaration in[0]
if (declarations.length > 0 && ((ASTNode) node).getOffset() < ((ASTNode) declarations[0]).getOffset()) {
declarations = (IASTName[]) ArrayUtil.prepend(IASTName.class, declarations, declName);
} else {
declarations = (IASTName[]) ArrayUtil.append(IASTName.class, declarations, declName);
} }
} }
} }
public void removeDeclaration(IASTNode node) { public void removeDeclaration(IASTNode node) {
if( definition == node ){ if (definition == node) {
definition = null; definition = null;
return; return;
} }
ArrayUtil.remove(declarations, node); ArrayUtil.remove(declarations, node);
} }
protected void updateTemplateParameterBindings( IASTName name ){ protected void updateTemplateParameterBindings(IASTName name) {
IASTName orig = definition != null ? definition : declarations[0]; IASTName orig = definition != null ? definition : declarations[0];
ICPPASTTemplateDeclaration origTemplate = CPPTemplates.getTemplateDeclaration( orig ); ICPPASTTemplateDeclaration origTemplate = CPPTemplates.getTemplateDeclaration(orig);
ICPPASTTemplateDeclaration newTemplate = CPPTemplates.getTemplateDeclaration( name ); ICPPASTTemplateDeclaration newTemplate = CPPTemplates.getTemplateDeclaration(name);
ICPPASTTemplateParameter [] ops = origTemplate.getTemplateParameters(); ICPPASTTemplateParameter[] ops = origTemplate.getTemplateParameters();
ICPPASTTemplateParameter [] nps = newTemplate.getTemplateParameters(); ICPPASTTemplateParameter[] nps = newTemplate.getTemplateParameters();
ICPPInternalBinding temp = null; ICPPInternalBinding temp = null;
for( int i = 0; i < nps.length; i++ ){ for (int i = 0; i < nps.length; i++) {
temp = (ICPPInternalBinding) CPPTemplates.getTemplateParameterName( ops[i] ).getBinding(); temp = (ICPPInternalBinding) CPPTemplates.getTemplateParameterName(ops[i]).getBinding();
if( temp != null ){ if (temp != null) {
IASTName n = CPPTemplates.getTemplateParameterName( nps[i] ); IASTName n = CPPTemplates.getTemplateParameterName(nps[i]);
n.setBinding( temp ); n.setBinding(temp);
temp.addDeclaration( n ); temp.addDeclaration(n);
} }
} }
} }

View file

@ -46,11 +46,11 @@ public class CPPTemplateScope extends CPPScope implements ICPPTemplateScope {
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope#getTemplateDefinition() * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope#getTemplateDefinition()
*/ */
public ICPPTemplateDefinition getTemplateDefinition() { public ICPPTemplateDefinition getTemplateDefinition() {
// if( primaryDefinition == null ){ // if (primaryDefinition == null) {
// //primaryDefinition = CPPTemplates.getTemplateDefinition( this ); // //primaryDefinition = CPPTemplates.getTemplateDefinition(this);
// ICPPASTTemplateDeclaration template = (ICPPASTTemplateDeclaration) getPhysicalNode(); // ICPPASTTemplateDeclaration template = (ICPPASTTemplateDeclaration) getPhysicalNode();
// IASTDeclaration decl = template.getDeclaration(); // IASTDeclaration decl = template.getDeclaration();
// return new CPPTemplateDefinition( decl ); // return new CPPTemplateDefinition(decl);
// } // }
// return primaryDefinition; // return primaryDefinition;
return null; return null;
@ -66,42 +66,45 @@ public class CPPTemplateScope extends CPPScope implements ICPPTemplateScope {
public IScope getParent() { public IScope getParent() {
ICPPASTTemplateDeclaration templateDecl = (ICPPASTTemplateDeclaration) getPhysicalNode(); ICPPASTTemplateDeclaration templateDecl = (ICPPASTTemplateDeclaration) getPhysicalNode();
IASTName name = CPPTemplates.getTemplateName( templateDecl ); IASTName name = CPPTemplates.getTemplateName(templateDecl);
IASTNode p = name != null ? name.getParent() : null; IASTNode p = name != null ? name.getParent() : null;
if( p instanceof ICPPASTQualifiedName ){ if (p instanceof ICPPASTQualifiedName) {
ICPPASTQualifiedName qual = (ICPPASTQualifiedName) p; ICPPASTQualifiedName qual = (ICPPASTQualifiedName) p;
IASTName [] names = qual.getNames(); IASTName[] names = qual.getNames();
int i = 0; int i = 0;
for( ; i < names.length; i++ ){ for (; i < names.length; i++) {
if( names[i] == name ) break; if (names[i] == name)
break;
} }
if( i > 0 ){ if (i > 0) {
try { try {
IBinding binding = names[i - 1].resolveBinding(); IBinding binding = names[i - 1].resolveBinding();
if( binding instanceof ICPPClassType ){ if (binding instanceof ICPPClassType) {
return ((ICPPClassType)binding).getCompositeScope(); return ((ICPPClassType) binding).getCompositeScope();
} else if( binding instanceof ICPPNamespace ){ } else if (binding instanceof ICPPNamespace) {
return ((ICPPNamespace)binding).getNamespaceScope(); return ((ICPPNamespace) binding).getNamespaceScope();
} else if( binding instanceof ICPPInternalUnknown ){ } else if (binding instanceof ICPPInternalUnknown) {
return ((ICPPInternalUnknown)binding).getUnknownScope(); return ((ICPPInternalUnknown) binding).getUnknownScope();
} else if( binding instanceof IProblemBinding ){ } else if (binding instanceof IProblemBinding) {
if( binding instanceof ICPPScope ) if (binding instanceof ICPPScope)
return (IScope) binding; return (IScope) binding;
return new CPPScope.CPPScopeProblem( names[i-1], IProblemBinding.SEMANTIC_BAD_SCOPE, names[i-1].toCharArray() ); return new CPPScope.CPPScopeProblem(names[i - 1], IProblemBinding.SEMANTIC_BAD_SCOPE,
names[i - 1].toCharArray());
} }
} catch( DOMException e ){ } catch (DOMException e) {
IScope result= e.getProblem(); IScope result = e.getProblem();
if (result instanceof ICPPScope) { if (result instanceof ICPPScope) {
return result; return result;
} }
return new CPPScope.CPPScopeProblem( names[i-1], IProblemBinding.SEMANTIC_BAD_SCOPE, names[i-1].toCharArray() ); return new CPPScope.CPPScopeProblem(names[i - 1], IProblemBinding.SEMANTIC_BAD_SCOPE,
names[i - 1].toCharArray());
} }
} else if( qual.isFullyQualified() ){ } else if (qual.isFullyQualified()) {
return qual.getTranslationUnit().getScope(); return qual.getTranslationUnit().getScope();
} }
} }
while( templateDecl.getParent() instanceof ICPPASTTemplateDeclaration ) while (templateDecl.getParent() instanceof ICPPASTTemplateDeclaration)
templateDecl = (ICPPASTTemplateDeclaration) templateDecl.getParent(); templateDecl = (ICPPASTTemplateDeclaration) templateDecl.getParent();
return CPPVisitor.getContainingScope( templateDecl ); return CPPVisitor.getContainingScope(templateDecl);
} }
} }

View file

@ -21,29 +21,28 @@ import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
/** /**
* @author aniefer * @author aniefer
*/ */
public class CPPTypedefSpecialization extends CPPSpecialization implements public class CPPTypedefSpecialization extends CPPSpecialization implements ITypedef, ITypeContainer {
ITypedef, ITypeContainer {
private IType type = null; private IType type = null;
/** /**
* @param specialized * @param specialized
* @param scope * @param scope
* @param argumentMap * @param argumentMap
*/ */
public CPPTypedefSpecialization( IBinding specialized, ICPPScope scope, public CPPTypedefSpecialization(IBinding specialized, ICPPScope scope, ObjectMap argumentMap) {
ObjectMap argumentMap ) { super(specialized, scope, argumentMap);
super( specialized, scope, argumentMap );
} }
private ITypedef getTypedef() { private ITypedef getTypedef() {
return (ITypedef) getSpecializedBinding(); return (ITypedef) getSpecializedBinding();
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.ITypedef#getType() * @see org.eclipse.cdt.core.dom.ast.ITypedef#getType()
*/ */
public IType getType() throws DOMException { public IType getType() throws DOMException {
if( type == null ){ if (type == null) {
type = CPPTemplates.instantiateType( getTypedef().getType(), argumentMap ); type = CPPTemplates.instantiateType(getTypedef().getType(), argumentMap);
} }
return type; return type;
} }
@ -56,8 +55,8 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements
IType t = null; IType t = null;
try { try {
t = (IType) super.clone(); t = (IType) super.clone();
} catch ( CloneNotSupportedException e ) { } catch (CloneNotSupportedException e) {
//not going to happen // not going to happen
} }
return t; return t;
} }
@ -65,24 +64,25 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType) * @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/ */
public boolean isSameType( IType o ) { public boolean isSameType(IType o) {
if( o == this ) if (o == this)
return true; return true;
if( o instanceof ITypedef ) if (o instanceof ITypedef) {
try { try {
IType t = getType(); IType t = getType();
if( t != null ) if (t != null)
return t.isSameType( ((ITypedef)o).getType()); return t.isSameType(((ITypedef) o).getType());
return false; return false;
} catch ( DOMException e ) { } catch (DOMException e) {
return false; return false;
} }
}
try { try {
IType t = getType(); IType t = getType();
if( t != null ) if (t != null)
return t.isSameType( o ); return t.isSameType(o);
} catch ( DOMException e ) { } catch (DOMException e) {
return false; return false;
} }
return false; return false;
@ -91,5 +91,4 @@ public class CPPTypedefSpecialization extends CPPSpecialization implements
public void setType(IType type) { public void setType(IType type) {
this.type = type; this.type = type;
} }
} }

View file

@ -44,8 +44,7 @@ public class TemplateInstanceUtil {
if(specd instanceof ICPPTemplateDefinition) { if(specd instanceof ICPPTemplateDefinition) {
keysToAdapt= ((ICPPTemplateDefinition)specd).getTemplateParameters(); keysToAdapt= ((ICPPTemplateDefinition)specd).getTemplateParameters();
} }
final int length= Math.min(keys.length, keysToAdapt.length); for(int i = 0; i < keys.length && i < keysToAdapt.length; i++) {
for(int i=0; i<length; i++) {
IType type= (IType) preresult.get(keys[i]); IType type= (IType) preresult.get(keys[i]);
result.put( result.put(
cf.getCompositeBinding((IIndexFragmentBinding)keysToAdapt[i]), cf.getCompositeBinding((IIndexFragmentBinding)keysToAdapt[i]),