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

Partial fix for bug 214017.

This commit is contained in:
Sergey Prigogin 2008-04-19 08:36:06 +00:00
parent b45f93e8ce
commit b30c89a812
16 changed files with 1141 additions and 120 deletions

View file

@ -236,6 +236,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
IBinding[] result = getBindingsInAST(name, resolve, prefixLookup); IBinding[] result = getBindingsInAST(name, resolve, prefixLookup);
final IASTTranslationUnit tu = name.getTranslationUnit(); final IASTTranslationUnit tu = name.getTranslationUnit();
if (tu != null) {
IIndex index = tu.getIndex(); IIndex index = tu.getIndex();
if (index != null) { if (index != null) {
if (physicalNode instanceof IASTTranslationUnit) { if (physicalNode instanceof IASTTranslationUnit) {
@ -268,6 +269,7 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
} }
} }
} }
}
return (IBinding[]) ArrayUtil.trim(IBinding.class, result); return (IBinding[]) ArrayUtil.trim(IBinding.class, result);
} }

View file

@ -108,8 +108,19 @@ public abstract class CPPUnknownBinding extends PlatformObject
t = SemanticUtil.getUltimateType(t, false); t = SemanticUtil.getUltimateType(t, false);
if (t instanceof ICPPClassType) { if (t instanceof ICPPClassType) {
IScope s = ((ICPPClassType) t).getCompositeScope(); IScope s = ((ICPPClassType) t).getCompositeScope();
if (s != null && ASTInternal.isFullyCached(s)) if (s != null && ASTInternal.isFullyCached(s)) {
// If name did not come from an AST but was created just to encapsulate
// a simple identifier, we should not use getBinding method since it may
// lead to a NullPointerException.
if (name.getParent() != null) {
result = s.getBinding(name, true); result = s.getBinding(name, true);
} else {
IBinding[] bindings = s.find(name.toString());
if (bindings != null && bindings.length > 0) {
result = bindings[0];
}
}
}
} else if (t instanceof ICPPInternalUnknown) { } else if (t instanceof ICPPInternalUnknown) {
result = resolvePartially((ICPPInternalUnknown) t, argMap); result = resolvePartially((ICPPInternalUnknown) t, argMap);
} }

View file

