mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Removes a workaround in PDOMCPPLinkage.getAdaptedParent().
This commit is contained in:
parent
9f420bc917
commit
4a256b8f16
7 changed files with 58 additions and 38 deletions
|
@ -234,7 +234,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
|||
}
|
||||
|
||||
public IASTName getUnknownName() {
|
||||
return null;
|
||||
return new CPPASTName(getNameCharArray());
|
||||
}
|
||||
|
||||
public ICPPUnknownBinding getUnknownContainerBinding() {
|
||||
|
|
|
@ -72,7 +72,7 @@ public class CPPTemplateTypeParameter extends CPPTemplateParameter implements
|
|||
}
|
||||
|
||||
public IASTName getUnknownName() {
|
||||
return null;
|
||||
return new CPPASTName(getNameCharArray());
|
||||
}
|
||||
|
||||
public ICPPUnknownBinding getUnknownContainerBinding() {
|
||||
|
|
|
@ -13,6 +13,7 @@ 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.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
@ -52,6 +53,7 @@ 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.ICPPInternalUnknownScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassType;
|
||||
import org.eclipse.cdt.internal.core.index.CIndex;
|
||||
|
@ -76,16 +78,15 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
* @see org.eclipse.cdt.internal.core.index.composite.cpp.ICompositesFactory#getCompositeScope(org.eclipse.cdt.core.index.IIndex, org.eclipse.cdt.core.dom.ast.IScope)
|
||||
*/
|
||||
public IIndexScope getCompositeScope(IIndexScope rscope) {
|
||||
IIndexScope result;
|
||||
|
||||
try {
|
||||
if (rscope == null) {
|
||||
return null;
|
||||
} else if (rscope instanceof ICPPClassScope) {
|
||||
}
|
||||
if (rscope instanceof ICPPClassScope) {
|
||||
ICPPClassScope classScope = (ICPPClassScope) rscope;
|
||||
result = new CompositeCPPClassScope(this,
|
||||
findOneBinding(classScope.getClassType()));
|
||||
} else if (rscope instanceof ICPPNamespaceScope) {
|
||||
return new CompositeCPPClassScope(this, findOneBinding(classScope.getClassType()));
|
||||
}
|
||||
if (rscope instanceof ICPPNamespaceScope) {
|
||||
ICPPNamespace[] namespaces;
|
||||
if (rscope instanceof CompositeCPPNamespace) {
|
||||
// avoid duplicating the search
|
||||
|
@ -94,17 +95,23 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
namespaces = getNamespaces(rscope.getScopeBinding());
|
||||
}
|
||||
return new CompositeCPPNamespaceScope(this, namespaces);
|
||||
} else if (rscope instanceof ICPPTemplateScope) {
|
||||
return new CompositeCPPTemplateScope(this, (ICPPTemplateScope) rscope);
|
||||
} else {
|
||||
throw new CompositingNotImplementedError(rscope.getClass().getName());
|
||||
}
|
||||
if (rscope instanceof ICPPTemplateScope) {
|
||||
return new CompositeCPPTemplateScope(this, (ICPPTemplateScope) rscope);
|
||||
}
|
||||
if (rscope instanceof ICPPInternalUnknownScope) {
|
||||
ICPPInternalUnknownScope uscope= (ICPPInternalUnknownScope) rscope;
|
||||
final ICPPBinding binding = uscope.getScopeBinding();
|
||||
return new CompositeCPPUnknownScope((CompositeCPPBinding) getCompositeBinding((IIndexFragmentBinding) binding), (IASTName) uscope.getPhysicalNode());
|
||||
}
|
||||
throw new CompositingNotImplementedError(rscope.getClass().getName());
|
||||
} catch(CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
throw new CompositingNotImplementedError(ce.getMessage());
|
||||
} catch(DOMException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
throw new CompositingNotImplementedError(ce.getMessage());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
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.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
@ -24,6 +25,8 @@ import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
|||
public class CompositeCPPTemplateTypeParameter extends CompositeCPPBinding
|
||||
implements ICPPTemplateTypeParameter, ICPPUnknownBinding, IIndexType {
|
||||
|
||||
private ICPPScope unknownScope;
|
||||
|
||||
public CompositeCPPTemplateTypeParameter(ICompositesFactory cf, ICPPTemplateTypeParameter binding) {
|
||||
super(cf, binding);
|
||||
}
|
||||
|
@ -43,7 +46,10 @@ public class CompositeCPPTemplateTypeParameter extends CompositeCPPBinding
|
|||
}
|
||||
|
||||
public ICPPScope getUnknownScope() {
|
||||
return null;
|
||||
if (unknownScope == null) {
|
||||
unknownScope= new CompositeCPPUnknownScope(this, getUnknownName());
|
||||
}
|
||||
return unknownScope;
|
||||
}
|
||||
|
||||
public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap, ICPPScope instantiationScope) {
|
||||
|
@ -52,7 +58,7 @@ public class CompositeCPPTemplateTypeParameter extends CompositeCPPBinding
|
|||
}
|
||||
|
||||
public IASTName getUnknownName() {
|
||||
return null;
|
||||
return new CPPASTName(getNameCharArray());
|
||||
}
|
||||
|
||||
public ICPPUnknownBinding getUnknownContainerBinding() {
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
|||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragment;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBindingComparator;
|
||||
|
@ -209,6 +210,11 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
|
|||
if (parent instanceof IIndexScope) {
|
||||
return (IIndexScope) parent;
|
||||
}
|
||||
// unknown bindings don't always implement the scope directly
|
||||
if (parent instanceof ICPPUnknownBinding) {
|
||||
return (IIndexScope) ((ICPPUnknownBinding) parent).getUnknownScope();
|
||||
}
|
||||
} catch (DOMException e) {
|
||||
} catch (CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
}
|
||||
|
@ -251,14 +257,14 @@ public abstract class PDOMBinding extends PDOMNamedNode implements IIndexFragmen
|
|||
protected static String getConstantNameForValue(PDOMLinkage linkage, int value) {
|
||||
Class<? extends PDOMLinkage> c= linkage.getClass();
|
||||
Field[] fields= c.getFields();
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
for (Field field : fields) {
|
||||
try {
|
||||
fields[i].setAccessible(true);
|
||||
if ((fields[i].getModifiers() & Modifier.STATIC) != 0) {
|
||||
if (int.class.equals(fields[i].getType())) {
|
||||
int fvalue= fields[i].getInt(null);
|
||||
field.setAccessible(true);
|
||||
if ((field.getModifiers() & Modifier.STATIC) != 0) {
|
||||
if (int.class.equals(field.getType())) {
|
||||
int fvalue= field.getInt(null);
|
||||
if (fvalue == value)
|
||||
return fields[i].getName();
|
||||
return field.getName();
|
||||
}
|
||||
}
|
||||
} catch (IllegalAccessException iae) {
|
||||
|
|
|
@ -70,7 +70,6 @@ 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.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||
|
@ -528,12 +527,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
} else if (binding instanceof ICPPClassType) {
|
||||
return CPP_DEFERRED_CLASS_INSTANCE;
|
||||
}
|
||||
} else if (binding instanceof ICPPUnknownBinding) {
|
||||
if (binding instanceof ICPPUnknownClassInstance) {
|
||||
return CPP_UNKNOWN_CLASS_INSTANCE;
|
||||
} else if (binding instanceof ICPPUnknownClassType) {
|
||||
return CPP_UNKNOWN_CLASS_TYPE;
|
||||
}
|
||||
} else if (binding instanceof ICPPTemplateInstance) {
|
||||
if (binding instanceof ICPPConstructor) {
|
||||
return CPP_CONSTRUCTOR_INSTANCE;
|
||||
|
@ -602,6 +595,12 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
return CPP_FUNCTION_TYPE;
|
||||
} else if (binding instanceof ICPPFunction) {
|
||||
return CPPFUNCTION;
|
||||
} else if (binding instanceof ICPPUnknownBinding) {
|
||||
if (binding instanceof ICPPUnknownClassInstance) {
|
||||
return CPP_UNKNOWN_CLASS_INSTANCE;
|
||||
} else if (binding instanceof ICPPUnknownClassType) {
|
||||
return CPP_UNKNOWN_CLASS_TYPE;
|
||||
}
|
||||
} else if (binding instanceof ICPPClassTemplate) {
|
||||
// this must be before class type
|
||||
return CPP_CLASS_TEMPLATE;
|
||||
|
@ -670,7 +669,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
}
|
||||
if (parent instanceof IPDOMMemberOwner) {
|
||||
int localToFileRec= getLocalToFileRec(parent, binding);
|
||||
return CPPFindBinding.findBinding(parent, this, binding, localToFileRec);
|
||||
return CPPFindBinding.findBinding(parent, this, binding, localToFileRec, parent instanceof ICPPSpecialization);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -693,12 +692,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
// all instances are stored with their template definition
|
||||
if (binding instanceof ICPPTemplateInstance) {
|
||||
scopeBinding= ((ICPPTemplateInstance) binding).getTemplateDefinition();
|
||||
} else if (binding instanceof ICPPUnknownClassType &&
|
||||
binding instanceof ICPPDeferredClassInstance == false) {
|
||||
// the parent of an unknown class can be a template parameter, which is not a scope
|
||||
scopeBinding= ((ICPPUnknownClassType) binding).getUnknownContainerBinding();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
IScope scope = binding.getScope();
|
||||
if (scope instanceof ICPPTemplateScope
|
||||
&& binding instanceof ICPPTemplateParameter == false
|
||||
|
|
|
@ -25,6 +25,7 @@ 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.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
|
@ -48,6 +49,7 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
|
|||
*/
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 8;
|
||||
private ICPPScope fUnknownScope;
|
||||
|
||||
public PDOMCPPTemplateTypeParameter(PDOM pdom, PDOMNode parent,
|
||||
ICPPTemplateTypeParameter param) throws CoreException {
|
||||
|
@ -141,13 +143,18 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMember
|
|||
|
||||
|
||||
public ICPPScope getUnknownScope() {
|
||||
return null;
|
||||
if (fUnknownScope == null) {
|
||||
fUnknownScope= new PDOMCPPUnknownScope(this, new CPPASTName(getNameCharArray()));
|
||||
}
|
||||
return fUnknownScope;
|
||||
}
|
||||
|
||||
public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap, ICPPScope instantiationScope) { fail(); return null;}
|
||||
public IASTName getUnknownName() {
|
||||
public IBinding resolvePartially(ICPPUnknownBinding parentBinding, ObjectMap argMap, ICPPScope instantiationScope) {
|
||||
return null;
|
||||
}
|
||||
public IASTName getUnknownName() {
|
||||
return new CPPASTName(getNameCharArray());
|
||||
}
|
||||
public ICPPUnknownBinding getUnknownContainerBinding() {
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue