mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Moves c++-specific stuff from PDOMLinkage to PDOMCPPLinkage.
This commit is contained in:
parent
8a3ee52100
commit
1c88bb0adf
3 changed files with 175 additions and 121 deletions
|
@ -14,14 +14,11 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ILinkage;
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
|
||||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
import org.eclipse.cdt.core.dom.ast.IArrayType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
|
@ -31,25 +28,12 @@ import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
|
||||||
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.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
|
||||||
import org.eclipse.cdt.core.index.IIndexLinkage;
|
import org.eclipse.cdt.core.index.IIndexLinkage;
|
||||||
import org.eclipse.cdt.internal.core.Util;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexBindingConstants;
|
import org.eclipse.cdt.internal.core.index.IIndexBindingConstants;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
|
||||||
import org.eclipse.cdt.internal.core.index.composite.CompositeScope;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
|
import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||||
|
@ -236,109 +220,6 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param binding
|
|
||||||
* @return <ul><li> null - skip this binding (don't add to pdom)
|
|
||||||
* <li>this - for filescope
|
|
||||||
* <li>a PDOMBinding instance - parent adapted binding
|
|
||||||
* </ul>
|
|
||||||
* @throws CoreException
|
|
||||||
*/
|
|
||||||
protected PDOMNode getAdaptedParent(IBinding binding, boolean addParent) throws CoreException {
|
|
||||||
try {
|
|
||||||
IBinding scopeBinding = null;
|
|
||||||
if (binding instanceof ICPPTemplateInstance) {
|
|
||||||
scopeBinding = ((ICPPTemplateInstance)binding).getTemplateDefinition();
|
|
||||||
} else {
|
|
||||||
IScope scope = binding.getScope();
|
|
||||||
if (scope == null) {
|
|
||||||
if (binding instanceof ICPPDeferredTemplateInstance) {
|
|
||||||
ICPPDeferredTemplateInstance deferred = (ICPPDeferredTemplateInstance) binding;
|
|
||||||
ICPPTemplateDefinition template = deferred.getTemplateDefinition();
|
|
||||||
scope = template.getScope();
|
|
||||||
}
|
|
||||||
|
|
||||||
IIndexBinding ib = (binding instanceof IIndexBinding) ? (IIndexBinding) binding : null;
|
|
||||||
|
|
||||||
if (ib == null && binding instanceof ICPPSpecialization) {
|
|
||||||
IBinding spec = ((ICPPSpecialization)binding).getSpecializedBinding();
|
|
||||||
if (spec instanceof IIndexBinding) {
|
|
||||||
ib = (IIndexBinding) spec;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ib != null) {
|
|
||||||
// don't adapt file local bindings from other fragments to this one.
|
|
||||||
if (ib.isFileLocal()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
// in an index the null scope represents global scope.
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scope instanceof IIndexScope) {
|
|
||||||
if (scope instanceof CompositeScope) { // we special case for performance
|
|
||||||
return adaptBinding(((CompositeScope)scope).getRawScopeBinding());
|
|
||||||
} else {
|
|
||||||
return adaptBinding(((IIndexScope) scope).getScopeBinding());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// the scope is from the ast
|
|
||||||
if (scope instanceof ICPPTemplateScope && !(binding instanceof ICPPTemplateParameter || binding instanceof ICPPTemplateInstance)) {
|
|
||||||
scope = scope.getParent();
|
|
||||||
if (scope == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (scope instanceof ICPPNamespaceScope) {
|
|
||||||
IName name= scope.getScopeName();
|
|
||||||
if (name != null && name.toCharArray().length == 0) {
|
|
||||||
// skip unnamed namespaces
|
|
||||||
scope= scope.getParent();
|
|
||||||
} else {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IASTNode scopeNode = ASTInternal.getPhysicalNodeOfScope(scope);
|
|
||||||
if (scopeNode instanceof IASTCompoundStatement) {
|
|
||||||
return null;
|
|
||||||
} else if (scopeNode instanceof IASTTranslationUnit) {
|
|
||||||
return this;
|
|
||||||
} else {
|
|
||||||
if (scope instanceof ICPPClassScope) {
|
|
||||||
scopeBinding = ((ICPPClassScope)scope).getClassType();
|
|
||||||
} else {
|
|
||||||
IName scopeName = scope.getScopeName();
|
|
||||||
if (scopeName instanceof IASTName) {
|
|
||||||
scopeBinding = ((IASTName) scopeName).resolveBinding();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (scopeBinding != null && scopeBinding != binding) {
|
|
||||||
PDOMBinding scopePDOMBinding = null;
|
|
||||||
if (addParent) {
|
|
||||||
scopePDOMBinding = addBinding(scopeBinding, null);
|
|
||||||
} else {
|
|
||||||
scopePDOMBinding = adaptBinding(scopeBinding);
|
|
||||||
}
|
|
||||||
if (scopePDOMBinding != null)
|
|
||||||
return scopePDOMBinding;
|
|
||||||
}
|
|
||||||
} catch (DOMException e) {
|
|
||||||
throw new CoreException(Util.createStatus(e));
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
final protected int getLocalToFileRec(PDOMNode parent, IBinding binding) throws CoreException {
|
final protected int getLocalToFileRec(PDOMNode parent, IBinding binding) throws CoreException {
|
||||||
int rec= 0;
|
int rec= 0;
|
||||||
if (parent instanceof PDOMBinding) {
|
if (parent instanceof PDOMBinding) {
|
||||||
|
|
|
@ -14,8 +14,12 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
package org.eclipse.cdt.internal.core.pdom.dom.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
|
@ -25,12 +29,17 @@ import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.c.ICBasicType;
|
import org.eclipse.cdt.core.dom.ast.c.ICBasicType;
|
||||||
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.internal.core.Util;
|
import org.eclipse.cdt.internal.core.Util;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
|
import org.eclipse.cdt.internal.core.index.IIndexCBindingConstants;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositeScope;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.FindBinding;
|
import org.eclipse.cdt.internal.core.pdom.dom.FindBinding;
|
||||||
|
@ -74,7 +83,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
PDOMNode parent = getAdaptedParent(binding, false);
|
PDOMNode parent = getAdaptedParent(binding);
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -172,8 +181,70 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapts the parent of the given binding to an object contained in this linkage. May return
|
||||||
|
* <code>null</code> if the binding cannot be adapted or the binding does not exist and addParent
|
||||||
|
* is set to <code>false</code>.
|
||||||
|
* @param binding the binding to adapt
|
||||||
|
* @return <ul>
|
||||||
|
* <li> null - skip this binding (don't add to pdom)
|
||||||
|
* <li> this - for global scope
|
||||||
|
* <li> a PDOMBinding instance - parent adapted binding
|
||||||
|
* </ul>
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
final private PDOMNode getAdaptedParent(IBinding binding) throws CoreException {
|
||||||
|
try {
|
||||||
|
IScope scope = binding.getScope();
|
||||||
|
if (binding instanceof IIndexBinding) {
|
||||||
|
IIndexBinding ib= (IIndexBinding) binding;
|
||||||
|
if (ib.isFileLocal()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// in an index the null scope represents global scope.
|
||||||
|
if (scope == null) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scope == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scope instanceof IIndexScope) {
|
||||||
|
if (scope instanceof CompositeScope) { // we special case for performance
|
||||||
|
return adaptBinding(((CompositeScope)scope).getRawScopeBinding());
|
||||||
|
} else {
|
||||||
|
return adaptBinding(((IIndexScope) scope).getScopeBinding());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// the scope is from the ast
|
||||||
|
IASTNode scopeNode = ASTInternal.getPhysicalNodeOfScope(scope);
|
||||||
|
IBinding scopeBinding = null;
|
||||||
|
if (scopeNode instanceof IASTCompoundStatement) {
|
||||||
|
return null;
|
||||||
|
} else if (scopeNode instanceof IASTTranslationUnit) {
|
||||||
|
return this;
|
||||||
|
} else {
|
||||||
|
IName scopeName = scope.getScopeName();
|
||||||
|
if (scopeName instanceof IASTName) {
|
||||||
|
scopeBinding = ((IASTName) scopeName).resolveBinding();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (scopeBinding != null && scopeBinding != binding) {
|
||||||
|
PDOMBinding scopePDOMBinding= adaptBinding(scopeBinding);
|
||||||
|
if (scopePDOMBinding != null)
|
||||||
|
return scopePDOMBinding;
|
||||||
|
}
|
||||||
|
} catch (DOMException e) {
|
||||||
|
throw new CoreException(Util.createStatus(e));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public final PDOMBinding doAdaptBinding(final IBinding binding) throws CoreException {
|
public final PDOMBinding doAdaptBinding(final IBinding binding) throws CoreException {
|
||||||
PDOMNode parent = getAdaptedParent(binding, false);
|
PDOMNode parent = getAdaptedParent(binding);
|
||||||
if (parent == this) {
|
if (parent == this) {
|
||||||
int localToFileRec= getLocalToFileRec(null, binding);
|
int localToFileRec= getLocalToFileRec(null, binding);
|
||||||
return FindBinding.findBinding(getIndex(), getPDOM(), binding.getNameCharArray(), new int[] {getBindingType(binding)}, localToFileRec);
|
return FindBinding.findBinding(getIndex(), getPDOM(), binding.getNameCharArray(), new int[] {getBindingType(binding)}, localToFileRec);
|
||||||
|
|
|
@ -21,8 +21,10 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
|
@ -55,6 +57,7 @@ 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.ICPPTemplateDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||||
|
@ -66,6 +69,8 @@ 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.index.IIndexCPPBindingConstants;
|
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||||
|
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||||
|
import org.eclipse.cdt.internal.core.index.composite.CompositeScope;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
|
import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||||
|
@ -591,6 +596,103 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adapts the parent of the given binding to an object contained in this linkage. May return
|
||||||
|
* <code>null</code> if the binding cannot be adapted or the binding does not exist and addParent
|
||||||
|
* is set to <code>false</code>.
|
||||||
|
* @param binding the binding to adapt
|
||||||
|
* @return <ul>
|
||||||
|
* <li> null - skip this binding (don't add to pdom)
|
||||||
|
* <li> this - for global scope
|
||||||
|
* <li> a PDOMBinding instance - parent adapted binding
|
||||||
|
* </ul>
|
||||||
|
* @throws CoreException
|
||||||
|
*/
|
||||||
|
private final PDOMNode getAdaptedParent(IBinding binding, boolean addParent) throws CoreException {
|
||||||
|
try {
|
||||||
|
IBinding scopeBinding = null;
|
||||||
|
if (binding instanceof ICPPTemplateInstance) {
|
||||||
|
scopeBinding = ((ICPPTemplateInstance)binding).getTemplateDefinition();
|
||||||
|
} else {
|
||||||
|
IScope scope = binding.getScope();
|
||||||
|
if (binding instanceof IIndexBinding) {
|
||||||
|
IIndexBinding ib= (IIndexBinding) binding;
|
||||||
|
// don't adapt file local bindings from other fragments to this one.
|
||||||
|
if (ib.isFileLocal()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// in an index the null scope represents global scope.
|
||||||
|
if (scope == null) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (scope == null) {
|
||||||
|
if (binding instanceof ICPPSpecialization) {
|
||||||
|
if (((ICPPSpecialization) binding).getSpecializedBinding() instanceof IIndexBinding) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scope instanceof IIndexScope) {
|
||||||
|
if (scope instanceof CompositeScope) { // we special case for performance
|
||||||
|
return adaptBinding(((CompositeScope)scope).getRawScopeBinding());
|
||||||
|
} else {
|
||||||
|
return adaptBinding(((IIndexScope) scope).getScopeBinding());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// the scope is from the ast
|
||||||
|
if (scope instanceof ICPPTemplateScope && !(binding instanceof ICPPTemplateParameter || binding instanceof ICPPTemplateInstance)) {
|
||||||
|
scope = scope.getParent();
|
||||||
|
if (scope == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (scope instanceof ICPPNamespaceScope) {
|
||||||
|
IName name= scope.getScopeName();
|
||||||
|
if (name != null && name.toCharArray().length == 0) {
|
||||||
|
// skip unnamed namespaces
|
||||||
|
scope= scope.getParent();
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IASTNode scopeNode = ASTInternal.getPhysicalNodeOfScope(scope);
|
||||||
|
if (scopeNode instanceof IASTCompoundStatement) {
|
||||||
|
return null;
|
||||||
|
} else if (scopeNode instanceof IASTTranslationUnit) {
|
||||||
|
return this;
|
||||||
|
} else {
|
||||||
|
if (scope instanceof ICPPClassScope) {
|
||||||
|
scopeBinding = ((ICPPClassScope)scope).getClassType();
|
||||||
|
} else {
|
||||||
|
IName scopeName = scope.getScopeName();
|
||||||
|
if (scopeName instanceof IASTName) {
|
||||||
|
scopeBinding = ((IASTName) scopeName).resolveBinding();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (scopeBinding != null && scopeBinding != binding) {
|
||||||
|
PDOMBinding scopePDOMBinding = null;
|
||||||
|
if (addParent) {
|
||||||
|
scopePDOMBinding = addBinding(scopeBinding, null);
|
||||||
|
} else {
|
||||||
|
scopePDOMBinding = adaptBinding(scopeBinding);
|
||||||
|
}
|
||||||
|
if (scopePDOMBinding != null)
|
||||||
|
return scopePDOMBinding;
|
||||||
|
}
|
||||||
|
} catch (DOMException e) {
|
||||||
|
throw new CoreException(Util.createStatus(e));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PDOMNode addType(PDOMNode parent, IType type) throws CoreException {
|
public PDOMNode addType(PDOMNode parent, IType type) throws CoreException {
|
||||||
if (type instanceof IProblemBinding) {
|
if (type instanceof IProblemBinding) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue