### Eclipse Workspace Patch 1.0 #P org.eclipse.cdt.ui Index: src/org/eclipse/cdt/internal/ui/IndexLabelProvider.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/IndexLabelProvider.java,v retrieving revision 1.7 diff -u -r1.7 IndexLabelProvider.java --- src/org/eclipse/cdt/internal/ui/IndexLabelProvider.java 19 Mar 2007 21:05:46 -0000 1.7 +++ src/org/eclipse/cdt/internal/ui/IndexLabelProvider.java 23 Mar 2007 15:31:13 -0000 @@ -10,6 +10,7 @@ * Markus Schorn (Wind River Systems) * IBM Corporation * Andrew Ferguson (Symbian) + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.internal.ui; @@ -33,8 +34,10 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.model.ICContainer; import org.eclipse.cdt.core.model.ICProject; @@ -98,6 +101,8 @@ PDOMNode parent = ((PDOMNode)element).getParentNode(); PDOMNode grandParent = parent != null ? parent.getParentNode() : null; boolean showArgs = parentOfSpec == null || grandParent == null || !parentOfSpec.equals(grandParent); + showArgs = showArgs && ((element instanceof ICPPClassType || element instanceof ICPPFunction) + && !(element instanceof ICPPTemplateDefinition)); StringBuffer buffer = null; buffer = new StringBuffer("Spec: "); //$NON-NLS-1$ #P org.eclipse.cdt.core Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java,v retrieving revision 1.6 diff -u -r1.6 CPPClassSpecialization.java --- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java 12 Oct 2006 13:23:41 -0000 1.6 +++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecialization.java 23 Mar 2007 15:31:13 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2007 IBM Corporation 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 @@ -7,7 +7,7 @@ * * Contributors: * IBM - Initial API and implementation - * / + * Bryan Wilkinson (QNX) *******************************************************************************/ /* * Created on Apr 29, 2005 @@ -15,22 +15,32 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp; import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IASTDeclaration; +import org.eclipse.cdt.core.dom.ast.IASTDeclarator; +import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IField; +import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; +import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ObjectMap; +import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; /** * @author aniefer @@ -39,6 +49,8 @@ public class CPPClassSpecialization extends CPPSpecialization implements ICPPClassType, ICPPInternalClassType { + private IScope specScope; + /** * @param specialized * @param scope @@ -47,24 +59,44 @@ super(specialized, scope, argumentMap); } + private ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier(){ + IASTNode definition = getDefinition(); + if( definition != null ){ + IASTNode node = definition; + while( node instanceof IASTName ) + node = node.getParent(); + if( node instanceof ICPPASTCompositeTypeSpecifier ) + return (ICPPASTCompositeTypeSpecifier)node; + } + return null; + } + /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases() */ public ICPPBase[] getBases() throws DOMException { - ICPPClassType cls = (ICPPClassType) getSpecializedBinding(); - if( cls != null ){ - ICPPBase [] bases = cls.getBases(); - for (int i = 0; i < bases.length; i++) { - IBinding T = bases[i].getBaseClass(); - if( T instanceof ICPPTemplateTypeParameter && argumentMap.containsKey( T ) ){ - IType t = (IType) argumentMap.get( T ); - if( t instanceof ICPPClassType ) - ((CPPBaseClause)bases[i]).setBaseClass( (ICPPClassType) argumentMap.get(T) ); + if( getDefinition() == null ){ + IASTNode node = (getDeclarations() != null && getDeclarations().length > 0) ? getDeclarations()[0] : null; + return new ICPPBase [] { new CPPBaseClause.CPPBaseProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) }; + } + + ICPPASTBaseSpecifier[] bases = getCompositeTypeSpecifier().getBaseSpecifiers(); + if (bases.length == 0) + return ICPPBase.EMPTY_BASE_ARRAY; + + ICPPBase[] bindings = new ICPPBase[bases.length]; + for (int i = 0; i < bases.length; i++) { + bindings[i] = new CPPBaseClause(bases[i]); + IBinding base = bindings[i].getBaseClass(); + if (base instanceof IType) { + IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap); + if (specBase instanceof ICPPClassType) { + ((CPPBaseClause) bindings[i]).setBaseClass((ICPPClassType) specBase); } } - return bases; } - return ICPPBase.EMPTY_BASE_ARRAY; + return bindings; + } /* (non-Javadoc) @@ -119,8 +151,38 @@ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getConstructors() */ public ICPPConstructor[] getConstructors() throws DOMException { - // TODO Auto-generated method stub - return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY; + if( getDefinition() == null ){ + IASTNode node = (getDeclarations() != null && getDeclarations().length > 0) ? getDeclarations()[0] : null; + return new ICPPConstructor [] { new CPPConstructor.CPPConstructorProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) }; + } + + IScope scope = getCompositeScope(); + if (scope instanceof CPPClassSpecializationScope) { + if (ASTInternal.isFullyCached(scope)) + return ((CPPClassSpecializationScope)scope).getConstructors(); + } + + if( ASTInternal.isFullyCached(scope)) + return ((CPPClassScope)scope).getConstructors( true ); + + IASTDeclaration [] members = getCompositeTypeSpecifier().getMembers(); + for( int i = 0; i < members.length; i++ ){ + IASTDeclaration decl = members[i]; + if( decl instanceof ICPPASTTemplateDeclaration ) + decl = ((ICPPASTTemplateDeclaration)decl).getDeclaration(); + if( decl instanceof IASTSimpleDeclaration ){ + IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decl).getDeclarators(); + for( int j = 0; j < dtors.length; j++ ){ + if( dtors[j] == null ) break; + ASTInternal.addName(scope, dtors[j].getName() ); + } + } else if( decl instanceof IASTFunctionDefinition ){ + IASTDeclarator dtor = ((IASTFunctionDefinition)decl).getDeclarator(); + ASTInternal.addName(scope, dtor.getName() ); + } + } + + return ((CPPClassScope)scope).getConstructors( true ); } /* (non-Javadoc) @@ -135,6 +197,9 @@ * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey() */ public int getKey() throws DOMException { + if (getDefinition() != null) + return getCompositeTypeSpecifier().getKey(); + return ((ICPPClassType)getSpecializedBinding()).getKey(); } @@ -142,15 +207,21 @@ * @see org.eclipse.cdt.core.dom.ast.ICompositeType#getCompositeScope() */ public IScope getCompositeScope() throws DOMException { - IASTNode definition = getDefinition(); - if( definition != null ){ - IASTNode node = definition.getParent(); - while( node instanceof IASTName ) - node = node.getParent(); - if( node instanceof ICPPASTCompositeTypeSpecifier ) - return ((ICPPASTCompositeTypeSpecifier)node).getScope(); + if (specScope == null) { + ICPPClassScope scope = null; + if( getDefinition() != null ){ + scope = (ICPPClassScope) getCompositeTypeSpecifier().getScope(); + } + + if (scope != null && scope.getClassType() == this) { + //explicit specialization: can use composite type specifier scope + specScope = scope; + } else if (scope != null) { + //implicit specialization: must specialize bindings in scope + specScope = new CPPClassSpecializationScope(this); + } } - return ((ICPPClassType)getSpecializedBinding()).getCompositeScope(); + return specScope; } /* (non-Javadoc) @@ -164,8 +235,7 @@ * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#createDelegate(org.eclipse.cdt.core.dom.ast.IASTName) */ public ICPPDelegate createDelegate(IASTName name) { - // TODO Auto-generated method stub - return null; + return new CPPClassType.CPPClassTypeDelegate( name, this ); } public Object clone() { @@ -174,8 +244,64 @@ } public ICPPMethod[] getConversionOperators() { - // TODO Auto-generated method stub - return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; + if( getDefinition() == null ){ + IASTNode node = (getDeclarations() != null && getDeclarations().length > 0) ? getDeclarations()[0] : null; + return new ICPPMethod[] { new CPPMethod.CPPMethodProblem( node, IProblemBinding.SEMANTIC_DEFINITION_NOT_FOUND, getNameCharArray() ) }; + } + try { + ICPPMethod [] result = null; + + IScope scope = getCompositeScope(); + if (scope instanceof CPPClassSpecializationScope) { + if (ASTInternal.isFullyCached(scope)) + result = ((CPPClassSpecializationScope)scope).getConversionOperators(); + } else { + IBinding binding = null; + + IASTDeclaration [] decls = getCompositeTypeSpecifier().getMembers(); + IASTName name = null; + for ( int i = 0; i < decls.length; i++ ) { + if( decls[i] instanceof IASTSimpleDeclaration ){ + IASTDeclarator [] dtors = ((IASTSimpleDeclaration)decls[i]).getDeclarators(); + for ( int j = 0; j < dtors.length; j++ ) { + name = CPPVisitor.getMostNestedDeclarator( dtors[j] ).getName(); + if( name instanceof ICPPASTConversionName ){ + binding = name.resolveBinding(); + if( binding instanceof ICPPMethod) + result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding ); + } + } + } else if( decls[i] instanceof IASTFunctionDefinition ){ + IASTDeclarator dtor = ((IASTFunctionDefinition)decls[i]).getDeclarator(); + name = CPPVisitor.getMostNestedDeclarator( dtor ).getName(); + if( name instanceof ICPPASTConversionName ){ + binding = name.resolveBinding(); + if( binding instanceof ICPPMethod ){ + result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding ); + } + } + } + } + } + + ICPPBase [] bases = getBases(); + for ( int i = 0; i < bases.length; i++ ) { + ICPPClassType cls = null; + try { + IBinding b = bases[i].getBaseClass(); + if( b instanceof ICPPClassType ) + cls = (ICPPClassType) b; + } catch (DOMException e) { + continue; + } + if( cls instanceof ICPPInternalClassType ) + result = (ICPPMethod[]) ArrayUtil.addAll( ICPPMethod.class, result, ((ICPPInternalClassType)cls).getConversionOperators() ); + } + + return (ICPPMethod[]) ArrayUtil.trim( ICPPMethod.class, result ); + } catch (DOMException e) { + return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; + } } public ICPPClassType[] getNestedClasses() throws DOMException { Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBaseClause.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBaseClause.java,v retrieving revision 1.10 diff -u -r1.10 CPPBaseClause.java --- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBaseClause.java 29 Jan 2007 11:51:43 -0000 1.10 +++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPBaseClause.java 23 Mar 2007 15:31:13 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2005 IBM Corporation and others. + * Copyright (c) 2004, 2007 IBM Corporation 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 @@ -16,7 +16,7 @@ import org.eclipse.cdt.core.dom.IName; import org.eclipse.cdt.core.dom.ast.DOMException; -import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IProblemBinding; import org.eclipse.cdt.core.dom.ast.ITypedef; @@ -33,7 +33,7 @@ public class CPPBaseClause implements ICPPBase { static public class CPPBaseProblem extends ProblemBinding implements ICPPBase { private ICPPClassType classProblem = null; - public CPPBaseProblem( IASTName node, int id, char[] arg ) { + public CPPBaseProblem( IASTNode node, int id, char[] arg ) { super( node, id, arg ); } public IBinding getBaseClass() { Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java,v retrieving revision 1.13 diff -u -r1.13 CPPClassInstance.java --- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java 19 Mar 2007 21:05:44 -0000 1.13 +++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstance.java 23 Mar 2007 15:31:13 -0000 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2007 IBM Corporation 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 @@ -7,6 +7,7 @@ * * Contributors: * IBM - Initial API and implementation + * Bryan Wilkinson (QNX) *******************************************************************************/ /* * Created on Mar 28, 2005 @@ -29,14 +30,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; import org.eclipse.cdt.core.parser.util.ObjectMap; /** * @author aniefer */ public class CPPClassInstance extends CPPInstance implements ICPPClassType, ICPPInternalBinding { - private CPPClassInstanceScope instanceScope; + private CPPClassSpecializationScope instanceScope; /** * @param decl @@ -53,16 +53,15 @@ public ICPPBase[] getBases() throws DOMException { ICPPClassType cls = (ICPPClassType) getSpecializedBinding(); if( cls != null ){ - ICPPBase [] bases = cls.getBases(); - for (int i = 0; i < bases.length; i++) { - IBinding T = bases[i].getBaseClass(); - if( T instanceof ICPPTemplateTypeParameter && argumentMap.containsKey( T ) ){ - IType t = (IType) argumentMap.get( T ); - if( t instanceof ICPPClassType ) - ((CPPBaseClause)bases[i]).setBaseClass( (ICPPClassType) argumentMap.get(T) ); - } + ICPPBase [] bindings = cls.getBases(); + for (int i = 0; i < bindings.length; i++) { + IBinding base = bindings[i].getBaseClass(); + if (base instanceof IType) { + IType specBase = CPPTemplates.instantiateType((IType) base, argumentMap); + ((CPPBaseClause)bindings[i]).setBaseClass((ICPPClassType)specBase); + } } - return bases; + return bindings; } return ICPPBase.EMPTY_BASE_ARRAY; } @@ -119,7 +118,7 @@ * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getConstructors() */ public ICPPConstructor[] getConstructors() throws DOMException { - CPPClassInstanceScope scope = (CPPClassInstanceScope) getCompositeScope(); + CPPClassSpecializationScope scope = (CPPClassSpecializationScope) getCompositeScope(); if( scope.isFullyCached() ) return scope.getConstructors(); return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY; @@ -145,7 +144,7 @@ */ public IScope getCompositeScope() { if( instanceScope == null ){ - instanceScope = new CPPClassInstanceScope( this ); + instanceScope = new CPPClassSpecializationScope( this ); } return instanceScope; } Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java,v retrieving revision 1.6 diff -u -r1.6 CPPClassTemplateSpecialization.java --- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java 19 Mar 2007 21:05:44 -0000 1.6 +++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java 23 Mar 2007 15:31:13 -0000 @@ -7,7 +7,7 @@ * * Contributors: * IBM - Initial API and implementation - * / + * Bryan Wilkinson (QNX) *******************************************************************************/ /* * Created on May 2, 2005 @@ -24,7 +24,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; -import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ObjectMap; /** @@ -35,7 +34,6 @@ implements ICPPClassTemplate, ICPPInternalClassTemplate { private ObjectMap instances = null; - private ICPPClassTemplatePartialSpecialization [] partialSpecializations = null; /** * @param specialized @@ -50,12 +48,10 @@ /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate#getPartialSpecializations() */ - public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() { - partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.trim( ICPPClassTemplatePartialSpecialization.class, partialSpecializations ); - return partialSpecializations; + public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException { + return ((ICPPClassTemplate) getSpecializedBinding()).getPartialSpecializations(); } - /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition#getTemplateParameters() */ @@ -119,6 +115,6 @@ } public void addPartialSpecialization( ICPPClassTemplatePartialSpecialization spec ){ - partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.append( ICPPClassTemplatePartialSpecialization.class, partialSpecializations, spec ); + //should not occur } } Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstanceScope.java =================================================================== RCS file: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstanceScope.java diff -N parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstanceScope.java --- parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassInstanceScope.java 29 Jan 2007 10:27:46 -0000 1.17 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,331 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation 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: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Bryan Wilkinson (QNX) - *******************************************************************************/ -/* - * Created on Mar 28, 2005 - */ -package org.eclipse.cdt.internal.core.dom.parser.cpp; - -import org.eclipse.cdt.core.dom.IName; -import org.eclipse.cdt.core.dom.ast.DOMException; -import org.eclipse.cdt.core.dom.ast.IASTDeclarator; -import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.dom.ast.IScope; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; -import org.eclipse.cdt.core.parser.util.ArrayUtil; -import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; -import org.eclipse.cdt.core.parser.util.CharArrayUtils; -import org.eclipse.cdt.core.parser.util.ObjectMap; -import org.eclipse.cdt.core.parser.util.ObjectSet; -import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; -import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope; - -/** - * @author aniefer - */ -public class CPPClassInstanceScope implements ICPPClassScope, IASTInternalScope { - private static final char[] CONSTRUCTOR_KEY = "!!!CTOR!!!".toCharArray(); //$NON-NLS-1$ - - private CharArrayObjectMap bindings; - private ObjectMap instanceMap = ObjectMap.EMPTY_MAP; - - private ICPPTemplateInstance instance; - private boolean isFullyCached = false; - private boolean doneConstructors = false; - - /** - * @param instance - */ - public CPPClassInstanceScope(CPPClassInstance instance ) { - this.instance = instance; - } - - private ICPPClassType getOriginalClass(){ - return (ICPPClassType) instance.getTemplateDefinition(); - } - public boolean isFullyCached(){ - if( !isFullyCached ){ - CPPSemantics.LookupData data = new CPPSemantics.LookupData(); - try { - CPPSemantics.lookupInScope( data, this, null ); - } catch (DOMException e) { - } - } - return true; - } - - public IBinding getBinding( IASTName name, boolean forceResolve ) { - char [] c = name.toCharArray(); - if( bindings == null ) - return null; - - if( CharArrayUtils.equals( c, instance.getNameCharArray() ) && CPPClassScope.isConstructorReference( name ) ){ - c = CONSTRUCTOR_KEY; - } - - Object cache = bindings.get( c ); - if( cache != null ){ - int i = ( cache instanceof ObjectSet ) ? 0 : -1; - ObjectSet set = ( cache instanceof ObjectSet ) ? (ObjectSet) cache : null; - Object obj = ( set != null ) ? set.keyAt( i ) : cache; - IBinding [] bs = null; - IBinding binding = null; - while( obj != null ){ - if( obj instanceof IASTName ){ - IASTName n = (IASTName) obj; - if( n instanceof ICPPASTQualifiedName ){ - IASTName [] ns = ((ICPPASTQualifiedName)n).getNames(); - n = ns[ ns.length - 1 ]; - } - if( instanceMap.containsKey( n ) ){ - binding = (IBinding) instanceMap.get( n ); - } else { - binding = CPPClassScope.shouldResolve(forceResolve, n, name) ? n.resolveBinding() : n.getBinding(); - if (binding instanceof ICPPClassTemplatePartialSpecialization ){ - binding = null; - } - if( binding != null ){ - binding = CPPTemplates.createSpecialization( this, binding, instance.getArgumentMap() ); - if( instanceMap == ObjectMap.EMPTY_MAP ) - instanceMap = new ObjectMap(2); - instanceMap.put( n, binding ); - } - } - } else if( obj instanceof IBinding ){ - if( instanceMap.containsKey( obj ) ){ - binding = (IBinding) instanceMap.get( obj ); - } else { - binding = CPPTemplates.createSpecialization( this, (IBinding) obj, instance.getArgumentMap() ); - if( instanceMap == ObjectMap.EMPTY_MAP ) - instanceMap = new ObjectMap(2); - instanceMap.put( obj, binding ); - } - } - if( binding != null ){ - if( i == -1 ) - return binding; - bs = (IBinding[]) ArrayUtil.append( IBinding.class, bs, binding ); - binding = null; - } - if( i != -1 && ++i < set.size() ){ - obj = set.keyAt( i ); - } else { - obj = null; - } - } - bs = (IBinding[]) ArrayUtil.trim( IBinding.class, bs ); - if( bs.length == 1 ) - return bs[0]; - return CPPSemantics.resolveAmbiguities( name, bs ); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getClassType() - */ - public ICPPClassType getClassType() { - return (ICPPClassType) instance; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getImplicitMethods() - */ - public ICPPMethod[] getImplicitMethods() { - // TODO Auto-generated method stub - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName() - */ - public IName getScopeName() { - return (IASTName) ((ICPPInternalBinding)instance).getDefinition(); - } - - public void addName(IASTName name) { - if( name instanceof ICPPASTQualifiedName ) - return; - - if( bindings == null ) - bindings = new CharArrayObjectMap(1); - char [] c = name.toCharArray(); - - IASTNode parent = name.getParent(); - if( parent instanceof IASTDeclarator && CPPVisitor.isConstructor( this, (IASTDeclarator) parent ) ){ - c = CONSTRUCTOR_KEY; - } - Object o = bindings.get( c ); - if( o != null ){ - if( o instanceof ObjectSet ){ - ((ObjectSet)o).put( name ); - } else { - ObjectSet temp = new ObjectSet( 2 ); - temp.put( o ); - temp.put( name ); - bindings.put( c, temp ); - } - } else { - bindings.put( c, name ); - } - } - - protected ICPPConstructor [] getConstructors( ){ - if( bindings == null ) - return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY; - - if( !doneConstructors ){ - ICPPConstructor[] ctors; - try { - ctors = ((ICPPClassType)instance.getTemplateDefinition()).getConstructors(); - for (int i = 0; i < ctors.length; i++) { - addBinding( ctors[i] ); - } - doneConstructors = true; - } catch (DOMException e) { - } - } - ICPPConstructor[] ctors = CPPClassScope.getConstructors( bindings, true ); - for (int i = 0; i < ctors.length; i++) { - if( instanceMap.containsKey( ctors[i] ) ){ - ctors[i] = (ICPPConstructor) instanceMap.get( ctors[i] ); - } else { - IBinding b = CPPTemplates.createSpecialization( this, ctors[i], instance.getArgumentMap() ); - if( instanceMap == ObjectMap.EMPTY_MAP ) - instanceMap = new ObjectMap(2); - instanceMap.put( ctors[i], b ); - ctors[i] = (ICPPConstructor) b; - } - } - return ctors; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#setFullyCached(boolean) - */ - public void setFullyCached(boolean b) { - isFullyCached = b; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#getParent() - */ - public IScope getParent() throws DOMException { - ICPPClassType cls = getOriginalClass(); - ICPPClassScope scope = (ICPPClassScope)cls.getCompositeScope(); - if( scope != null ) - return scope.getParent(); - if( cls instanceof ICPPInternalBinding ){ - IASTNode [] nds = ((ICPPInternalBinding)cls).getDeclarations(); - if( nds != null && nds.length > 0 ) - return CPPVisitor.getContainingScope( nds[0] ); - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) - */ - public IBinding[] find(String name) { - return find(name, false); - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) - */ - public IBinding[] find(String name, boolean prefixLookup) { - if( name != null ) {} - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#getPhysicalNode() - */ - public IASTNode getPhysicalNode() throws DOMException { - ICPPClassType cls = getOriginalClass(); - ICPPClassScope scope = (ICPPClassScope)cls.getCompositeScope(); - - IASTNode node= ASTInternal.getPhysicalNodeOfScope(scope); - if (node != null) { - return node; - } - - IASTNode[] nds= ASTInternal.getDeclarationsOfBinding(cls); - - if( nds != null && nds.length > 0 ) - return nds[0]; - - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding) - */ - public void removeBinding(IBinding binding) { - char [] name = binding.getNameCharArray(); - if( ! bindings.containsKey( name ) ) - return; - - Object obj = bindings.get( name ); - if( obj instanceof ObjectSet ){ - ObjectSet set = (ObjectSet) obj; - set.remove( binding ); - if( set.size() == 0 ) - bindings.remove( name, 0, name.length ); - } else { - bindings.remove( name, 0, name.length ); - } - - if( instanceMap != null && instanceMap.containsKey( binding ) ) - instanceMap.remove( binding ); - isFullyCached = false; - } - - public void flushCache() { - if( bindings != null ) - bindings.clear(); - isFullyCached = false; - } - - public void addBinding(IBinding binding) { - if( bindings == null ) - bindings = new CharArrayObjectMap(1); - char [] c = (binding instanceof ICPPConstructor) ? CONSTRUCTOR_KEY : binding.getNameCharArray(); - Object o = bindings.get( c ); - if( o != null ){ - if( o instanceof ObjectSet ){ - ((ObjectSet)o).put( binding ); - } else { - ObjectSet set = new ObjectSet(2); - set.put( o ); - set.put( binding ); - bindings.put( c, set ); - } - } else { - bindings.put( c, binding ); - } - } - - public IBinding getInstance( IBinding binding ){ - if( instanceMap != null && instanceMap.containsKey( binding ) ) - return (IBinding) instanceMap.get( binding ); - return null; - } -} Index: parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java,v retrieving revision 1.36 diff -u -r1.36 PDOMLinkage.java --- parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java 19 Mar 2007 21:05:44 -0000 1.36 +++ parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMLinkage.java 23 Mar 2007 15:31:13 -0000 @@ -39,7 +39,7 @@ import org.eclipse.cdt.core.index.IIndexLinkage; import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassInstanceScope; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecializationScope; import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.index.composite.CompositeScope; import org.eclipse.cdt.internal.core.pdom.PDOM; @@ -158,23 +158,15 @@ return null; } - public PDOMNode addType(PDOMNode parent, IType type) throws CoreException { - PDOMNode node; - + public PDOMNode addType(PDOMNode parent, IType type) throws CoreException { if (type instanceof IPointerType) - node = new PDOMPointerType(pdom, parent, (IPointerType)type); + return new PDOMPointerType(pdom, parent, (IPointerType)type); else if (type instanceof IArrayType) - node= new PDOMArrayType(pdom, parent, (IArrayType) type); + return new PDOMArrayType(pdom, parent, (IArrayType) type); else if (type instanceof IQualifierType) - node = new PDOMQualifierType(pdom, parent, (IQualifierType)type); + return new PDOMQualifierType(pdom, parent, (IQualifierType)type); else - node = null; - - if(node!=null) { - parent.addChild(node); - } - - return node; + return null; } public abstract IBTreeComparator getIndexComparator(); @@ -254,8 +246,8 @@ } else { IBinding scopeBinding = null; - if (scope instanceof CPPClassInstanceScope) { - scopeBinding = ((CPPClassInstanceScope)scope).getClassType(); + if (scope instanceof CPPClassSpecializationScope) { + scopeBinding = ((CPPClassSpecializationScope)scope).getClassType(); } else { IName scopeName = scope.getScopeName(); if (scopeName instanceof IASTName) { Index: parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java,v retrieving revision 1.63 diff -u -r1.63 PDOMCPPLinkage.java --- parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java 19 Mar 2007 21:05:44 -0000 1.63 +++ parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java 23 Mar 2007 15:31:13 -0000 @@ -54,7 +54,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassInstanceScope; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecializationScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction; import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator; @@ -243,7 +243,7 @@ } else if (binding instanceof ICPPSpecialization) { try { IScope scope = binding.getScope(); - if (scope instanceof CPPClassInstanceScope) + if (scope instanceof CPPClassSpecializationScope) return true; } catch (DOMException e) { } @@ -284,7 +284,7 @@ pdomBinding = new PDOMCPPClassTemplatePartialSpecialization( pdom, parent, (ICPPClassTemplatePartialSpecialization) binding, - (PDOMCPPClassTemplate) pdomSpecialized); + pdomSpecialized); } else if (binding instanceof ICPPField && pdomSpecialized instanceof PDOMCPPField) { pdomBinding = new PDOMCPPFieldSpecialization(pdom, parent, (ICPPField) binding, (PDOMCPPField) pdomSpecialized); Index: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecializationScope.java =================================================================== RCS file: parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecializationScope.java diff -N parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecializationScope.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassSpecializationScope.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,391 @@ +/******************************************************************************* + * Copyright (c) 2005, 2007 IBM Corporation 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: + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Bryan Wilkinson (QNX) + *******************************************************************************/ +/* + * Created on Mar 28, 2005 + */ +package org.eclipse.cdt.internal.core.dom.parser.cpp; + +import org.eclipse.cdt.core.dom.IName; +import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IASTDeclarator; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IScope; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; +import org.eclipse.cdt.core.parser.util.ArrayUtil; +import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; +import org.eclipse.cdt.core.parser.util.CharArrayUtils; +import org.eclipse.cdt.core.parser.util.ObjectMap; +import org.eclipse.cdt.core.parser.util.ObjectSet; +import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; +import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope; + +/** + * @author aniefer + */ +public class CPPClassSpecializationScope implements ICPPClassScope, IASTInternalScope { + private static final char[] CONSTRUCTOR_KEY = "!!!CTOR!!!".toCharArray(); //$NON-NLS-1$ + + private CharArrayObjectMap bindings; + private ObjectMap instanceMap = ObjectMap.EMPTY_MAP; + + private ICPPSpecialization specialization; + private boolean isFullyCached = false; + private boolean doneConstructors = false; + + /** + * @param instance + */ + public CPPClassSpecializationScope(CPPClassSpecialization specialization ) { + this.specialization = specialization; + } + + /** + * @param instance + */ + public CPPClassSpecializationScope(CPPClassInstance instance ) { + this.specialization = instance; + } + + private ICPPClassType getOriginalClass(){ + return (ICPPClassType) specialization.getSpecializedBinding(); + } + public boolean isFullyCached(){ + if( !isFullyCached ){ + CPPSemantics.LookupData data = new CPPSemantics.LookupData(); + try { + CPPSemantics.lookupInScope( data, this, null ); + } catch (DOMException e) { + } + } + return true; + } + + public IBinding getBinding( IASTName name, boolean forceResolve ) { + char [] c = name.toCharArray(); + if( bindings == null ) + return null; + + if( CharArrayUtils.equals( c, specialization.getNameCharArray() ) ){ + if (CPPClassScope.isConstructorReference( name )) + c = CONSTRUCTOR_KEY; + else + return specialization; + } + + Object cache = bindings.get( c ); + if( cache != null ){ + int i = ( cache instanceof ObjectSet ) ? 0 : -1; + ObjectSet set = ( cache instanceof ObjectSet ) ? (ObjectSet) cache : null; + Object obj = ( set != null ) ? set.keyAt( i ) : cache; + IBinding [] bs = null; + IBinding binding = null; + while( obj != null ){ + if( obj instanceof IASTName ){ + IASTName n = (IASTName) obj; + if( n instanceof ICPPASTQualifiedName ){ + IASTName [] ns = ((ICPPASTQualifiedName)n).getNames(); + n = ns[ ns.length - 1 ]; + } + if( instanceMap.containsKey( n ) ){ + binding = (IBinding) instanceMap.get( n ); + } else { + binding = CPPClassScope.shouldResolve(forceResolve, n, name) ? n.resolveBinding() : n.getBinding(); + if (binding instanceof ICPPClassTemplatePartialSpecialization ){ + binding = null; + } + if( binding != null ){ + binding = CPPTemplates.createSpecialization( this, binding, specialization.getArgumentMap() ); + if( instanceMap == ObjectMap.EMPTY_MAP ) + instanceMap = new ObjectMap(2); + instanceMap.put( n, binding ); + } + } + } else if( obj instanceof IBinding ){ + if( instanceMap.containsKey( obj ) ){ + binding = (IBinding) instanceMap.get( obj ); + } else { + binding = CPPTemplates.createSpecialization( this, (IBinding) obj, specialization.getArgumentMap() ); + if( instanceMap == ObjectMap.EMPTY_MAP ) + instanceMap = new ObjectMap(2); + instanceMap.put( obj, binding ); + } + } + if( binding != null ){ + if( i == -1 ) + return binding; + bs = (IBinding[]) ArrayUtil.append( IBinding.class, bs, binding ); + binding = null; + } + if( i != -1 && ++i < set.size() ){ + obj = set.keyAt( i ); + } else { + obj = null; + } + } + bs = (IBinding[]) ArrayUtil.trim( IBinding.class, bs ); + if( bs.length == 1 ) + return bs[0]; + return CPPSemantics.resolveAmbiguities( name, bs ); + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getClassType() + */ + public ICPPClassType getClassType() { + return (ICPPClassType) specialization; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getImplicitMethods() + */ + public ICPPMethod[] getImplicitMethods() { + // TODO Auto-generated method stub + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getScopeName() + */ + public IName getScopeName() { + return (IASTName) ((ICPPInternalBinding)specialization).getDefinition(); + } + + public void addName(IASTName name) { + if( name instanceof ICPPASTQualifiedName ) + return; + + if( bindings == null ) + bindings = new CharArrayObjectMap(1); + char [] c = name.toCharArray(); + + IASTNode parent = name.getParent(); + if( parent instanceof IASTDeclarator && CPPVisitor.isConstructor( this, (IASTDeclarator) parent ) ){ + c = CONSTRUCTOR_KEY; + } + Object o = bindings.get( c ); + if( o != null ){ + if( o instanceof ObjectSet ){ + ((ObjectSet)o).put( name ); + } else { + ObjectSet temp = new ObjectSet( 2 ); + temp.put( o ); + temp.put( name ); + bindings.put( c, temp ); + } + } else { + bindings.put( c, name ); + } + } + + protected ICPPConstructor [] getConstructors( ){ + if( bindings == null ) + return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY; + + if( !doneConstructors ){ + ICPPConstructor[] ctors; + try { + ctors = ((ICPPClassType)specialization.getSpecializedBinding()).getConstructors(); + for (int i = 0; i < ctors.length; i++) { + addBinding( ctors[i] ); + } + doneConstructors = true; + } catch (DOMException e) { + } + } + ICPPConstructor[] ctors = CPPClassScope.getConstructors( bindings, true ); + for (int i = 0; i < ctors.length; i++) { + if( instanceMap.containsKey( ctors[i] ) ){ + ctors[i] = (ICPPConstructor) instanceMap.get( ctors[i] ); + } else { + IBinding b = CPPTemplates.createSpecialization( this, ctors[i], specialization.getArgumentMap() ); + if( instanceMap == ObjectMap.EMPTY_MAP ) + instanceMap = new ObjectMap(2); + instanceMap.put( ctors[i], b ); + ctors[i] = (ICPPConstructor) b; + } + } + return ctors; + } + + protected ICPPMethod[] getConversionOperators() { + if( bindings == null ) + return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY; + + ICPPMethod [] result = null; + + Object[] values = bindings.valueArray(); + for (int i = 0; i < values.length; i++) { + int j = ( values[i] instanceof ObjectSet ) ? 0 : -1; + ObjectSet set = ( values[i] instanceof ObjectSet ) ? (ObjectSet) values[i] : null; + Object obj = ( set != null ) ? set.keyAt( j ) : values[i]; + IBinding binding = null; + while( obj != null ){ + if( obj instanceof IASTName ){ + IASTName n = (IASTName) obj; + if( n instanceof ICPPASTQualifiedName ){ + IASTName [] ns = ((ICPPASTQualifiedName)n).getNames(); + n = ns[ ns.length - 1 ]; + } + + if (n instanceof ICPPASTConversionName) { + if( instanceMap.containsKey( n ) ){ + binding = (IBinding) instanceMap.get( n ); + } else { + binding = n.resolveBinding(); + if( binding != null ){ + binding = CPPTemplates.createSpecialization( this, binding, specialization.getArgumentMap() ); + if( instanceMap == ObjectMap.EMPTY_MAP ) + instanceMap = new ObjectMap(2); + instanceMap.put( n, binding ); + } + } + } + } + if( binding != null ){ + result = (ICPPMethod[]) ArrayUtil.append( ICPPMethod.class, result, binding ); + binding = null; + } + if( j != -1 && ++j < set.size() ){ + obj = set.keyAt( j ); + } else { + obj = null; + } + } + } + + return (ICPPMethod[]) ArrayUtil.trim( ICPPMethod.class, result ); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#setFullyCached(boolean) + */ + public void setFullyCached(boolean b) { + isFullyCached = b; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.IScope#getParent() + */ + public IScope getParent() throws DOMException { + ICPPClassType cls = getOriginalClass(); + ICPPClassScope scope = (ICPPClassScope)cls.getCompositeScope(); + if( scope != null ) + return scope.getParent(); + if( cls instanceof ICPPInternalBinding ){ + IASTNode [] nds = ((ICPPInternalBinding)cls).getDeclarations(); + if( nds != null && nds.length > 0 ) + return CPPVisitor.getContainingScope( nds[0] ); + } + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) + */ + public IBinding[] find(String name) { + return find(name, false); + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) + */ + public IBinding[] find(String name, boolean prefixLookup) { + if( name != null ) {} + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.IScope#getPhysicalNode() + */ + public IASTNode getPhysicalNode() throws DOMException { + ICPPClassType cls = getOriginalClass(); + ICPPClassScope scope = (ICPPClassScope)cls.getCompositeScope(); + + IASTNode node= ASTInternal.getPhysicalNodeOfScope(scope); + if (node != null) { + return node; + } + + IASTNode[] nds= ASTInternal.getDeclarationsOfBinding(cls); + + if( nds != null && nds.length > 0 ) + return nds[0]; + + return null; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#removeBinding(org.eclipse.cdt.core.dom.ast.IBinding) + */ + public void removeBinding(IBinding binding) { + char [] name = binding.getNameCharArray(); + if( ! bindings.containsKey( name ) ) + return; + + Object obj = bindings.get( name ); + if( obj instanceof ObjectSet ){ + ObjectSet set = (ObjectSet) obj; + set.remove( binding ); + if( set.size() == 0 ) + bindings.remove( name, 0, name.length ); + } else { + bindings.remove( name, 0, name.length ); + } + + if( instanceMap != null && instanceMap.containsKey( binding ) ) + instanceMap.remove( binding ); + isFullyCached = false; + } + + public void flushCache() { + if( bindings != null ) + bindings.clear(); + isFullyCached = false; + } + + public void addBinding(IBinding binding) { + if( bindings == null ) + bindings = new CharArrayObjectMap(1); + char [] c = (binding instanceof ICPPConstructor) ? CONSTRUCTOR_KEY : binding.getNameCharArray(); + Object o = bindings.get( c ); + if( o != null ){ + if( o instanceof ObjectSet ){ + ((ObjectSet)o).put( binding ); + } else { + ObjectSet set = new ObjectSet(2); + set.put( o ); + set.put( binding ); + bindings.put( c, set ); + } + } else { + bindings.put( c, binding ); + } + } + + public IBinding getInstance( IBinding binding ){ + if( instanceMap != null && instanceMap.containsKey( binding ) ) + return (IBinding) instanceMap.get( binding ); + return null; + } +}