mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Partial fix for bug 214017.
This commit is contained in:
parent
b45f93e8ce
commit
b30c89a812
16 changed files with 1141 additions and 120 deletions
|
@ -236,35 +236,37 @@ abstract public class CPPScope implements ICPPScope, IASTInternalScope {
|
|||
IBinding[] result = getBindingsInAST(name, resolve, prefixLookup);
|
||||
|
||||
final IASTTranslationUnit tu = name.getTranslationUnit();
|
||||
IIndex index = tu.getIndex();
|
||||
if (index != null) {
|
||||
if (physicalNode instanceof IASTTranslationUnit) {
|
||||
try {
|
||||
IndexFilter filter = IndexFilter.CPP_DECLARED_OR_IMPLICIT;
|
||||
IBinding[] bindings = prefixLookup ?
|
||||
index.findBindingsForPrefix(name.toCharArray(), true, filter, null) :
|
||||
index.findBindings(name.toCharArray(), filter, null);
|
||||
if (fileSet != null) {
|
||||
bindings= fileSet.filterFileLocalBindings(bindings);
|
||||
}
|
||||
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, bindings);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
} else if (physicalNode instanceof ICPPASTNamespaceDefinition) {
|
||||
ICPPASTNamespaceDefinition ns = (ICPPASTNamespaceDefinition) physicalNode;
|
||||
try {
|
||||
IIndexBinding binding = index.findBinding(ns.getName());
|
||||
if (binding instanceof ICPPNamespace) {
|
||||
ICPPNamespaceScope indexNs = ((ICPPNamespace)binding).getNamespaceScope();
|
||||
IBinding[] bindings = indexNs.getBindings(name, resolve, prefixLookup);
|
||||
if (tu != null) {
|
||||
IIndex index = tu.getIndex();
|
||||
if (index != null) {
|
||||
if (physicalNode instanceof IASTTranslationUnit) {
|
||||
try {
|
||||
IndexFilter filter = IndexFilter.CPP_DECLARED_OR_IMPLICIT;
|
||||
IBinding[] bindings = prefixLookup ?
|
||||
index.findBindingsForPrefix(name.toCharArray(), true, filter, null) :
|
||||
index.findBindings(name.toCharArray(), filter, null);
|
||||
if (fileSet != null) {
|
||||
bindings= fileSet.filterFileLocalBindings(bindings);
|
||||
}
|
||||
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, bindings);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
} else if (physicalNode instanceof ICPPASTNamespaceDefinition) {
|
||||
ICPPASTNamespaceDefinition ns = (ICPPASTNamespaceDefinition) physicalNode;
|
||||
try {
|
||||
IIndexBinding binding = index.findBinding(ns.getName());
|
||||
if (binding instanceof ICPPNamespace) {
|
||||
ICPPNamespaceScope indexNs = ((ICPPNamespace)binding).getNamespaceScope();
|
||||
IBinding[] bindings = indexNs.getBindings(name, resolve, prefixLookup);
|
||||
if (fileSet != null) {
|
||||
bindings= fileSet.filterFileLocalBindings(bindings);
|
||||
}
|
||||
result = (IBinding[]) ArrayUtil.addAll(IBinding.class, result, bindings);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,8 +108,19 @@ public abstract class CPPUnknownBinding extends PlatformObject
|
|||
t = SemanticUtil.getUltimateType(t, false);
|
||||
if (t instanceof ICPPClassType) {
|
||||
IScope s = ((ICPPClassType) t).getCompositeScope();
|
||||
if (s != null && ASTInternal.isFullyCached(s))
|
||||
result = s.getBinding(name, true);
|
||||
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);
|
||||
} else {
|
||||
IBinding[] bindings = s.find(name.toString());
|
||||
if (bindings != null && bindings.length > 0) {
|
||||
result = bindings[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (t instanceof ICPPInternalUnknown) {
|
||||
result = resolvePartially((ICPPInternalUnknown) t, argMap);
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.eclipse.cdt.core.parser.util.ObjectMap;
|
|||
*/
|
||||
public class CPPUnknownClass extends CPPUnknownBinding implements ICPPInternalUnknownClassType {
|
||||
|
||||
|
||||
public CPPUnknownClass(ICPPInternalUnknown scopeBinding, IASTName name) {
|
||||
super(scopeBinding, name);
|
||||
}
|
||||
|
|
|
@ -11,10 +11,6 @@
|
|||
* Bryan Wilkinson (QNX)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
|
||||
/*
|
||||
* Created on May 3, 2005
|
||||
*/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
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.CharArrayObjectMap;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPUnknownScope implements ICPPScope, IASTInternalScope {
|
||||
public class CPPUnknownScope implements ICPPScope, ICPPInternalUnknownScope {
|
||||
private final ICPPInternalUnknown binding;
|
||||
private final IASTName scopeName;
|
||||
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
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope#getUnknownBinding()
|
||||
*/
|
||||
public ICPPInternalUnknown getScopeBinding() {
|
||||
return binding;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* For debug purposes only
|
||||
*/
|
||||
|
|
|
@ -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();
|
||||
}
|
|
@ -2338,7 +2338,7 @@ public class CPPSemantics {
|
|||
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();
|
||||
astName.setName( name );
|
||||
astName.setParent( ASTInternal.getPhysicalNodeOfScope(scope));
|
||||
|
|
|
@ -56,4 +56,6 @@ public interface IIndexCPPBindingConstants {
|
|||
int CPP_FUNCTION_TYPE= IIndexBindingConstants.LAST_CONSTANT + 39;
|
||||
int GPPBASICTYPE = IIndexBindingConstants.LAST_CONSTANT + 40;
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
|
@ -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.IIndexBinding;
|
||||
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.IIndexFragmentBinding;
|
||||
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.CompositeQualifierType;
|
||||
import org.eclipse.cdt.internal.core.index.composite.CompositingNotImplementedError;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class CPPCompositesFactory extends AbstractCompositeFactory implements ICompositesFactory {
|
||||
public class CPPCompositesFactory extends AbstractCompositeFactory {
|
||||
|
||||
public CPPCompositesFactory(IIndex index) {
|
||||
super(index);
|
||||
|
@ -75,22 +76,22 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
|
|||
IIndexScope result;
|
||||
|
||||
try {
|
||||
if(rscope == null) {
|
||||
if (rscope == null) {
|
||||
return null;
|
||||
} else if(rscope instanceof ICPPClassScope) {
|
||||
} else if (rscope instanceof ICPPClassScope) {
|
||||
ICPPClassScope classScope = (ICPPClassScope) rscope;
|
||||
result = new CompositeCPPClassScope(this,
|
||||
findOneBinding(classScope.getClassType()));
|
||||
} else if(rscope instanceof ICPPNamespaceScope) {
|
||||
} else if (rscope instanceof ICPPNamespaceScope) {
|
||||
ICPPNamespace[] namespaces;
|
||||
if(rscope instanceof CompositeCPPNamespace) {
|
||||
if (rscope instanceof CompositeCPPNamespace) {
|
||||
// avoid duplicating the search
|
||||
namespaces = ((CompositeCPPNamespace)rscope).namespaces;
|
||||
} else {
|
||||
namespaces = getNamespaces(rscope.getScopeBinding());
|
||||
}
|
||||
return new CompositeCPPNamespaceScope(this, namespaces);
|
||||
} else if(rscope instanceof ICPPTemplateScope) {
|
||||
} else if (rscope instanceof ICPPTemplateScope) {
|
||||
return new CompositeCPPTemplateScope(this, (ICPPTemplateScope) rscope);
|
||||
} else {
|
||||
throw new CompositingNotImplementedError(rscope.getClass().getName());
|
||||
|
@ -109,31 +110,31 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
|
|||
public IType getCompositeType(IIndexType rtype) throws DOMException {
|
||||
IType result;
|
||||
|
||||
if(rtype instanceof ICPPSpecialization) {
|
||||
if (rtype instanceof ICPPSpecialization) {
|
||||
result = (IIndexType) getCompositeBinding((IIndexFragmentBinding) rtype);
|
||||
} else if(rtype instanceof ICPPClassType) {
|
||||
} else if (rtype instanceof ICPPClassType) {
|
||||
result = (ICPPClassType) getCompositeBinding((IIndexFragmentBinding) rtype);
|
||||
} else if(rtype instanceof ITypedef) {
|
||||
} else if (rtype instanceof ITypedef) {
|
||||
result = new CompositeCPPTypedef(this, (ICPPBinding) rtype);
|
||||
} else if (rtype instanceof IEnumeration) {
|
||||
result = (IEnumeration) getCompositeBinding((IIndexFragmentBinding) rtype);
|
||||
} else if(rtype instanceof ICPPFunctionType) {
|
||||
} else if (rtype instanceof ICPPFunctionType) {
|
||||
result = new CompositeCPPFunctionType((ICPPFunctionType) rtype, this);
|
||||
} else if(rtype instanceof ICPPPointerToMemberType) {
|
||||
result = new CompositeCPPPointerToMemberType(this, (ICPPPointerToMemberType)rtype);
|
||||
} else if(rtype instanceof IPointerType) {
|
||||
result = new CompositePointerType((IPointerType)rtype, this);
|
||||
} else if(rtype instanceof ICPPReferenceType) {
|
||||
} else if (rtype instanceof ICPPPointerToMemberType) {
|
||||
result = new CompositeCPPPointerToMemberType(this, (ICPPPointerToMemberType) rtype);
|
||||
} else if (rtype instanceof IPointerType) {
|
||||
result = new CompositePointerType((IPointerType) rtype, this);
|
||||
} else if (rtype instanceof ICPPReferenceType) {
|
||||
result = new CompositeCPPReferenceType((ICPPReferenceType)rtype, this);
|
||||
} else if(rtype instanceof IQualifierType) {
|
||||
} else if (rtype instanceof IQualifierType) {
|
||||
result = new CompositeQualifierType((IQualifierType) rtype, this);
|
||||
} else if(rtype instanceof IArrayType) {
|
||||
} else if (rtype instanceof IArrayType) {
|
||||
result = new CompositeArrayType((IArrayType) rtype, this);
|
||||
} else if(rtype == null) {
|
||||
} else if (rtype == null) {
|
||||
result = null;
|
||||
} else if(rtype instanceof ICPPTemplateTypeParameter) {
|
||||
} else if (rtype instanceof ICPPTemplateTypeParameter) {
|
||||
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
|
||||
} else {
|
||||
throw new CompositingNotImplementedError();
|
||||
|
@ -142,12 +143,11 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
private ICPPNamespace[] getNamespaces(IBinding rbinding) throws CoreException {
|
||||
CIndex cindex = (CIndex) index;
|
||||
IIndexBinding[] ibs = cindex.findEquivalentBindings(rbinding);
|
||||
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];
|
||||
return namespaces;
|
||||
}
|
||||
|
@ -160,11 +160,6 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
|
|||
return super.findOneBinding(binding, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IIndexFragmentBinding findOneBinding(IBinding binding, boolean allowDeclaration) {
|
||||
return super.findOneBinding(binding, allowDeclaration);
|
||||
}
|
||||
|
||||
/* (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)
|
||||
*/
|
||||
|
@ -172,109 +167,113 @@ public class CPPCompositesFactory extends AbstractCompositeFactory implements IC
|
|||
IIndexBinding result;
|
||||
|
||||
try {
|
||||
if(binding==null) {
|
||||
if (binding == null) {
|
||||
result = null;
|
||||
} else if(binding instanceof ICPPSpecialization) {
|
||||
if(binding instanceof ICPPTemplateInstance) {
|
||||
if(binding instanceof ICPPDeferredTemplateInstance) {
|
||||
if(binding instanceof ICPPClassType) {
|
||||
} else if (binding instanceof ICPPSpecialization) {
|
||||
if (binding instanceof ICPPTemplateInstance) {
|
||||
if (binding instanceof ICPPDeferredTemplateInstance) {
|
||||
if (binding instanceof ICPPClassType) {
|
||||
return new CompositeCPPDeferredClassInstance(this, (ICPPClassType) findOneBinding(binding));
|
||||
} else if(binding instanceof ICPPFunction) {
|
||||
} else if (binding instanceof ICPPFunction) {
|
||||
return new CompositeCPPDeferredFunctionInstance(this, (ICPPFunction) binding);
|
||||
} else {
|
||||
throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} else {
|
||||
if(binding instanceof ICPPClassType) {
|
||||
if (binding instanceof ICPPClassType) {
|
||||
return new CompositeCPPClassInstance(this, (ICPPClassType) findOneBinding(binding));
|
||||
} else if(binding instanceof ICPPConstructor) {
|
||||
} else if (binding instanceof ICPPConstructor) {
|
||||
return new CompositeCPPConstructorInstance(this, (ICPPConstructor) binding);
|
||||
} else if(binding instanceof ICPPMethod) {
|
||||
} else if (binding instanceof ICPPMethod) {
|
||||
return new CompositeCPPMethodInstance(this, (ICPPMethod) binding);
|
||||
} else if(binding instanceof ICPPFunction) {
|
||||
} else if (binding instanceof ICPPFunction) {
|
||||
return new CompositeCPPFunctionInstance(this, (ICPPFunction) binding);
|
||||
} else {
|
||||
throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
} else if (binding instanceof ICPPTemplateDefinition) {
|
||||
if(binding instanceof ICPPClassTemplatePartialSpecialization) {
|
||||
if (binding instanceof ICPPClassTemplatePartialSpecialization) {
|
||||
return new CompositeCPPClassTemplatePartialSpecialization(this, (ICPPClassTemplatePartialSpecialization) binding);
|
||||
} else if(binding instanceof ICPPClassType) {
|
||||
} else if (binding instanceof ICPPClassType) {
|
||||
return new CompositeCPPClassTemplateSpecialization(this, (ICPPClassType) binding);
|
||||
} else if(binding instanceof ICPPConstructor) {
|
||||
} else if (binding instanceof ICPPConstructor) {
|
||||
return new CompositeCPPConstructorTemplateSpecialization(this, (ICPPConstructor) binding);
|
||||
} else if(binding instanceof ICPPMethod) {
|
||||
} else if (binding instanceof ICPPMethod) {
|
||||
return new CompositeCPPMethodTemplateSpecialization(this, (ICPPMethod) binding);
|
||||
} else if(binding instanceof ICPPFunctionType) {
|
||||
} else if (binding instanceof ICPPFunctionType) {
|
||||
return new CompositeCPPFunctionTemplateSpecialization(this, (ICPPFunction) binding);
|
||||
} else {
|
||||
throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} else {
|
||||
if(binding instanceof ICPPClassType) {
|
||||
if (binding instanceof ICPPClassType) {
|
||||
return new CompositeCPPClassSpecialization(this, (ICPPClassType) findOneBinding(binding));
|
||||
} if(binding instanceof ICPPConstructor) {
|
||||
} else if (binding instanceof ICPPConstructor) {
|
||||
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));
|
||||
} if(binding instanceof ICPPFunction) {
|
||||
} else if (binding instanceof ICPPFunction) {
|
||||
return new CompositeCPPFunctionSpecialization(this, (ICPPFunction) findOneBinding(binding, true));
|
||||
} if(binding instanceof ICPPField) {
|
||||
} else if (binding instanceof ICPPField) {
|
||||
return new CompositeCPPField(this, (ICPPField) binding);
|
||||
} if(binding instanceof ICPPParameter) {
|
||||
} else if (binding instanceof ICPPParameter) {
|
||||
return new CompositeCPPParameterSpecialization(this, (ICPPParameter) binding);
|
||||
} if(binding instanceof ITypedef) {
|
||||
} else if (binding instanceof ITypedef) {
|
||||
return new CompositeCPPTypedefSpecialization(this, (ICPPBinding) binding);
|
||||
} else {
|
||||
throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
} 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);
|
||||
return new CompositeCPPClassTemplate(this, def);
|
||||
} else if (binding instanceof ICPPConstructor) {
|
||||
return new CompositeCPPConstructorTemplate(this, (ICPPConstructor) binding);
|
||||
} else if (binding instanceof ICPPMethod) {
|
||||
return new CompositeCPPMethodTemplate(this, (ICPPMethod) binding);
|
||||
return new CompositeCPPMethodTemplate(this, (ICPPMethod) binding);
|
||||
} else if (binding instanceof ICPPFunctionTemplate) {
|
||||
return new CompositeCPPFunctionTemplate(this, (ICPPFunction) binding);
|
||||
} else {
|
||||
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);
|
||||
} else if(binding instanceof ICPPField) {
|
||||
} else if (binding instanceof ICPPField) {
|
||||
result = new CompositeCPPField(this, (ICPPField) binding);
|
||||
} else if(binding instanceof ICPPVariable) {
|
||||
} else if (binding instanceof ICPPVariable) {
|
||||
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);
|
||||
result = def == null ? null : new CompositeCPPClassType(this, def);
|
||||
} else if(binding instanceof ICPPConstructor) {
|
||||
} else if (binding instanceof ICPPConstructor) {
|
||||
result = new CompositeCPPConstructor(this, (ICPPConstructor) binding);
|
||||
} else if(binding instanceof ICPPMethod) {
|
||||
} else if (binding instanceof ICPPMethod) {
|
||||
result = new CompositeCPPMethod(this, (ICPPMethod) binding);
|
||||
} else if(binding instanceof ICPPNamespaceAlias) {
|
||||
} else if (binding instanceof ICPPNamespaceAlias) {
|
||||
result = new CompositeCPPNamespaceAlias(this, (ICPPNamespaceAlias) binding);
|
||||
} else if(binding instanceof ICPPNamespace) {
|
||||
} else if (binding instanceof ICPPNamespace) {
|
||||
ICPPNamespace[] ns = getNamespaces(binding);
|
||||
result = ns.length == 0 ? null : new CompositeCPPNamespace(this, ns);
|
||||
} else if (binding instanceof ICPPUsingDeclaration) {
|
||||
result = new CompositeCPPUsingDeclaration(this, (ICPPUsingDeclaration) binding);
|
||||
} else if(binding instanceof IEnumeration) {
|
||||
} else if (binding instanceof IEnumeration) {
|
||||
IEnumeration def = (IEnumeration) findOneBinding(binding);
|
||||
result = def == null ? null : new CompositeCPPEnumeration(this, def);
|
||||
} else if(binding instanceof ICPPFunction) {
|
||||
} else if (binding instanceof ICPPFunction) {
|
||||
result = new CompositeCPPFunction(this, (ICPPFunction) binding);
|
||||
} else if(binding instanceof IEnumerator) {
|
||||
} else if (binding instanceof IEnumerator) {
|
||||
result = new CompositeCPPEnumerator(this, (IEnumerator) binding);
|
||||
} else if(binding instanceof ITypedef) {
|
||||
} else if (binding instanceof ITypedef) {
|
||||
result = new CompositeCPPTypedef(this, (ICPPBinding) binding);
|
||||
} else if(binding instanceof ICPPTemplateTypeParameter) {
|
||||
} else if (binding instanceof ICPPTemplateTypeParameter) {
|
||||
result = new CompositeCPPTemplateTypeParameter(this, (ICPPTemplateTypeParameter) binding);
|
||||
} else if(binding instanceof IIndexMacroContainer) {
|
||||
} else if (binding instanceof IIndexMacroContainer) {
|
||||
result= new CompositeMacroContainer(this, binding);
|
||||
} else {
|
||||
throw new CompositingNotImplementedError("composite binding unavailable for "+binding+" "+binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
|
|
@ -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.parser.util.ObjectMap;
|
||||
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;
|
||||
|
||||
public class CompositeCPPClassInstance extends CompositeCPPClassType implements
|
||||
ICPPClassType, IIndexType, ICPPTemplateInstance, ICPPSpecialization {
|
||||
public class CompositeCPPClassInstance extends CompositeCPPClassType
|
||||
implements ICPPTemplateInstance, ICPPSpecialization {
|
||||
|
||||
public CompositeCPPClassInstance(ICompositesFactory cf, ICPPClassType rbinding) {
|
||||
super(cf, rbinding);
|
||||
|
@ -37,7 +36,7 @@ ICPPClassType, IIndexType, ICPPTemplateInstance, ICPPSpecialization {
|
|||
public ICPPMethod[] getDeclaredMethods() throws DOMException {
|
||||
ICPPClassType specialized = (ICPPClassType) getSpecializedBinding();
|
||||
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());
|
||||
}
|
||||
return bindings;
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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) {
|
||||
}
|
||||
}
|
|
@ -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.ProblemBinding;
|
||||
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.ICPPInternalUnknownScope;
|
||||
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.index.IIndexCPPBindingConstants;
|
||||
|
@ -410,9 +413,17 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
} else if (binding instanceof ICPPFunction) {
|
||||
pdomBinding = new PDOMCPPFunction(pdom, parent, (ICPPFunction) binding, true);
|
||||
} else if (binding instanceof ICPPClassTemplate) {
|
||||
pdomBinding= new PDOMCPPClassTemplate(pdom, parent, (ICPPClassTemplate) binding);
|
||||
if (binding instanceof ICPPInternalUnknownClassInstance) {
|
||||
pdomBinding= new PDOMCPPUnknownClassInstance(pdom, parent, (ICPPInternalUnknownClassInstance) binding);
|
||||
} else {
|
||||
pdomBinding= new PDOMCPPClassTemplate(pdom, parent, (ICPPClassTemplate) binding);
|
||||
}
|
||||
} else if (binding instanceof ICPPClassType) {
|
||||
pdomBinding= new PDOMCPPClassType(pdom, parent, (ICPPClassType) binding);
|
||||
if (binding instanceof ICPPInternalUnknown) {
|
||||
pdomBinding= new PDOMCPPUnknownClassType(pdom, parent, (ICPPInternalUnknownClassType) binding);
|
||||
} else {
|
||||
pdomBinding= new PDOMCPPClassType(pdom, parent, (ICPPClassType) binding);
|
||||
}
|
||||
} else if (binding instanceof ICPPNamespaceAlias) {
|
||||
pdomBinding = new PDOMCPPNamespaceAlias(pdom, parent, (ICPPNamespaceAlias) binding);
|
||||
} else if (binding instanceof ICPPNamespace) {
|
||||
|
@ -489,6 +500,12 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
} else if (binding instanceof ICPPClassType) {
|
||||
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) {
|
||||
if (binding instanceof ICPPConstructor) {
|
||||
return CPP_CONSTRUCTOR_INSTANCE;
|
||||
|
@ -594,6 +611,14 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
return CPPFindBinding.findBinding(((PDOMCPPNamespace)parent).getIndex(), this, binding,
|
||||
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) {
|
||||
int localToFileRec= getLocalToFileRec(parent, binding);
|
||||
return CPPFindBinding.findBinding(parent, this, binding, localToFileRec);
|
||||
|
@ -650,10 +675,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
|
||||
if (scope instanceof IIndexScope) {
|
||||
if (scope instanceof CompositeScope) { // we special case for performance
|
||||
return addaptOrAddBinding(addParent, ((CompositeScope)scope).getRawScopeBinding());
|
||||
} else {
|
||||
return addaptOrAddBinding(addParent, ((IIndexScope) scope).getScopeBinding());
|
||||
return addaptOrAddBinding(addParent, ((CompositeScope) scope).getRawScopeBinding());
|
||||
}
|
||||
return addaptOrAddBinding(addParent, ((IIndexScope) scope).getScopeBinding());
|
||||
}
|
||||
|
||||
// the scope is from the ast
|
||||
|
@ -683,6 +707,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
} else {
|
||||
if (scope instanceof ICPPClassScope) {
|
||||
scopeBinding = ((ICPPClassScope)scope).getClassType();
|
||||
} else if (scope instanceof ICPPInternalUnknownScope) {
|
||||
scopeBinding = ((ICPPInternalUnknownScope) scope).getScopeBinding();
|
||||
} else {
|
||||
IName scopeName = scope.getScopeName();
|
||||
if (scopeName instanceof IASTName) {
|
||||
|
@ -691,16 +717,16 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (scopeBinding != null && scopeBinding != binding)
|
||||
if (scopeBinding != null && scopeBinding != binding) {
|
||||
return addaptOrAddBinding(addParent, scopeBinding);
|
||||
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
throw new CoreException(Util.createStatus(e));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private PDOMBinding addaptOrAddBinding(boolean add, IBinding binding) throws CoreException {
|
||||
private PDOMBinding addaptOrAddBinding(boolean add, IBinding binding) throws CoreException {
|
||||
if (add)
|
||||
return addBinding(binding, null);
|
||||
|
||||
|
@ -830,6 +856,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
return new PDOMCPPClassInstance(pdom, record);
|
||||
case CPP_DEFERRED_CLASS_INSTANCE:
|
||||
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:
|
||||
return new PDOMCPPTemplateTypeParameter(pdom, record);
|
||||
// TODO other template parameter types
|
||||
|
|
|
@ -6,19 +6,25 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.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.IType;
|
||||
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.ICPPScope;
|
||||
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.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.IIndexInternalTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
|
@ -28,10 +34,9 @@ import org.eclipse.core.runtime.CoreException;
|
|||
|
||||
/**
|
||||
* @author Bryan Wilkinson
|
||||
*
|
||||
*/
|
||||
class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements
|
||||
ICPPTemplateTypeParameter, IIndexType, IIndexInternalTemplateParameter {
|
||||
ICPPTemplateTypeParameter, ICPPInternalUnknown, IIndexType, IIndexInternalTemplateParameter {
|
||||
|
||||
private static final int DEFAULT_TYPE = PDOMCPPBinding.RECORD_SIZE + 0;
|
||||
|
||||
|
@ -88,7 +93,7 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements
|
|||
ICPPTemplateTypeParameter ttp= (ICPPTemplateTypeParameter) type;
|
||||
try {
|
||||
char[][] ttpName= ttp.getQualifiedNameCharArray();
|
||||
return hasQualifiedName(ttpName, ttpName.length-1);
|
||||
return hasQualifiedName(ttpName, ttpName.length - 1);
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
|
@ -113,5 +118,29 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements
|
|||
}
|
||||
|
||||
@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) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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$
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue