1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 22:52:11 +02:00

Minor correction for adapting template-bindings between different pdoms.

This commit is contained in:
Markus Schorn 2008-04-25 09:11:18 +00:00
parent a9b1ca9430
commit 35e73ce090

View file

@ -699,6 +699,13 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
} }
else { else {
IScope scope = binding.getScope(); IScope scope = binding.getScope();
if (scope instanceof ICPPTemplateScope
&& binding instanceof ICPPTemplateParameter == false
&& scope instanceof IBinding == false // PDOMCPPClassTemplate, PDOMCPPFunctionTemplate
) {
scope = scope.getParent();
}
if (binding instanceof IIndexBinding) { if (binding instanceof IIndexBinding) {
IIndexBinding ib= (IIndexBinding) binding; IIndexBinding ib= (IIndexBinding) binding;
// don't adapt file local bindings from other fragments to this one. // don't adapt file local bindings from other fragments to this one.
@ -714,13 +721,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return null; return null;
} }
if (scope instanceof ICPPTemplateScope && !(binding instanceof ICPPTemplateParameter)) {
scope = scope.getParent();
if (scope == null) {
return this;
}
}
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 adaptOrAddBinding(add, ((CompositeScope) scope).getRawScopeBinding()); return adaptOrAddBinding(add, ((CompositeScope) scope).getRawScopeBinding());
@ -745,16 +745,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
if (scopeNode instanceof IASTTranslationUnit) { if (scopeNode instanceof IASTTranslationUnit) {
return this; return this;
} }
if (scope instanceof ICPPClassScope) { scopeBinding= getBindingForASTScope(scope);
scopeBinding = ((ICPPClassScope)scope).getClassType();
} else if (scope instanceof ICPPInternalUnknownScope) {
scopeBinding = ((ICPPInternalUnknownScope) scope).getScopeBinding();
} else {
IName scopeName = scope.getScopeName();
if (scopeName instanceof IASTName) {
scopeBinding = ((IASTName) scopeName).resolveBinding();
}
}
} }
assert scopeBinding != binding; assert scopeBinding != binding;
if (scopeBinding != null && scopeBinding != binding) { if (scopeBinding != null && scopeBinding != binding) {
@ -766,6 +757,20 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
return null; return null;
} }
private IBinding getBindingForASTScope(IScope scope) throws DOMException {
if (scope instanceof ICPPClassScope) {
return ((ICPPClassScope)scope).getClassType();
}
if (scope instanceof ICPPInternalUnknownScope) {
return ((ICPPInternalUnknownScope) scope).getScopeBinding();
}
IName scopeName = scope.getScopeName();
if (scopeName instanceof IASTName) {
return ((IASTName) scopeName).resolveBinding();
}
return null;
}
private PDOMBinding adaptOrAddBinding(boolean add, IBinding binding) throws CoreException { private PDOMBinding adaptOrAddBinding(boolean add, IBinding binding) throws CoreException {
if (add) { if (add) {
return addBinding(binding, null); return addBinding(binding, null);