@ -31,7 +31,6 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
*/ */
public class CPPUnknownClass extends CPPUnknownBinding implements ICPPInternalUnknownClassType { public class CPPUnknownClass extends CPPUnknownBinding implements ICPPInternalUnknownClassType {
public CPPUnknownClass(ICPPInternalUnknown scopeBinding, IASTName name) { public CPPUnknownClass(ICPPInternalUnknown scopeBinding, IASTName name) {
super(scopeBinding, name); super(scopeBinding, name);
} }

View file

@ -11,10 +11,6 @@
* Bryan Wilkinson (QNX) * Bryan Wilkinson (QNX)
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
/*
* Created on May 3, 2005
*/
package org.eclipse.cdt.internal.core.dom.parser.cpp; package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.core.dom.IName; import org.eclipse.cdt.core.dom.IName;
@ -30,13 +26,12 @@ import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; import org.eclipse.cdt.core.parser.util.CharArrayObjectMap;
import org.eclipse.cdt.core.parser.util.CharArrayUtils; import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
/** /**
* @author aniefer * @author aniefer
*/ */
public class CPPUnknownScope implements ICPPScope, IASTInternalScope { public class CPPUnknownScope implements ICPPScope, ICPPInternalUnknownScope {
private final ICPPInternalUnknown binding; private final ICPPInternalUnknown binding;
private final IASTName scopeName; private final IASTName scopeName;
private CharArrayObjectMap map; private CharArrayObjectMap map;
@ -169,6 +164,13 @@ public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
// do nothing, this is part of template magic and not a normal scope // do nothing, this is part of template magic and not a normal scope
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope#getUnknownBinding()
*/
public ICPPInternalUnknown getScopeBinding() {
return binding;
}
/* (non-Javadoc) /* (non-Javadoc)
* For debug purposes only * For debug purposes only
*/ */

View file

@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2008 Google, Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope;
/**
* Scope corresponding to an unknown binding.
* @see ICPPInternalUnknown
*
* @author Sergey Prigogin
*/
public interface ICPPInternalUnknownScope extends IASTInternalScope {
/**
* @return Returns the binding corresponding to the scope.
*/
public abstract ICPPInternalUnknown getScopeBinding();
}

View file

@ -2338,7 +2338,7 @@ public class CPPSemantics {
return findBindings( scope, name.toCharArray(), qualified ); return findBindings( scope, name.toCharArray(), qualified );
} }
public static IBinding[] findBindings( IScope scope, char []name, boolean qualified ) throws DOMException{ public static IBinding[] findBindings( IScope scope, char[] name, boolean qualified ) throws DOMException{
CPPASTName astName = new CPPASTName(); CPPASTName astName = new CPPASTName();
astName.setName( name ); astName.setName( name );
astName.setParent( ASTInternal.getPhysicalNodeOfScope(scope)); astName.setParent( ASTInternal.getPhysicalNodeOfScope(scope));

View file

@ -56,4 +56,6 @@ public interface IIndexCPPBindingConstants {
int CPP_FUNCTION_TYPE= IIndexBindingConstants.LAST_CONSTANT + 39; int CPP_FUNCTION_TYPE= IIndexBindingConstants.LAST_CONSTANT + 39;
int GPPBASICTYPE = IIndexBindingConstants.LAST_CONSTANT + 40; int GPPBASICTYPE = IIndexBindingConstants.LAST_CONSTANT + 40;
int CPP_USING_DECLARATION= IIndexBindingConstants.LAST_CONSTANT + 41; int CPP_USING_DECLARATION= IIndexBindingConstants.LAST_CONSTANT + 41;
int CPP_UNKNOWN_CLASS_TYPE= IIndexBindingConstants.LAST_CONSTANT + 42;
int CPP_UNKNOWN_CLASS_INSTANCE= IIndexBindingConstants.LAST_CONSTANT + 43;
} }

View file

@ -49,6 +49,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndex;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexMacroContainer; import org.eclipse.cdt.core.index.IIndexMacroContainer;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType;
import org.eclipse.cdt.internal.core.index.CIndex; import org.eclipse.cdt.internal.core.index.CIndex;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding; import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexScope; import org.eclipse.cdt.internal.core.index.IIndexScope;
@ -59,10 +61,9 @@ import org.eclipse.cdt.internal.core.index.composite.CompositeMacroContainer;
import org.eclipse.cdt.internal.core.index.composite.CompositePointerType; import org.eclipse.cdt.internal.core.index.composite.CompositePointerType;
import org.eclipse.cdt.internal.core.index.composite.CompositeQualifierType; import org.eclipse.cdt.internal.core.index.composite.CompositeQualifierType;
import org.eclipse.cdt.internal.core.index.composite.CompositingNotImplementedError; import org.eclipse.cdt.internal.core.index.composite.CompositingNotImplementedError;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
public class CPPCompositesFactory extends AbstractCompositeFactory implements ICompositesFactory { public class CPPCompositesFactory extends AbstractCompositeFactory {
public CPPCompositesFactory(IIndex index) { public CPPCompositesFactory(IIndex index) {
super(index); super(index);
@ -75,22 +76,22 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
IIndexScope result; IIndexScope result;
try { try {
if(rscope == null) { if (rscope == null) {
return null; return null;
} else if(rscope instanceof ICPPClassScope) { } else if (rscope instanceof ICPPClassScope) {
ICPPClassScope classScope = (ICPPClassScope) rscope; ICPPClassScope classScope = (ICPPClassScope) rscope;
result = new CompositeCPPClassScope(this, result = new CompositeCPPClassScope(this,
findOneBinding(classScope.getClassType())); findOneBinding(classScope.getClassType()));
} else if(rscope instanceof ICPPNamespaceScope) { } else if (rscope instanceof ICPPNamespaceScope) {
ICPPNamespace[] namespaces; ICPPNamespace[] namespaces;
if(rscope instanceof CompositeCPPNamespace) { if (rscope instanceof CompositeCPPNamespace) {
// avoid duplicating the search // avoid duplicating the search
namespaces = ((CompositeCPPNamespace)rscope).namespaces; namespaces = ((CompositeCPPNamespace)rscope).namespaces;
} else { } else {
namespaces = getNamespaces(rscope.getScopeBinding()); namespaces = getNamespaces(rscope.getScopeBinding());
} }
return new CompositeCPPNamespaceScope(this, namespaces); return new CompositeCPPNamespaceScope(this, namespaces);
} else if(rscope instanceof ICPPTemplateScope) { } else if (rscope instanceof ICPPTemplateScope) {
return new CompositeCPPTemplateScope(this, (ICPPTemplateScope) rscope); return new CompositeCPPTemplateScope(this, (ICPPTemplateScope) rscope);
} else { } else {
throw new CompositingNotImplementedError(rscope.getClass().getName()); throw new CompositingNotImplementedError(rscope.getClass().getName());
@ -109,31 +110,31 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
public IType getCompositeType(IIndexType rtype) throws DOMException { public IType getCompositeType(IIndexType rtype) throws DOMException {
IType result; IType result;
if(rtype instanceof ICPPSpecialization) { if (rtype instanceof ICPPSpecialization) {
result = (IIndexType) getCompositeBinding((IIndexFragmentBinding) rtype); result = (IIndexType) getCompositeBinding((IIndexFragmentBinding) rtype);
} else if(rtype instanceof ICPPClassType) { } else if (rtype instanceof ICPPClassType) {
result = (ICPPClassType) getCompositeBinding((IIndexFragmentBinding) rtype); result = (ICPPClassType) getCompositeBinding((IIndexFragmentBinding) rtype);
} else if(rtype instanceof ITypedef) { } else if (rtype instanceof ITypedef) {
result = new CompositeCPPTypedef(this, (ICPPBinding) rtype); result = new CompositeCPPTypedef(this, (ICPPBinding) rtype);
} else if (rtype instanceof IEnumeration) { } else if (rtype instanceof IEnumeration) {
result = (IEnumeration) getCompositeBinding((IIndexFragmentBinding) rtype); result = (IEnumeration) getCompositeBinding((IIndexFragmentBinding) rtype);
} else if(rtype instanceof ICPPFunctionType) { } else if (rtype instanceof ICPPFunctionType) {
result = new CompositeCPPFunctionType((ICPPFunctionType) rtype, this); result = new CompositeCPPFunctionType((ICPPFunctionType) rtype, this);
} else if(rtype instanceof ICPPPointerToMemberType) { } else if (rtype instanceof ICPPPointerToMemberType) {
result = new CompositeCPPPointerToMemberType(this, (ICPPPointerToMemberType)rtype); result = new CompositeCPPPointerToMemberType(this, (ICPPPointerToMemberType) rtype);
} else if(rtype instanceof IPointerType) { } else if (rtype instanceof IPointerType) {
result = new CompositePointerType((IPointerType)rtype, this); result = new CompositePointerType((IPointerType) rtype, this);
} else if(rtype instanceof ICPPReferenceType) { } else if (rtype instanceof ICPPReferenceType) {
result = new CompositeCPPReferenceType((ICPPReferenceType)rtype, this); result = new CompositeCPPReferenceType((ICPPReferenceType)rtype, this);
} else if(rtype instanceof IQualifierType) { } else if (rtype instanceof IQualifierType) {
result = new CompositeQualifierType((IQualifierType) rtype, this); result = new CompositeQualifierType((IQualifierType) rtype, this);
} else if(rtype instanceof IArrayType) { } else if (rtype instanceof IArrayType) {
result = new CompositeArrayType((IArrayType) rtype, this); result = new CompositeArrayType((IArrayType) rtype, this);
} else if(rtype == null) { } else if (rtype == null) {
result = null; result = null;
} else if(rtype instanceof ICPPTemplateTypeParameter) { } else if (rtype instanceof ICPPTemplateTypeParameter) {
result = (IIndexType) getCompositeBinding((IIndexFragmentBinding) rtype); result = (IIndexType) getCompositeBinding((IIndexFragmentBinding) rtype);
} else if(rtype instanceof IBasicType) { } else if (rtype instanceof IBasicType) {
result = rtype; // no context required its a leaf with no way to traverse upward result = rtype; // no context required its a leaf with no way to traverse upward
} else { } else {
throw new CompositingNotImplementedError(); throw new CompositingNotImplementedError();
@ -142,12 +143,11 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
return result; return result;
} }
private ICPPNamespace[] getNamespaces(IBinding rbinding) throws CoreException { private ICPPNamespace[] getNamespaces(IBinding rbinding) throws CoreException {
CIndex cindex = (CIndex) index; CIndex cindex = (CIndex) index;
IIndexBinding[] ibs = cindex.findEquivalentBindings(rbinding); IIndexBinding[] ibs = cindex.findEquivalentBindings(rbinding);
ICPPNamespace[] namespaces = new ICPPNamespace[ibs.length]; ICPPNamespace[] namespaces = new ICPPNamespace[ibs.length];
for(int i=0; i<namespaces.length; i++) for (int i = 0; i < namespaces.length; i++)
namespaces[i] = (ICPPNamespace) ibs[i]; namespaces[i] = (ICPPNamespace) ibs[i];
return namespaces; return namespaces;
} }
@ -160,11 +160,6 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
return super.findOneBinding(binding, false); return super.findOneBinding(binding, false);
} }
@Override
protected IIndexFragmentBinding findOneBinding(IBinding binding, boolean allowDeclaration) {
return super.findOneBinding(binding, allowDeclaration);
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeBinding(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IBinding) * @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeBinding(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IBinding)
*/ */
@ -172,66 +167,68 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
IIndexBinding result; IIndexBinding result;
try { try {
if(binding==null) { if (binding == null) {
result = null; result = null;
} else if(binding instanceof ICPPSpecialization) { } else if (binding instanceof ICPPSpecialization) {
if(binding instanceof ICPPTemplateInstance) { if (binding instanceof ICPPTemplateInstance) {
if(binding instanceof ICPPDeferredTemplateInstance) { if (binding instanceof ICPPDeferredTemplateInstance) {
if(binding instanceof ICPPClassType) { if (binding instanceof ICPPClassType) {
return new CompositeCPPDeferredClassInstance(this, (ICPPClassType) findOneBinding(binding)); return new CompositeCPPDeferredClassInstance(this, (ICPPClassType) findOneBinding(binding));
} else if(binding instanceof ICPPFunction) { } else if (binding instanceof ICPPFunction) {
return new CompositeCPPDeferredFunctionInstance(this, (ICPPFunction) binding); return new CompositeCPPDeferredFunctionInstance(this, (ICPPFunction) binding);
} else { } else {
throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
} }
} else { } else {
if(binding instanceof ICPPClassType) { if (binding instanceof ICPPClassType) {
return new CompositeCPPClassInstance(this, (ICPPClassType) findOneBinding(binding)); return new CompositeCPPClassInstance(this, (ICPPClassType) findOneBinding(binding));
} else if(binding instanceof ICPPConstructor) { } else if (binding instanceof ICPPConstructor) {
return new CompositeCPPConstructorInstance(this, (ICPPConstructor) binding); return new CompositeCPPConstructorInstance(this, (ICPPConstructor) binding);
} else if(binding instanceof ICPPMethod) { } else if (binding instanceof ICPPMethod) {
return new CompositeCPPMethodInstance(this, (ICPPMethod) binding); return new CompositeCPPMethodInstance(this, (ICPPMethod) binding);
} else if(binding instanceof ICPPFunction) { } else if (binding instanceof ICPPFunction) {
return new CompositeCPPFunctionInstance(this, (ICPPFunction) binding); return new CompositeCPPFunctionInstance(this, (ICPPFunction) binding);
} else { } else {
throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
} }
} }
} else if (binding instanceof ICPPTemplateDefinition) { } else if (binding instanceof ICPPTemplateDefinition) {
if(binding instanceof ICPPClassTemplatePartialSpecialization) { if (binding instanceof ICPPClassTemplatePartialSpecialization) {
return new CompositeCPPClassTemplatePartialSpecialization(this, (ICPPClassTemplatePartialSpecialization) binding); return new CompositeCPPClassTemplatePartialSpecialization(this, (ICPPClassTemplatePartialSpecialization) binding);
} else if(binding instanceof ICPPClassType) { } else if (binding instanceof ICPPClassType) {
return new CompositeCPPClassTemplateSpecialization(this, (ICPPClassType) binding); return new CompositeCPPClassTemplateSpecialization(this, (ICPPClassType) binding);
} else if(binding instanceof ICPPConstructor) { } else if (binding instanceof ICPPConstructor) {
return new CompositeCPPConstructorTemplateSpecialization(this, (ICPPConstructor) binding); return new CompositeCPPConstructorTemplateSpecialization(this, (ICPPConstructor) binding);
} else if(binding instanceof ICPPMethod) { } else if (binding instanceof ICPPMethod) {
return new CompositeCPPMethodTemplateSpecialization(this, (ICPPMethod) binding); return new CompositeCPPMethodTemplateSpecialization(this, (ICPPMethod) binding);
} else if(binding instanceof ICPPFunctionType) { } else if (binding instanceof ICPPFunctionType) {
return new CompositeCPPFunctionTemplateSpecialization(this, (ICPPFunction) binding); return new CompositeCPPFunctionTemplateSpecialization(this, (ICPPFunction) binding);
} else { } else {
throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
} }
} else { } else {
if(binding instanceof ICPPClassType) { if (binding instanceof ICPPClassType) {
return new CompositeCPPClassSpecialization(this, (ICPPClassType) findOneBinding(binding)); return new CompositeCPPClassSpecialization(this, (ICPPClassType) findOneBinding(binding));
} if(binding instanceof ICPPConstructor) { } else if (binding instanceof ICPPConstructor) {
return new CompositeCPPConstructorSpecialization(this, (ICPPConstructor) findOneBinding(binding, true)); return new CompositeCPPConstructorSpecialization(this, (ICPPConstructor) findOneBinding(binding, true));
} if(binding instanceof ICPPMethod) { } else if (binding instanceof ICPPMethod) {
return new CompositeCPPMethodSpecialization(this, (ICPPMethod) findOneBinding(binding, true)); return new CompositeCPPMethodSpecialization(this, (ICPPMethod) findOneBinding(binding, true));
} if(binding instanceof ICPPFunction) { } else if (binding instanceof ICPPFunction) {
return new CompositeCPPFunctionSpecialization(this, (ICPPFunction) findOneBinding(binding, true)); return new CompositeCPPFunctionSpecialization(this, (ICPPFunction) findOneBinding(binding, true));
} if(binding instanceof ICPPField) { } else if (binding instanceof ICPPField) {
return new CompositeCPPField(this, (ICPPField) binding); return new CompositeCPPField(this, (ICPPField) binding);
} if(binding instanceof ICPPParameter) { } else if (binding instanceof ICPPParameter) {
return new CompositeCPPParameterSpecialization(this, (ICPPParameter) binding); return new CompositeCPPParameterSpecialization(this, (ICPPParameter) binding);
} if(binding instanceof ITypedef) { } else if (binding instanceof ITypedef) {
return new CompositeCPPTypedefSpecialization(this, (ICPPBinding) binding); return new CompositeCPPTypedefSpecialization(this, (ICPPBinding) binding);
} else { } else {
throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
} }
} }
} else if (binding instanceof ICPPTemplateDefinition) { } else if (binding instanceof ICPPTemplateDefinition) {
if(binding instanceof ICPPClassTemplate) { if (binding instanceof ICPPInternalUnknownClassInstance) {
result = new CompositeCPPUnknownClassInstance(this, (ICPPInternalUnknownClassInstance) binding);
} else if (binding instanceof ICPPClassTemplate) {
ICPPClassType def= (ICPPClassType) findOneBinding(binding); ICPPClassType def= (ICPPClassType) findOneBinding(binding);
return new CompositeCPPClassTemplate(this, def); return new CompositeCPPClassTemplate(this, def);
} else if (binding instanceof ICPPConstructor) { } else if (binding instanceof ICPPConstructor) {
@ -243,38 +240,40 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
} else { } else {
throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
} }
} else if(binding instanceof ICPPParameter) { } else if (binding instanceof ICPPParameter) {
result = new CompositeCPPParameter(this, (ICPPParameter) binding); result = new CompositeCPPParameter(this, (ICPPParameter) binding);
} else if(binding instanceof ICPPField) { } else if (binding instanceof ICPPField) {
result = new CompositeCPPField(this, (ICPPField) binding); result = new CompositeCPPField(this, (ICPPField) binding);
} else if(binding instanceof ICPPVariable) { } else if (binding instanceof ICPPVariable) {
result = new CompositeCPPVariable(this, (ICPPVariable) binding); result = new CompositeCPPVariable(this, (ICPPVariable) binding);
} else if(binding instanceof ICPPClassType) { } else if (binding instanceof ICPPInternalUnknownClassType) {
result = new CompositeCPPUnknownClassType(this, (ICPPInternalUnknownClassType) binding);
} else if (binding instanceof ICPPClassType) {
ICPPClassType def = (ICPPClassType) findOneBinding(binding); ICPPClassType def = (ICPPClassType) findOneBinding(binding);
result = def == null ? null : new CompositeCPPClassType(this, def); result = def == null ? null : new CompositeCPPClassType(this, def);
} else if(binding instanceof ICPPConstructor) { } else if (binding instanceof ICPPConstructor) {
result = new CompositeCPPConstructor(this, (ICPPConstructor) binding); result = new CompositeCPPConstructor(this, (ICPPConstructor) binding);
} else if(binding instanceof ICPPMethod) { } else if (binding instanceof ICPPMethod) {
result = new CompositeCPPMethod(this, (ICPPMethod) binding); result = new CompositeCPPMethod(this, (ICPPMethod) binding);
} else if(binding instanceof ICPPNamespaceAlias) { } else if (binding instanceof ICPPNamespaceAlias) {
result = new CompositeCPPNamespaceAlias(this, (ICPPNamespaceAlias) binding); result = new CompositeCPPNamespaceAlias(this, (ICPPNamespaceAlias) binding);
} else if(binding instanceof ICPPNamespace) { } else if (binding instanceof ICPPNamespace) {
ICPPNamespace[] ns = getNamespaces(binding); ICPPNamespace[] ns = getNamespaces(binding);
result = ns.length == 0 ? null : new CompositeCPPNamespace(this, ns); result = ns.length == 0 ? null : new CompositeCPPNamespace(this, ns);
} else if (binding instanceof ICPPUsingDeclaration) { } else if (binding instanceof ICPPUsingDeclaration) {
result = new CompositeCPPUsingDeclaration(this, (ICPPUsingDeclaration) binding); result = new CompositeCPPUsingDeclaration(this, (ICPPUsingDeclaration) binding);
} else if(binding instanceof IEnumeration) { } else if (binding instanceof IEnumeration) {
IEnumeration def = (IEnumeration) findOneBinding(binding); IEnumeration def = (IEnumeration) findOneBinding(binding);
result = def == null ? null : new CompositeCPPEnumeration(this, def); result = def == null ? null : new CompositeCPPEnumeration(this, def);
} else if(binding instanceof ICPPFunction) { } else if (binding instanceof ICPPFunction) {
result = new CompositeCPPFunction(this, (ICPPFunction) binding); result = new CompositeCPPFunction(this, (ICPPFunction) binding);
} else if(binding instanceof IEnumerator) { } else if (binding instanceof IEnumerator) {
result = new CompositeCPPEnumerator(this, (IEnumerator) binding); result = new CompositeCPPEnumerator(this, (IEnumerator) binding);
} else if(binding instanceof ITypedef) { } else if (binding instanceof ITypedef) {
result = new CompositeCPPTypedef(this, (ICPPBinding) binding); result = new CompositeCPPTypedef(this, (ICPPBinding) binding);
} else if(binding instanceof ICPPTemplateTypeParameter) { } else if (binding instanceof ICPPTemplateTypeParameter) {
result = new CompositeCPPTemplateTypeParameter(this, (ICPPTemplateTypeParameter) binding); result = new CompositeCPPTemplateTypeParameter(this, (ICPPTemplateTypeParameter) binding);
} else if(binding instanceof IIndexMacroContainer) { } else if (binding instanceof IIndexMacroContainer) {
result= new CompositeMacroContainer(this, binding); result= new CompositeMacroContainer(this, binding);
} else { } else {
throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$ throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$

View file

@ -23,11 +23,10 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.index.IIndexBinding;
import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory; import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
public class CompositeCPPClassInstance extends CompositeCPPClassType implements public class CompositeCPPClassInstance extends CompositeCPPClassType
ICPPClassType, IIndexType, ICPPTemplateInstance, ICPPSpecialization { implements ICPPTemplateInstance, ICPPSpecialization {
public CompositeCPPClassInstance(ICompositesFactory cf, ICPPClassType rbinding) { public CompositeCPPClassInstance(ICompositesFactory cf, ICPPClassType rbinding) {
super(cf, rbinding); super(cf, rbinding);
@ -37,7 +36,7 @@ ICPPClassType, IIndexType, ICPPTemplateInstance, ICPPSpecialization {
public ICPPMethod[] getDeclaredMethods() throws DOMException { public ICPPMethod[] getDeclaredMethods() throws DOMException {
ICPPClassType specialized = (ICPPClassType) getSpecializedBinding(); ICPPClassType specialized = (ICPPClassType) getSpecializedBinding();
ICPPMethod[] bindings = specialized.getDeclaredMethods(); ICPPMethod[] bindings = specialized.getDeclaredMethods();
for(int i=0; i<bindings.length; i++) { for (int i = 0; i < bindings.length; i++) {
bindings[i]= (ICPPMethod) CPPTemplates.createSpecialization((ICPPScope)getScope(), (IIndexBinding) bindings[i], getArgumentMap()); bindings[i]= (ICPPMethod) CPPTemplates.createSpecialization((ICPPScope)getScope(), (IIndexBinding) bindings[i], getArgumentMap());
} }
return bindings; return bindings;

View file

@ -0,0 +1,98 @@
/*******************************************************************************
* Copyright (c) 2008 Symbian Software Systems 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:
* Andrew Ferguson (Symbian) - Initial implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
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.ICPPMethod;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.composite.CompositingNotImplementedError;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
/**
*
*/
public class CompositeCPPClassSpecializationScope extends CompositeCPPClassScope {
public CompositeCPPClassSpecializationScope(ICompositesFactory cf, IIndexFragmentBinding rbinding) {
super(cf, rbinding);
}
private ICPPSpecialization specialization() {
return (ICPPSpecialization) cf.getCompositeBinding(rbinding);
}
@Override
public ICPPMethod[] getImplicitMethods() {
throw new CompositingNotImplementedError();
}
@Override
public IBinding[] find(String name) throws DOMException {
throw new CompositingNotImplementedError();
}
@Override
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet acceptLocalBindings) throws DOMException {
char[] c = name.toCharArray();
if (CharArrayUtils.equals(c, specialization().getNameCharArray()) &&
!CPPClassScope.isConstructorReference(name)) {
return specialization();
}
ICPPClassType specialized = (ICPPClassType) specialization().getSpecializedBinding();
IScope classScope = specialized.getCompositeScope();
IBinding[] bindings = classScope != null ? classScope.getBindings(name, resolve, false) : null;
if (bindings == null)
return null;
IBinding[] specs = new IBinding[0];
for (int i = 0; i < bindings.length; i++) {
specs = (IBinding[]) ArrayUtil.append(IBinding.class, specs, getInstance(bindings[i]));
}
specs = (IBinding[]) ArrayUtil.trim(IBinding.class, specs);
return CPPSemantics.resolveAmbiguities(name, specs);
}
@Override
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet acceptLocalBindings) throws DOMException {
throw new CompositingNotImplementedError();
}
private IBinding getInstance(IBinding binding) {
if (instanceMap.containsKey(binding)) {
return (IBinding) instanceMap.get(binding);
} else if (!(binding instanceof ICPPClassTemplatePartialSpecialization)) {
IBinding spec = CPPTemplates.createSpecialization(this, binding, specialization().getArgumentMap());
if (instanceMap == ObjectMap.EMPTY_MAP)
instanceMap = new ObjectMap(2);
instanceMap.put(binding, spec);
return spec;
}
return null;
}
private ObjectMap instanceMap = ObjectMap.EMPTY_MAP;
}

View file

@ -0,0 +1,87 @@
/*******************************************************************************
* Copyright (c) 2008 Google, Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
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.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
/**
* @author Sergey Prigogin
*/
class CompositeCPPUnknownClassInstance extends CompositeCPPUnknownClassType
implements ICPPInternalUnknownClassInstance {
public CompositeCPPUnknownClassInstance(ICompositesFactory cf,
ICPPInternalUnknownClassInstance rbinding) {
super(cf, rbinding);
}
public IType[] getArguments() {
IType[] arguments = ((ICPPInternalUnknownClassInstance) rbinding).getArguments();
try {
for (int i = 0; i < arguments.length; i++) {
arguments[i] = cf.getCompositeType((IIndexType) arguments[i]);
}
} catch (DOMException e) {
CCorePlugin.log(e);
}
return arguments;
}
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException {
return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY;
}
public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
return ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY;
}
public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) {
}
public void addSpecialization(IType[] arguments, ICPPSpecialization specialization) {
}
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
return InternalTemplateInstantiatorUtil.deferredInstance(argMap, arguments, cf, rbinding);
}
public ICPPSpecialization getInstance(IType[] arguments) {
return InternalTemplateInstantiatorUtil.getInstance(arguments, cf, this);
}
public IBinding instantiate(IType[] args) {
return InternalTemplateInstantiatorUtil.instantiate(args, cf, rbinding);
}
@Override
public IBinding resolveUnknown(ObjectMap argMap) throws DOMException {
IBinding result = super.resolveUnknown(argMap);
if (result instanceof ICPPSpecialization && result instanceof ICPPTemplateDefinition) {
IType[] newArgs = CPPTemplates.instantiateTypes(getArguments(), argMap);
IBinding instance = CPPTemplates.instantiateTemplate((ICPPTemplateDefinition) result, newArgs, null);
if (instance != null) {
result = instance;
}
}
return result;
}
}

View file

@ -0,0 +1,207 @@
/*******************************************************************************
* Copyright (c) 2008 Google, Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IField;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
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.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.index.IIndexBinding;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.core.runtime.CoreException;
/**
* @author Sergey Prigogin
*/
class CompositeCPPUnknownClassType extends CompositeCPPBinding
implements ICPPInternalUnknownClassType, IIndexType {
public CompositeCPPUnknownClassType(ICompositesFactory cf, ICPPInternalUnknownClassType rbinding) {
super(cf, rbinding);
}
@Override
public Object clone() {
fail(); return null;
}
public IField findField(String name) throws DOMException {
IField preResult = ((ICPPClassType) rbinding).findField(name);
return (IField) cf.getCompositeBinding((IIndexFragmentBinding)preResult);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases()
*/
public ICPPBase[] getBases() {
return ICPPBase.EMPTY_BASE_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
*/
public IField[] getFields() {
return IField.EMPTY_FIELD_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredFields()
*/
public ICPPField[] getDeclaredFields() {
return ICPPField.EMPTY_CPPFIELD_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getMethods()
*/
public ICPPMethod[] getMethods() {
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getAllDeclaredMethods()
*/
public ICPPMethod[] getAllDeclaredMethods() {
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredMethods()
*/
public ICPPMethod[] getDeclaredMethods() {
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getConstructors()
*/
public ICPPConstructor[] getConstructors() {
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFriends()
*/
public IBinding[] getFriends() {
return IBinding.EMPTY_BINDING_ARRAY;
}
public ICPPClassType[] getNestedClasses() throws DOMException {
ICPPClassType[] result = ((ICPPClassType) rbinding).getNestedClasses();
for (int i = 0; i < result.length; i++) {
result[i] = (ICPPClassType) cf.getCompositeBinding((IIndexFragmentBinding) result[i]);
}
return result;
}
public IScope getCompositeScope() throws DOMException {
return new CompositeCPPClassScope(cf, rbinding);
}
public int getKey() throws DOMException {
return ((ICPPClassType) rbinding).getKey();
}
public boolean isSameType(IType type) {
return ((ICPPClassType) rbinding).isSameType(type);
}
public ICPPScope getUnknownScope() {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap)
*/
public IBinding resolveUnknown(ObjectMap argMap) throws DOMException {
IBinding result = this;
IType t = null;
try {
if(rbinding instanceof PDOMBinding) {
IIndexFragmentBinding tparentBinding = (IIndexFragmentBinding) ((PDOMBinding) rbinding).getParentBinding();
IIndexBinding parentBinding= cf.getCompositeBinding(tparentBinding);
if (parentBinding instanceof ICPPTemplateTypeParameter) {
t = CPPTemplates.instantiateType((ICPPTemplateTypeParameter) parentBinding, argMap);
} else if (parentBinding instanceof ICPPInternalUnknownClassType) {
IBinding binding = ((ICPPInternalUnknownClassType) parentBinding).resolveUnknown(argMap);
if (binding instanceof IType) {
t = (IType) binding;
}
}
}
if (t != null) {
t = SemanticUtil.getUltimateType(t, false);
if (t instanceof ICPPClassType) {
IScope s = ((ICPPClassType) t).getCompositeScope();
if (s != null && ASTInternal.isFullyCached(s)) {
IBinding[] bindings = s.find(getName());
if (bindings != null && bindings.length > 0) {
result = bindings[0];
}
}
} else if (t instanceof ICPPInternalUnknown) {
result = resolvePartially((ICPPInternalUnknown) t, argMap);
}
}
} catch(CoreException ce) {
CCorePlugin.log(ce);
}
return result;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType#resolvePartially(org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown, org.eclipse.cdt.core.parser.util.ObjectMap)
*/
public IBinding resolvePartially(ICPPInternalUnknown parentBinding, ObjectMap argMap) {
return ((ICPPInternalUnknownClassType) rbinding).resolvePartially(parentBinding, argMap);
}
public void addDeclaration(IASTNode node) {
}
public void addDefinition(IASTNode node) {
}
public IASTNode[] getDeclarations() {
return null;
}
public IASTNode getDefinition() {
return null;
}
public void removeDeclaration(IASTNode node) {
}
}

View file

@ -71,7 +71,10 @@ import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal; import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType; import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
@ -410,9 +413,17 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} else if (binding instanceof ICPPFunction) { } else if (binding instanceof ICPPFunction) {
pdomBinding = new PDOMCPPFunction(pdom, parent, (ICPPFunction) binding, true); pdomBinding = new PDOMCPPFunction(pdom, parent, (ICPPFunction) binding, true);
} else if (binding instanceof ICPPClassTemplate) { } else if (binding instanceof ICPPClassTemplate) {
if (binding instanceof ICPPInternalUnknownClassInstance) {
pdomBinding= new PDOMCPPUnknownClassInstance(pdom, parent, (ICPPInternalUnknownClassInstance) binding);
} else {
pdomBinding= new PDOMCPPClassTemplate(pdom, parent, (ICPPClassTemplate) binding); pdomBinding= new PDOMCPPClassTemplate(pdom, parent, (ICPPClassTemplate) binding);
}
} else if (binding instanceof ICPPClassType) { } else if (binding instanceof ICPPClassType) {
if (binding instanceof ICPPInternalUnknown) {
pdomBinding= new PDOMCPPUnknownClassType(pdom, parent, (ICPPInternalUnknownClassType) binding);
} else {
pdomBinding= new PDOMCPPClassType(pdom, parent, (ICPPClassType) binding); pdomBinding= new PDOMCPPClassType(pdom, parent, (ICPPClassType) binding);
}
} else if (binding instanceof ICPPNamespaceAlias) { } else if (binding instanceof ICPPNamespaceAlias) {
pdomBinding = new PDOMCPPNamespaceAlias(pdom, parent, (ICPPNamespaceAlias) binding); pdomBinding = new PDOMCPPNamespaceAlias(pdom, parent, (ICPPNamespaceAlias) binding);
} else if (binding instanceof ICPPNamespace) { } else if (binding instanceof ICPPNamespace) {
@ -489,6 +500,12 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} else if (binding instanceof ICPPClassType) { } else if (binding instanceof ICPPClassType) {
return CPP_DEFERRED_CLASS_INSTANCE; return CPP_DEFERRED_CLASS_INSTANCE;
} }
} else if (binding instanceof ICPPInternalUnknown) {
if (binding instanceof ICPPInternalUnknownClassInstance) {
return CPP_UNKNOWN_CLASS_INSTANCE;
} else if (binding instanceof ICPPInternalUnknownClassType) {
return CPP_UNKNOWN_CLASS_TYPE;
}
} else if (binding instanceof ICPPTemplateInstance) { } else if (binding instanceof ICPPTemplateInstance) {
if (binding instanceof ICPPConstructor) { if (binding instanceof ICPPConstructor) {
return CPP_CONSTRUCTOR_INSTANCE; return CPP_CONSTRUCTOR_INSTANCE;
@ -594,6 +611,14 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return CPPFindBinding.findBinding(((PDOMCPPNamespace)parent).getIndex(), this, binding, return CPPFindBinding.findBinding(((PDOMCPPNamespace)parent).getIndex(), this, binding,
localToFileRec); localToFileRec);
} }
// TODO(sprigogin): Hack. There should be a better way to adapt unknown bindings.
if (parent instanceof ICPPInternalUnknown) {
if (binding instanceof ICPPInternalUnknownClassInstance) {
return new PDOMCPPUnknownClassInstance(getPDOM(), parent, (ICPPInternalUnknownClassInstance) binding);
} else if (binding instanceof ICPPInternalUnknownClassType) {
return new PDOMCPPUnknownClassType(getPDOM(), parent, (ICPPInternalUnknownClassType) binding);
}
}
if (parent instanceof IPDOMMemberOwner) { if (parent instanceof IPDOMMemberOwner) {
int localToFileRec= getLocalToFileRec(parent, binding); int localToFileRec= getLocalToFileRec(parent, binding);
return CPPFindBinding.findBinding(parent, this, binding, localToFileRec); return CPPFindBinding.findBinding(parent, this, binding, localToFileRec);
@ -650,10 +675,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (scope instanceof IIndexScope) { if (scope instanceof IIndexScope) {
if (scope instanceof CompositeScope) { // we special case for performance if (scope instanceof CompositeScope) { // we special case for performance
return addaptOrAddBinding(addParent, ((CompositeScope)scope).getRawScopeBinding()); return addaptOrAddBinding(addParent, ((CompositeScope) scope).getRawScopeBinding());
} else {
return addaptOrAddBinding(addParent, ((IIndexScope) scope).getScopeBinding());
} }
return addaptOrAddBinding(addParent, ((IIndexScope) scope).getScopeBinding());
} }
// the scope is from the ast // the scope is from the ast
@ -683,6 +707,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} else { } else {
if (scope instanceof ICPPClassScope) { if (scope instanceof ICPPClassScope) {
scopeBinding = ((ICPPClassScope)scope).getClassType(); scopeBinding = ((ICPPClassScope)scope).getClassType();
} else if (scope instanceof ICPPInternalUnknownScope) {
scopeBinding = ((ICPPInternalUnknownScope) scope).getScopeBinding();
} else { } else {
IName scopeName = scope.getScopeName(); IName scopeName = scope.getScopeName();
if (scopeName instanceof IASTName) { if (scopeName instanceof IASTName) {
@ -691,9 +717,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} }
} }
} }
if (scopeBinding != null && scopeBinding != binding) if (scopeBinding != null && scopeBinding != binding) {
return addaptOrAddBinding(addParent, scopeBinding); return addaptOrAddBinding(addParent, scopeBinding);
}
} catch (DOMException e) { } catch (DOMException e) {
throw new CoreException(Util.createStatus(e)); throw new CoreException(Util.createStatus(e));
} }
@ -830,6 +856,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return new PDOMCPPClassInstance(pdom, record); return new PDOMCPPClassInstance(pdom, record);
case CPP_DEFERRED_CLASS_INSTANCE: case CPP_DEFERRED_CLASS_INSTANCE:
return new PDOMCPPDeferredClassInstance(pdom, record); return new PDOMCPPDeferredClassInstance(pdom, record);
case CPP_UNKNOWN_CLASS_TYPE:
return new PDOMCPPUnknownClassType(pdom, record);
case CPP_UNKNOWN_CLASS_INSTANCE:
return new PDOMCPPUnknownClassInstance(pdom, record);
case CPP_TEMPLATE_TYPE_PARAMETER: case CPP_TEMPLATE_TYPE_PARAMETER:
return new PDOMCPPTemplateTypeParameter(pdom, record); return new PDOMCPPTemplateTypeParameter(pdom, record);
// TODO other template parameter types // TODO other template parameter types

View file

@ -8,17 +8,23 @@
* Contributors: * Contributors:
* QNX - Initial API and implementation * QNX - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Sergey Prigogin (Google)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp; package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.ITypedef;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
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.ICPPTemplateTypeParameter;
import org.eclipse.cdt.core.parser.util.ObjectMap;
import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.Util;
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants; import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexInternalTemplateParameter; import org.eclipse.cdt.internal.core.index.IIndexInternalTemplateParameter;
import org.eclipse.cdt.internal.core.index.IIndexType; import org.eclipse.cdt.internal.core.index.IIndexType;
@ -28,10 +34,9 @@ import org.eclipse.core.runtime.CoreException;
/** /**
* @author Bryan Wilkinson * @author Bryan Wilkinson
*
*/ */
class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements
ICPPTemplateTypeParameter, IIndexType, IIndexInternalTemplateParameter { ICPPTemplateTypeParameter, ICPPInternalUnknown, IIndexType, IIndexInternalTemplateParameter {
private static final int DEFAULT_TYPE = PDOMCPPBinding.RECORD_SIZE + 0; private static final int DEFAULT_TYPE = PDOMCPPBinding.RECORD_SIZE + 0;
@ -88,7 +93,7 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements
ICPPTemplateTypeParameter ttp= (ICPPTemplateTypeParameter) type; ICPPTemplateTypeParameter ttp= (ICPPTemplateTypeParameter) type;
try { try {
char[][] ttpName= ttp.getQualifiedNameCharArray(); char[][] ttpName= ttp.getQualifiedNameCharArray();
return hasQualifiedName(ttpName, ttpName.length-1); return hasQualifiedName(ttpName, ttpName.length - 1);
} catch (DOMException e) { } catch (DOMException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
} }
@ -113,5 +118,29 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements
} }
@Override @Override
public Object clone() { fail();return null; } public Object clone() { fail(); return null; }
public ICPPScope getUnknownScope() {
return null;
}
public IBinding resolveUnknown(ObjectMap argMap) { fail(); return null; }
public void addDeclaration(IASTNode node) {
}
public void addDefinition(IASTNode node) {
}
public IASTNode[] getDeclarations() {
return IASTNode.EMPTY_NODE_ARRAY;
}
public IASTNode getDefinition() {
return null;
}
public void removeDeclaration(IASTNode node) {
}
} }

View file

@ -0,0 +1,179 @@
/*******************************************************************************
* Copyright (c) 2008 Google, Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOMNode;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
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.ObjectMap;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPDeferredClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassInstance;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
/**
* @author Sergey Prigogin
*/
class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType
implements ICPPInternalUnknownClassInstance {
private static final int ARGUMENTS = PDOMCPPUnknownClassType.RECORD_SIZE + 0;
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPUnknownClassType.RECORD_SIZE + 4;
// Cached values.
IType[] arguments;
public PDOMCPPUnknownClassInstance(PDOM pdom, PDOMNode parent,
ICPPInternalUnknownClassInstance classInstance) throws CoreException {
super(pdom, parent, classInstance);
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
IType[] args = classInstance.getArguments();
for (int i = 0; i < args.length; i++) {
PDOMNode typeNode = getLinkageImpl().addType(this, args[i]);
if (typeNode != null)
list.addMember(typeNode);
}
}
public PDOMCPPUnknownClassInstance(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
}
@Override
protected int getRecordSize() {
return RECORD_SIZE;
}
@Override
public int getNodeType() {
return IIndexCPPBindingConstants.CPP_UNKNOWN_CLASS_INSTANCE;
}
private static class TemplateArgumentCollector implements IPDOMVisitor {
private List<IType> args = new ArrayList<IType>();
public boolean visit(IPDOMNode node) throws CoreException {
if (node instanceof IType)
args.add((IType) node);
return false;
}
public void leave(IPDOMNode node) throws CoreException {
}
public IType[] getTemplateArguments() {
return args.toArray(new IType[args.size()]);
}
}
public IType[] getArguments() {
if (arguments == null) {
try {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
TemplateArgumentCollector visitor = new TemplateArgumentCollector();
list.accept(visitor);
arguments = visitor.getTemplateArguments();
} catch (CoreException e) {
CCorePlugin.log(e);
return IType.EMPTY_TYPE_ARRAY;
}
}
return arguments;
}
public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations()
throws DOMException {
return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY;
}
public ICPPTemplateParameter[] getTemplateParameters() throws DOMException {
return ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY;
}
public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) {
}
public void addSpecialization(IType[] arguments, ICPPSpecialization specialization) {
}
public ICPPSpecialization deferredInstance(ObjectMap argMap, IType[] arguments) {
ICPPSpecialization instance = getInstance(arguments);
if (instance == null) {
instance = new CPPDeferredClassInstance(this, argMap, arguments);
addSpecialization(arguments, instance);
}
return instance;
}
public ICPPSpecialization getInstance(IType[] arguments) {
return null;
}
public IBinding instantiate(IType[] arguments) {
return deferredInstance(null, arguments);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap)
*/
@Override
public IBinding resolveUnknown(ObjectMap argMap) throws DOMException {
IBinding result = super.resolveUnknown(argMap);
if (result instanceof ICPPSpecialization && result instanceof ICPPTemplateDefinition) {
IType[] newArgs = CPPTemplates.instantiateTypes(getArguments(), argMap);
IBinding instance = CPPTemplates.instantiateTemplate((ICPPTemplateDefinition) result, newArgs, null);
if (instance != null) {
result = instance;
}
}
return result;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType#resolvePartially(org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown, org.eclipse.cdt.core.parser.util.ObjectMap)
*/
@Override
public IBinding resolvePartially(ICPPInternalUnknown parentBinding, ObjectMap argMap) {
IType[] arguments = getArguments();
IType[] newArgs = CPPTemplates.instantiateTypes(arguments, argMap);
if (parentBinding instanceof PDOMNode && isChildOf((PDOMNode) parentBinding) &&
Arrays.equals(newArgs, arguments)) {
return this;
}
IASTName name = new CPPASTName(getNameCharArray());
return new CPPUnknownClassInstance(parentBinding, name, newArgs);
}
@Override
public String toString() {
return getName() + " <" + ASTTypeUtil.getTypeListString(getArguments()) + ">"; //$NON-NLS-1$ //$NON-NLS-2$
}
}

View file

@ -0,0 +1,350 @@
/*******************************************************************************
* Copyright (c) 2008 Google, Inc and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Sergey Prigogin (Google) - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.IPDOMVisitor;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
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.IField;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
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.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.index.IIndexBinding;
import org.eclipse.cdt.core.index.IIndexFileSet;
import org.eclipse.cdt.core.parser.util.ObjectMap;
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.CPPASTName;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClass;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown;
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
import org.eclipse.cdt.internal.core.index.IIndexScope;
import org.eclipse.cdt.internal.core.index.IIndexType;
import org.eclipse.cdt.internal.core.pdom.PDOM;
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
import org.eclipse.core.runtime.CoreException;
/**
* @author Sergey Prigogin
*/
class PDOMCPPUnknownClassType extends PDOMCPPBinding implements ICPPClassScope, ICPPInternalUnknownClassType,
IPDOMMemberOwner, IIndexType, IIndexScope {
private static final int FIRSTBASE = PDOMCPPBinding.RECORD_SIZE + 0;
private static final int KEY = PDOMCPPBinding.RECORD_SIZE + 4; // byte
private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 8;
@SuppressWarnings("hiding")
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 12;
public PDOMCPPUnknownClassType(PDOM pdom, PDOMNode parent, ICPPInternalUnknownClassType classType)
throws CoreException {
super(pdom, parent, classType.getNameCharArray());
setKind(classType);
// linked list is initialized by storage being zero'd by malloc
}
public PDOMCPPUnknownClassType(PDOM pdom, int bindingRecord) {
super(pdom, bindingRecord);
}
@Override
public void update(PDOMLinkage linkage, IBinding newBinding) throws CoreException {
if (newBinding instanceof ICPPClassType) {
ICPPClassType ct= (ICPPClassType) newBinding;
setKind(ct);
super.update(linkage, newBinding);
}
}
private void setKind(ICPPClassType ct) throws CoreException {
try {
pdom.getDB().putByte(record + KEY, (byte) ct.getKey());
} catch (DOMException e) {
throw new CoreException(Util.createStatus(e));
}
}
public void addMember(PDOMNode member) throws CoreException {
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
list.addMember(member);
}
@Override
protected int getRecordSize() {
return RECORD_SIZE;
}
@Override
public int getNodeType() {
return IIndexCPPBindingConstants.CPP_UNKNOWN_CLASS_TYPE;
}
public PDOMCPPBase getFirstBase() throws CoreException {
int rec = pdom.getDB().getInt(record + FIRSTBASE);
return rec != 0 ? new PDOMCPPBase(pdom, rec) : null;
}
private void setFirstBase(PDOMCPPBase base) throws CoreException {
int rec = base != null ? base.getRecord() : 0;
pdom.getDB().putInt(record + FIRSTBASE, rec);
}
public void addBase(PDOMCPPBase base) throws CoreException {
PDOMCPPBase firstBase = getFirstBase();
base.setNextBase(firstBase);
setFirstBase(base);
}
@Override
public void accept(IPDOMVisitor visitor) throws CoreException {
super.accept(visitor);
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
list.accept(visitor);
}
public ICPPMethod[] getImplicitMethods() {
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
public IScope getCompositeScope() throws DOMException {
return this;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#getUnknownScope()
*/
public ICPPScope getUnknownScope() { fail(); return null; }
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.index.IIndexScope#getScopeBinding()
*/
public IIndexBinding getScopeBinding() {
return this;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified()
*/
@Override
public boolean isGloballyQualified() throws DOMException {
try {
return getParentNode() instanceof PDOMLinkage;
} catch (CoreException e) {
return true;
}
}
public ICPPClassType getClassType() {
return this;
}
@Override
public void addChild(PDOMNode member) throws CoreException {
addMember(member);
}
public boolean isFullyCached() {
return true;
}
@Override
public IBinding getBinding(IASTName name, boolean resolve, IIndexFileSet fileSet) throws DOMException {
return null;
}
@Override
public IBinding[] getBindings(IASTName name, boolean resolve, boolean prefixLookup, IIndexFileSet fileSet)
throws DOMException {
return IBinding.EMPTY_BINDING_ARRAY;
}
public IBinding[] find(String name) throws DOMException {
return CPPSemantics.findBindings(this, name, false);
}
// Not implemented
@Override
public Object clone() { fail(); return null; }
public IField findField(String name) throws DOMException { fail(); return null; }
@Override
public boolean mayHaveChildren() {
return true;
}
public void removeBase(PDOMName pdomName) throws CoreException {
}
public void addDeclaration(IASTNode node) {
}
public void addDefinition(IASTNode node) {
}
public IASTNode[] getDeclarations() {
return null;
}
public IASTNode getDefinition() {
return null;
}
public void removeDeclaration(IASTNode node) {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getBases()
*/
public ICPPBase[] getBases() {
return ICPPBase.EMPTY_BASE_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getFields()
*/
public IField[] getFields() {
return IField.EMPTY_FIELD_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredFields()
*/
public ICPPField[] getDeclaredFields() {
return ICPPField.EMPTY_CPPFIELD_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getMethods()
*/
public ICPPMethod[] getMethods() {
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getAllDeclaredMethods()
*/
public ICPPMethod[] getAllDeclaredMethods() {
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getDeclaredMethods()
*/
public ICPPMethod[] getDeclaredMethods() {
return ICPPMethod.EMPTY_CPPMETHOD_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getConstructors()
*/
public ICPPConstructor[] getConstructors() {
return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType#getFriends()
*/
public IBinding[] getFriends() {
return IBinding.EMPTY_BINDING_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.ICompositeType#getKey()
*/
public int getKey() {
return 0;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IType#isSameType(org.eclipse.cdt.core.dom.ast.IType)
*/
public boolean isSameType(IType type) {
return type == this;
}
public ICPPClassType[] getNestedClasses() {
return ICPPClassType.EMPTY_CLASS_ARRAY;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown#resolveUnknown(org.eclipse.cdt.core.parser.util.ObjectMap)
*/
public IBinding resolveUnknown(ObjectMap argMap) throws DOMException {
IBinding result = this;
try {
IIndexBinding parentBinding = getParentBinding();
IType t = null;
if (parentBinding instanceof ICPPTemplateTypeParameter) {
t = CPPTemplates.instantiateType((ICPPTemplateTypeParameter) parentBinding, argMap);
} else if (parentBinding instanceof ICPPInternalUnknownClassType) {
IBinding binding = ((ICPPInternalUnknownClassType) parentBinding).resolveUnknown(argMap);
if (binding instanceof IType) {
t = (IType) binding;
}
}
if (t != null) {
t = SemanticUtil.getUltimateType(t, false);
if (t instanceof ICPPClassType) {
IScope s = ((ICPPClassType) t).getCompositeScope();
if (s != null && ASTInternal.isFullyCached(s)) {
IBinding[] bindings = s.find(getName());
if (bindings != null && bindings.length > 0) {
result = bindings[0];
}
}
} else if (t instanceof ICPPInternalUnknown) {
result = resolvePartially((ICPPInternalUnknown) t, argMap);
}
}
} catch (CoreException e) {
}
return result;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownClassType#resolvePartially(org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown, org.eclipse.cdt.core.parser.util.ObjectMap)
*/
public IBinding resolvePartially(ICPPInternalUnknown parentBinding, ObjectMap argMap) {
try {
if (parentBinding == getParentBinding()) {
return this;
}
} catch (CoreException e) {
}
IASTName name = new CPPASTName(getNameCharArray());
return new CPPUnknownClass(parentBinding, name);
}
@Override
public String toString() {
return ASTTypeUtil.getType(this);
}
}