mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 12:55:40 +02:00
Map index bindings for class types back to the AST, bug 262719.
This commit is contained in:
parent
0c9f6c2e5e
commit
1117c603d8
16 changed files with 404 additions and 149 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2006, 2009 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -397,4 +397,18 @@ public class IndexCBindingResolutionBugs extends IndexBindingResolutionTestBase
|
||||||
assertTrue(params[0].getType() instanceof IBasicType);
|
assertTrue(params[0].getType() instanceof IBasicType);
|
||||||
assertEquals(IBasicType.t_int, ((IBasicType)params[0].getType()).getType());
|
assertEquals(IBasicType.t_int, ((IBasicType)params[0].getType()).getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// typedef struct S S;
|
||||||
|
// void setValue(S *pSelf, int value);
|
||||||
|
|
||||||
|
// struct S {
|
||||||
|
// int value;
|
||||||
|
// };
|
||||||
|
// void setValue(S *pSelf, int value) {
|
||||||
|
// pSelf->value = value;
|
||||||
|
// }
|
||||||
|
public void testOpaqueStruct_Bug262719() throws Exception {
|
||||||
|
IBinding b = getBindingFromASTName("value =", 5);
|
||||||
|
assertTrue(b instanceof IField);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,8 @@ import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalFunction;
|
import org.eclipse.cdt.internal.core.dom.parser.c.ICInternalFunction;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalFunction;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Access to methods on scopes and bindings internal to the parser.
|
* Access to methods on scopes and bindings internal to the parser.
|
||||||
|
@ -74,7 +76,7 @@ public class ASTInternal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getDeclaredInSourceFileOnly(IBinding binding, boolean requireDefinition) {
|
public static String getDeclaredInSourceFileOnly(IBinding binding, boolean requireDefinition, PDOMBinding nonLocal) {
|
||||||
IASTNode[] decls;
|
IASTNode[] decls;
|
||||||
IASTNode def;
|
IASTNode def;
|
||||||
if (binding instanceof ICPPInternalBinding) {
|
if (binding instanceof ICPPInternalBinding) {
|
||||||
|
@ -109,6 +111,13 @@ public class ASTInternal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (requireDefinition && nonLocal != null) {
|
||||||
|
try {
|
||||||
|
if (nonLocal.hasDeclaration())
|
||||||
|
return null;
|
||||||
|
} catch (CoreException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,8 +20,10 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
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.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||||
|
@ -33,7 +35,11 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||||
*/
|
*/
|
||||||
public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbiguityParent {
|
public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbiguityParent {
|
||||||
private CScope compilationUnit = null;
|
private CScope compilationUnit = null;
|
||||||
|
private CStructMapper fStructMapper;
|
||||||
|
|
||||||
|
public CASTTranslationUnit() {
|
||||||
|
fStructMapper= new CStructMapper(this);
|
||||||
|
}
|
||||||
|
|
||||||
public CASTTranslationUnit copy() {
|
public CASTTranslationUnit copy() {
|
||||||
CASTTranslationUnit copy = new CASTTranslationUnit();
|
CASTTranslationUnit copy = new CASTTranslationUnit();
|
||||||
|
@ -109,4 +115,11 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Maps structs from the index into this AST.
|
||||||
|
*/
|
||||||
|
public IType mapToASTType(ICompositeType type) {
|
||||||
|
return fStructMapper.mapToAST(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,76 @@
|
||||||
|
/*******************************************************************************
|
||||||
|
* Copyright (c) 2009 Wind River Systems, 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:
|
||||||
|
* Markus Schorn - initial API and implementation
|
||||||
|
*******************************************************************************/
|
||||||
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
import org.eclipse.cdt.core.parser.util.CharArrayMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility to map index bindings to ast bindings.
|
||||||
|
*/
|
||||||
|
public class CStructMapper {
|
||||||
|
private class Visitor extends ASTVisitor {
|
||||||
|
Visitor() {
|
||||||
|
shouldVisitDeclarations= true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTDeclaration declaration) {
|
||||||
|
if (declaration instanceof IASTSimpleDeclaration) {
|
||||||
|
IASTDeclSpecifier declspec = ((IASTSimpleDeclaration) declaration).getDeclSpecifier();
|
||||||
|
if (declspec instanceof IASTCompositeTypeSpecifier) {
|
||||||
|
IASTCompositeTypeSpecifier cts= (IASTCompositeTypeSpecifier) declspec;
|
||||||
|
final IASTName name = cts.getName();
|
||||||
|
final char[] nameChars = name.toCharArray();
|
||||||
|
if (nameChars.length > 0) {
|
||||||
|
fStructs.put(nameChars, name);
|
||||||
|
}
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PROCESS_SKIP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private final IASTTranslationUnit fTranslationUnit;
|
||||||
|
protected CharArrayMap<IASTName> fStructs;
|
||||||
|
|
||||||
|
public CStructMapper(IASTTranslationUnit tu) {
|
||||||
|
fTranslationUnit= tu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IType mapToAST(ICompositeType type) {
|
||||||
|
if (fStructs == null) {
|
||||||
|
fStructs= new CharArrayMap<IASTName>();
|
||||||
|
fTranslationUnit.accept(new Visitor());
|
||||||
|
}
|
||||||
|
IASTName name= fStructs.get(type.getNameCharArray());
|
||||||
|
if (name != null) {
|
||||||
|
IBinding b= name.resolveBinding();
|
||||||
|
if (b instanceof ICompositeType) {
|
||||||
|
final ICompositeType mapped = (ICompositeType) b;
|
||||||
|
if (mapped.isSameType(type)) {
|
||||||
|
return mapped;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
}
|
|
@ -610,6 +610,9 @@ public class CVisitor extends ASTQueries {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != null && type instanceof ICompositeType) {
|
if (type != null && type instanceof ICompositeType) {
|
||||||
|
if (type instanceof IIndexBinding) {
|
||||||
|
type= ((CASTTranslationUnit) fieldReference.getTranslationUnit()).mapToASTType((ICompositeType) type);
|
||||||
|
}
|
||||||
if (prefix) {
|
if (prefix) {
|
||||||
IBinding[] result = null;
|
IBinding[] result = null;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* John Camelon (IBM) - Initial API and implementation
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* Cast expression for c++
|
||||||
*/
|
*/
|
||||||
public class CPPASTCastExpression extends CPPASTUnaryExpression implements ICPPASTCastExpression {
|
public class CPPASTCastExpression extends CPPASTUnaryExpression implements ICPPASTCastExpression {
|
||||||
|
|
||||||
|
@ -97,6 +98,6 @@ public class CPPASTCastExpression extends CPPASTUnaryExpression implements ICPPA
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IType getExpressionType() {
|
public IType getExpressionType() {
|
||||||
return CPPVisitor.createType(typeId.getDeclSpecifier(), typeId.getAbstractDeclarator());
|
return CPPVisitor.createType(typeId.getAbstractDeclarator());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@ 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.cpp.ICPPASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||||
|
@ -184,6 +185,10 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
||||||
public IScope mapToASTScope(IIndexScope scope) {
|
public IScope mapToASTScope(IIndexScope scope) {
|
||||||
return fScopeMapper.mapToASTScope(scope);
|
return fScopeMapper.mapToASTScope(scope);
|
||||||
}
|
}
|
||||||
|
// bug 262719: class types from the index have to be mapped back to the AST.
|
||||||
|
public ICPPClassType mapToAST(ICPPClassType binding) {
|
||||||
|
return fScopeMapper.mapToAST(binding);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores directives from the index into this scope.
|
* Stores directives from the index into this scope.
|
||||||
|
|
|
@ -37,6 +37,6 @@ public class CPPASTTypeIdInitializerExpression extends ASTTypeIdInitializerExpre
|
||||||
|
|
||||||
public IType getExpressionType() {
|
public IType getExpressionType() {
|
||||||
final IASTTypeId typeId = getTypeId();
|
final IASTTypeId typeId = getTypeId();
|
||||||
return CPPVisitor.createType(typeId.getDeclSpecifier(), typeId.getAbstractDeclarator());
|
return CPPVisitor.createType(typeId.getAbstractDeclarator());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2008 IBM Corporation and others.
|
* Copyright (c) 2004, 2009 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
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.IASTSimpleDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
@ -33,6 +34,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||||
|
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,26 +47,33 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getVisibility() throws DOMException {
|
public int getVisibility() throws DOMException {
|
||||||
IASTDeclaration decl = getPrimaryDeclaration();
|
IASTDeclaration decl= getPrimaryDeclaration();
|
||||||
if( decl == null ) {
|
if (decl == null) {
|
||||||
//12.1-5, 12.8-10 Implicitl constructors and assignment operators are public
|
// 12.1-5, 12.8-10 Implicit constructors and assignment operators are public
|
||||||
return ICPPASTVisibilityLabel.v_public;
|
return ICPPASTVisibilityLabel.v_public;
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTCompositeTypeSpecifier cls = (IASTCompositeTypeSpecifier) decl.getParent();
|
IASTNode parent= decl.getParent();
|
||||||
IASTDeclaration [] members = cls.getMembers();
|
while (parent instanceof ICPPASTTemplateDeclaration) {
|
||||||
ICPPASTVisibilityLabel vis = null;
|
decl= (ICPPASTTemplateDeclaration) parent;
|
||||||
for (IASTDeclaration member : members) {
|
parent= parent.getParent();
|
||||||
if( member instanceof ICPPASTVisibilityLabel )
|
}
|
||||||
vis = (ICPPASTVisibilityLabel) member;
|
if (parent instanceof IASTCompositeTypeSpecifier) {
|
||||||
else if( member == decl )
|
IASTCompositeTypeSpecifier cls = (IASTCompositeTypeSpecifier) decl.getParent();
|
||||||
break;
|
IASTDeclaration [] members = cls.getMembers();
|
||||||
}
|
ICPPASTVisibilityLabel vis = null;
|
||||||
if( vis != null ){
|
for (IASTDeclaration member : members) {
|
||||||
return vis.getVisibility();
|
if( member instanceof ICPPASTVisibilityLabel )
|
||||||
} else if( cls.getKey() == ICPPASTCompositeTypeSpecifier.k_class ){
|
vis = (ICPPASTVisibilityLabel) member;
|
||||||
return ICPPASTVisibilityLabel.v_private;
|
else if( member == decl )
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
if( vis != null ){
|
||||||
|
return vis.getVisibility();
|
||||||
|
} else if( cls.getKey() == ICPPASTCompositeTypeSpecifier.k_class ){
|
||||||
|
return ICPPASTVisibilityLabel.v_private;
|
||||||
|
}
|
||||||
|
}
|
||||||
return ICPPASTVisibilityLabel.v_public;
|
return ICPPASTVisibilityLabel.v_public;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,80 +82,78 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
|
||||||
return scope.getClassType();
|
return scope.getClassType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTDeclaration getPrimaryDeclaration() throws DOMException{
|
public IASTDeclaration getPrimaryDeclaration() throws DOMException {
|
||||||
//first check if we already know it
|
// first check if we already know it
|
||||||
if( declarations != null ){
|
if (declarations != null) {
|
||||||
for (ICPPASTFunctionDeclarator dtor : declarations) {
|
for (ICPPASTFunctionDeclarator dtor : declarations) {
|
||||||
if (dtor == null)
|
if (dtor == null)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
IASTDeclaration decl= (IASTDeclaration) CPPVisitor.findOutermostDeclarator(dtor).getParent();
|
IASTDeclaration decl = (IASTDeclaration) ASTQueries.findOutermostDeclarator(dtor).getParent();
|
||||||
if( decl.getParent() instanceof ICPPASTCompositeTypeSpecifier )
|
IASTNode parent= decl.getParent();
|
||||||
|
while (parent instanceof ICPPASTTemplateDeclaration)
|
||||||
|
parent= parent.getParent();
|
||||||
|
if (parent instanceof ICPPASTCompositeTypeSpecifier)
|
||||||
return decl;
|
return decl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IFunctionType ftype = getType();
|
IFunctionType ftype = getType();
|
||||||
IType [] params = ftype.getParameterTypes();
|
IType[] params = ftype.getParameterTypes();
|
||||||
|
|
||||||
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal.getPhysicalNodeOfScope(getScope());
|
ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) ASTInternal
|
||||||
|
.getPhysicalNodeOfScope(getScope());
|
||||||
if (compSpec == null) {
|
if (compSpec == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
IASTDeclaration [] members = compSpec.getMembers();
|
IASTDeclaration[] members = compSpec.getMembers();
|
||||||
for (IASTDeclaration member : members) {
|
for (IASTDeclaration member : members) {
|
||||||
IASTDeclarator dtor = null;
|
IASTDeclarator[] ds = null;
|
||||||
IASTDeclarator [] ds = null;
|
while (member instanceof ICPPASTTemplateDeclaration)
|
||||||
int di = -1;
|
member = ((ICPPASTTemplateDeclaration) member).getDeclaration();
|
||||||
|
|
||||||
if( member instanceof ICPPASTTemplateDeclaration )
|
if (member instanceof IASTSimpleDeclaration) {
|
||||||
member = ((ICPPASTTemplateDeclaration) member).getDeclaration();
|
ds = ((IASTSimpleDeclaration) member).getDeclarators();
|
||||||
if( member instanceof IASTSimpleDeclaration ){
|
} else if (member instanceof IASTFunctionDefinition) {
|
||||||
ds = ((IASTSimpleDeclaration)member).getDeclarators();
|
ds = new IASTDeclarator[] {((IASTFunctionDefinition) member).getDeclarator()};
|
||||||
} else if( member instanceof IASTFunctionDefinition ){
|
} else {
|
||||||
dtor = ((IASTFunctionDefinition) member).getDeclarator();
|
continue;
|
||||||
}
|
}
|
||||||
if( ds != null && ds.length > 0 ){
|
|
||||||
di = 0;
|
for (IASTDeclarator dtor : ds) {
|
||||||
dtor = ds[0];
|
IASTName name = ASTQueries.findInnermostDeclarator(dtor).getName();
|
||||||
while( dtor != null ){
|
if (ASTQueries.findTypeRelevantDeclarator(dtor) instanceof ICPPASTFunctionDeclarator
|
||||||
IASTName name = CPPVisitor.findInnermostDeclarator(dtor).getName();
|
&& CharArrayUtils.equals(name.getLookupKey(), getNameCharArray())) {
|
||||||
if( CPPVisitor.findTypeRelevantDeclarator(dtor) instanceof ICPPASTFunctionDeclarator &&
|
IType t0 = CPPVisitor.createType(dtor);
|
||||||
CharArrayUtils.equals( name.getLookupKey(), getNameCharArray() ) )
|
boolean ok = false;
|
||||||
{
|
if (t0 instanceof IFunctionType) {
|
||||||
IType t0= CPPVisitor.createType( dtor );
|
IFunctionType t = (IFunctionType) t0;
|
||||||
boolean ok= false;
|
IType[] ps = t.getParameterTypes();
|
||||||
if (t0 instanceof IFunctionType) {
|
if (ps.length == params.length) {
|
||||||
IFunctionType t = (IFunctionType) t0;
|
int idx = 0;
|
||||||
IType [] ps = t.getParameterTypes();
|
for (; idx < ps.length && ps[idx] != null; idx++) {
|
||||||
if( ps.length == params.length ){
|
if (!ps[idx].isSameType(params[idx]))
|
||||||
int idx = 0;
|
break;
|
||||||
for( ; idx < ps.length && ps[idx] != null; idx++ ){
|
|
||||||
if( !ps[idx].isSameType(params[idx]) )
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ok= idx == ps.length;
|
|
||||||
}
|
}
|
||||||
else if (ps.length == 0) {
|
ok = idx == ps.length;
|
||||||
if (params.length == 1) {
|
} else if (ps.length == 0) {
|
||||||
IType t1= params[0];
|
if (params.length == 1) {
|
||||||
ok = (t1 instanceof IBasicType) && ((IBasicType) t1).getType() == IBasicType.t_void;
|
IType t1 = params[0];
|
||||||
}
|
ok = (t1 instanceof IBasicType)
|
||||||
|
&& ((IBasicType) t1).getType() == IBasicType.t_void;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
ok= false;
|
ok = false;
|
||||||
}
|
}
|
||||||
if (ok) {
|
if (ok) {
|
||||||
name.setBinding( this );
|
name.setBinding(this);
|
||||||
if( member instanceof IASTSimpleDeclaration )
|
if (member instanceof IASTSimpleDeclaration)
|
||||||
addDeclaration( dtor );
|
addDeclaration(dtor);
|
||||||
else if( member instanceof IASTFunctionDefinition )
|
else if (member instanceof IASTFunctionDefinition)
|
||||||
addDefinition( dtor );
|
addDefinition(dtor);
|
||||||
return member;
|
return member;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
dtor = ( di > -1 && ++ di < ds.length ) ? ds[di] : null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,6 +91,8 @@ abstract public class CPPScope implements ICPPScope, ICPPASTInternalScope {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final char[] c= name.getLookupKey();
|
final char[] c= name.getLookupKey();
|
||||||
|
if (c.length == 0)
|
||||||
|
return;
|
||||||
Object o = bindings.get(c);
|
Object o = bindings.get(c);
|
||||||
if (o != null) {
|
if (o != null) {
|
||||||
if (o instanceof ObjectSet) {
|
if (o instanceof ObjectSet) {
|
||||||
|
@ -304,6 +306,9 @@ abstract public class CPPScope implements ICPPScope, ICPPASTInternalScope {
|
||||||
if (bindings == null)
|
if (bindings == null)
|
||||||
bindings = new CharArrayObjectMap(1);
|
bindings = new CharArrayObjectMap(1);
|
||||||
char[] c = binding.getNameCharArray();
|
char[] c = binding.getNameCharArray();
|
||||||
|
if (c.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
Object o = bindings.get(c);
|
Object o = bindings.get(c);
|
||||||
if (o != null) {
|
if (o != null) {
|
||||||
if (o instanceof ObjectSet) {
|
if (o instanceof ObjectSet) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008 Wind River Systems, Inc. and others.
|
* Copyright (c) 2008, 2009 Wind River Systems, Inc. and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -17,16 +17,26 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IName;
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.EScopeKind;
|
import org.eclipse.cdt.core.dom.ast.EScopeKind;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDirective;
|
||||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||||
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
|
import org.eclipse.cdt.core.parser.util.CharArrayMap;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -119,13 +129,44 @@ public class CPPScopeMapper {
|
||||||
return fOffset;
|
return fOffset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collector for class definitions.
|
||||||
|
*/
|
||||||
|
private class Visitor extends ASTVisitor {
|
||||||
|
Visitor() {
|
||||||
|
shouldVisitDeclarations = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int visit(IASTDeclaration declaration) {
|
||||||
|
if (declaration instanceof IASTSimpleDeclaration) {
|
||||||
|
IASTDeclSpecifier declspec = ((IASTSimpleDeclaration) declaration).getDeclSpecifier();
|
||||||
|
if (declspec instanceof IASTCompositeTypeSpecifier) {
|
||||||
|
IASTCompositeTypeSpecifier cts = (IASTCompositeTypeSpecifier) declspec;
|
||||||
|
final IASTName name = cts.getName();
|
||||||
|
final char[] nameChars = name.toCharArray();
|
||||||
|
if (nameChars.length > 0) {
|
||||||
|
IASTName[] names= fClasses.get(nameChars);
|
||||||
|
names= (IASTName[]) ArrayUtil.append(IASTName.class, names, name);
|
||||||
|
fClasses.put(nameChars, names);
|
||||||
|
}
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
return PROCESS_SKIP;
|
||||||
|
} else if (declaration instanceof IASTASMDeclaration
|
||||||
|
|| declaration instanceof IASTFunctionDefinition) {
|
||||||
|
return PROCESS_SKIP;
|
||||||
|
}
|
||||||
|
return PROCESS_CONTINUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private final HashMap<IIndexScope, IScope> fMappedScopes= new HashMap<IIndexScope, IScope>();
|
private final HashMap<IIndexScope, IScope> fMappedScopes= new HashMap<IIndexScope, IScope>();
|
||||||
private final HashMap<String, NamespaceScopeWrapper> fNamespaceWrappers= new HashMap<String, NamespaceScopeWrapper>();
|
private final HashMap<String, NamespaceScopeWrapper> fNamespaceWrappers= new HashMap<String, NamespaceScopeWrapper>();
|
||||||
private final Map<String, List<UsingDirectiveWrapper>> fPerName= new HashMap<String, List<UsingDirectiveWrapper>>();
|
private final Map<String, List<UsingDirectiveWrapper>> fPerName= new HashMap<String, List<UsingDirectiveWrapper>>();
|
||||||
private final CPPASTTranslationUnit fTu;
|
private final CPPASTTranslationUnit fTu;
|
||||||
|
protected CharArrayMap<IASTName[]> fClasses;
|
||||||
|
|
||||||
|
|
||||||
public CPPScopeMapper(CPPASTTranslationUnit tu) {
|
public CPPScopeMapper(CPPASTTranslationUnit tu) {
|
||||||
|
@ -242,4 +283,26 @@ public class CPPScopeMapper {
|
||||||
}
|
}
|
||||||
return scope;
|
return scope;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICPPClassType mapToAST(ICPPClassType type) {
|
||||||
|
if (fClasses == null) {
|
||||||
|
fClasses= new CharArrayMap<IASTName[]>();
|
||||||
|
fTu.accept(new Visitor());
|
||||||
|
}
|
||||||
|
IASTName[] names= fClasses.get(type.getNameCharArray());
|
||||||
|
if (names != null) {
|
||||||
|
for (IASTName name : names) {
|
||||||
|
if (name == null)
|
||||||
|
break;
|
||||||
|
IBinding b= name.resolveBinding();
|
||||||
|
if (b instanceof ICPPClassType) {
|
||||||
|
final ICPPClassType mapped = (ICPPClassType) b;
|
||||||
|
if (mapped.isSameType(type)) {
|
||||||
|
return mapped;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return type;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2102,6 +2102,9 @@ public class CPPSemantics {
|
||||||
sourceExp, source, target, isImpliedObject);
|
sourceExp, source, target, isImpliedObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cost.rank < 0)
|
||||||
|
continue function_loop;
|
||||||
|
|
||||||
currFnCost[j] = cost;
|
currFnCost[j] = cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,7 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||||
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.CPPASTTranslationUnit;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassTemplate;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassTemplate;
|
||||||
|
@ -353,6 +354,12 @@ public class CPPVisitor extends ASTQueries {
|
||||||
parent instanceof IASTTypeId) {
|
parent instanceof IASTTypeId) {
|
||||||
binding = CPPSemantics.resolveBinding(elabType.getName());
|
binding = CPPSemantics.resolveBinding(elabType.getName());
|
||||||
}
|
}
|
||||||
|
if (binding instanceof IIndexBinding && binding instanceof ICPPClassType) {
|
||||||
|
binding= ((CPPASTTranslationUnit) elabType.getTranslationUnit()).mapToAST((ICPPClassType) binding);
|
||||||
|
if (binding instanceof ICPPInternalBinding) {
|
||||||
|
((ICPPInternalBinding) binding).addDeclaration(elabType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (binding != null &&
|
if (binding != null &&
|
||||||
(!(binding instanceof IProblemBinding) ||
|
(!(binding instanceof IProblemBinding) ||
|
||||||
|
@ -543,8 +550,34 @@ public class CPPVisitor extends ASTQueries {
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// parameter declarations
|
||||||
|
if (parent instanceof ICPPASTParameterDeclaration) {
|
||||||
|
ICPPASTParameterDeclaration param = (ICPPASTParameterDeclaration) parent;
|
||||||
|
parent = param.getParent();
|
||||||
|
if (parent instanceof IASTStandardFunctionDeclarator) {
|
||||||
|
IASTStandardFunctionDeclarator fdtor = (IASTStandardFunctionDeclarator) param.getParent();
|
||||||
|
// if the fdtor does not declare a function we don't create a binding for the parameter.
|
||||||
|
if (!(findOutermostDeclarator(fdtor).getParent() instanceof IASTDeclaration) ||
|
||||||
|
findTypeRelevantDeclarator(fdtor) != fdtor)
|
||||||
|
return null;
|
||||||
|
IBinding temp = findInnermostDeclarator(fdtor).getName().resolveBinding();
|
||||||
|
if (temp instanceof ICPPInternalFunction) {
|
||||||
|
return ((ICPPInternalFunction) temp).resolveParameter(param);
|
||||||
|
} else if (temp instanceof IProblemBinding) {
|
||||||
|
//problems with the function, still create binding for the parameter
|
||||||
|
return new CPPParameter(name);
|
||||||
|
} else if (temp instanceof IIndexBinding) {
|
||||||
|
return new CPPParameter(name);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
} else if (parent instanceof ICPPASTTemplateDeclaration) {
|
||||||
|
return CPPTemplates.createBinding(param);
|
||||||
|
}
|
||||||
|
return new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
// function declaration/definition
|
// function declaration/definition
|
||||||
IBinding binding;
|
IBinding binding= null;
|
||||||
final boolean template= tmplDecl != null;
|
final boolean template= tmplDecl != null;
|
||||||
boolean isFriendDecl= false;
|
boolean isFriendDecl= false;
|
||||||
ICPPScope scope = (ICPPScope) getContainingScope((IASTNode) name);
|
ICPPScope scope = (ICPPScope) getContainingScope((IASTNode) name);
|
||||||
|
@ -565,7 +598,9 @@ public class CPPVisitor extends ASTQueries {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean forceResolve= isFriendDecl && name instanceof ICPPASTTemplateId;
|
boolean forceResolve= isFriendDecl && name instanceof ICPPASTTemplateId;
|
||||||
binding = (scope != null) ? scope.getBinding(name, forceResolve) : null;
|
if (name.getLookupKey().length != 0 && scope != null) {
|
||||||
|
binding = scope.getBinding(name, forceResolve);
|
||||||
|
}
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
return e.getProblem();
|
return e.getProblem();
|
||||||
}
|
}
|
||||||
|
@ -649,7 +684,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
binding = template ? (ICPPFunction) new CPPFunctionTemplate(name)
|
binding = template ? (ICPPFunction) new CPPFunctionTemplate(name)
|
||||||
: new CPPFunction((ICPPASTFunctionDeclarator) funcDeclarator);
|
: new CPPFunction((ICPPASTFunctionDeclarator) funcDeclarator);
|
||||||
}
|
}
|
||||||
} else if (parent instanceof IASTSimpleDeclaration) {
|
} else if (simpleDecl != null) {
|
||||||
IType t1 = null, t2 = null;
|
IType t1 = null, t2 = null;
|
||||||
if (binding != null && binding instanceof IVariable && !(binding instanceof IIndexBinding)) {
|
if (binding != null && binding instanceof IVariable && !(binding instanceof IIndexBinding)) {
|
||||||
t1 = createType(declarator);
|
t1 = createType(declarator);
|
||||||
|
@ -665,7 +700,7 @@ public class CPPVisitor extends ASTQueries {
|
||||||
} else {
|
} else {
|
||||||
binding = new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION);
|
binding = new ProblemBinding(name, IProblemBinding.SEMANTIC_INVALID_REDECLARATION);
|
||||||
}
|
}
|
||||||
} else if (simpleDecl != null && simpleDecl.getParent() instanceof ICPPASTCompositeTypeSpecifier) {
|
} else if (simpleDecl.getParent() instanceof ICPPASTCompositeTypeSpecifier) {
|
||||||
binding = new CPPField(name);
|
binding = new CPPField(name);
|
||||||
} else {
|
} else {
|
||||||
binding = new CPPVariable(name);
|
binding = new CPPVariable(name);
|
||||||
|
@ -935,6 +970,9 @@ public class CPPVisitor extends ASTQueries {
|
||||||
type= getUltimateTypeUptoPointers(type);
|
type= getUltimateTypeUptoPointers(type);
|
||||||
}
|
}
|
||||||
if (type instanceof ICPPClassType) {
|
if (type instanceof ICPPClassType) {
|
||||||
|
if (type instanceof IIndexBinding) {
|
||||||
|
type= (((CPPASTTranslationUnit) fieldReference.getTranslationUnit())).mapToAST((ICPPClassType) type);
|
||||||
|
}
|
||||||
return ((ICPPClassType) type).getCompositeScope();
|
return ((ICPPClassType) type).getCompositeScope();
|
||||||
} else if (type instanceof ICPPUnknownBinding) {
|
} else if (type instanceof ICPPUnknownBinding) {
|
||||||
return ((ICPPUnknownBinding) type).asScope();
|
return ((ICPPUnknownBinding) type).asScope();
|
||||||
|
@ -1760,11 +1798,6 @@ public class CPPVisitor extends ASTQueries {
|
||||||
return basicType;
|
return basicType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IType createType(final IASTDeclSpecifier declSpecifier, final IASTDeclarator dtor) {
|
|
||||||
IType type = createType(declSpecifier);
|
|
||||||
return createType(type, dtor);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static IType get_type_info(IASTExpression expression) {
|
public static IType get_type_info(IASTExpression expression) {
|
||||||
try {
|
try {
|
||||||
IBinding[] std= expression.getTranslationUnit().getScope().find(STD);
|
IBinding[] std= expression.getTranslationUnit().getScope().find(STD);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2008 QNX Software Systems and others.
|
* Copyright (c) 2005, 2009 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* Doug Schaefer (QNX) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
|
@ -45,8 +45,6 @@ import org.eclipse.cdt.internal.core.pdom.db.IString;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
|
||||||
*
|
|
||||||
* This class represents a collection of symbols that can be linked together at
|
* This class represents a collection of symbols that can be linked together at
|
||||||
* link time. These are generally global symbols specific to a given language.
|
* link time. These are generally global symbols specific to a given language.
|
||||||
*/
|
*/
|
||||||
|
@ -61,6 +59,7 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
|
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
protected static final int RECORD_SIZE = PDOMNamedNode.RECORD_SIZE + 20;
|
protected static final int RECORD_SIZE = PDOMNamedNode.RECORD_SIZE + 20;
|
||||||
|
protected static final int[] FILE_LOCAL_REC_DUMMY = new int[]{0};
|
||||||
|
|
||||||
// node types
|
// node types
|
||||||
protected static final int LINKAGE= 0; // special one for myself
|
protected static final int LINKAGE= 0; // special one for myself
|
||||||
|
@ -204,13 +203,13 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
public abstract PDOMBinding adaptBinding(IBinding binding) throws CoreException;
|
public abstract PDOMBinding adaptBinding(IBinding binding) throws CoreException;
|
||||||
public abstract PDOMBinding addBinding(IASTName name) throws CoreException;
|
public abstract PDOMBinding addBinding(IASTName name) throws CoreException;
|
||||||
|
|
||||||
final protected int getLocalToFileRec(PDOMNode parent, IBinding binding) throws CoreException {
|
final protected int getLocalToFileRec(PDOMNode parent, IBinding binding, PDOMBinding glob) throws CoreException {
|
||||||
int rec= 0;
|
int rec= 0;
|
||||||
if (parent instanceof PDOMBinding) {
|
if (parent instanceof PDOMBinding) {
|
||||||
rec= ((PDOMBinding) parent).getLocalToFileRec();
|
rec= ((PDOMBinding) parent).getLocalToFileRec();
|
||||||
}
|
}
|
||||||
if (rec == 0) {
|
if (rec == 0) {
|
||||||
PDOMFile file= getLocalToFile(binding);
|
PDOMFile file= getLocalToFile(binding, glob);
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
rec= file.getRecord();
|
rec= file.getRecord();
|
||||||
}
|
}
|
||||||
|
@ -218,29 +217,29 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
return rec;
|
return rec;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected PDOMFile getLocalToFile(IBinding binding) throws CoreException {
|
protected PDOMFile getLocalToFile(IBinding binding, PDOMBinding glob) throws CoreException {
|
||||||
if (pdom instanceof WritablePDOM) {
|
if (pdom instanceof WritablePDOM) {
|
||||||
final WritablePDOM wpdom= (WritablePDOM) pdom;
|
final WritablePDOM wpdom= (WritablePDOM) pdom;
|
||||||
try {
|
try {
|
||||||
if (binding instanceof IField) {
|
if (binding instanceof IField) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
boolean checkInSourceOnly= false;
|
boolean checkIfInSourceOnly= false;
|
||||||
boolean requireDefinition= false;
|
boolean requireDefinition= false;
|
||||||
if (binding instanceof IVariable) {
|
if (binding instanceof IVariable) {
|
||||||
if (!(binding instanceof IField)) {
|
if (!(binding instanceof IField)) {
|
||||||
checkInSourceOnly= ((IVariable) binding).isStatic();
|
checkIfInSourceOnly= ((IVariable) binding).isStatic();
|
||||||
}
|
}
|
||||||
} else if (binding instanceof IFunction) {
|
} else if (binding instanceof IFunction) {
|
||||||
IFunction f= (IFunction) binding;
|
IFunction f= (IFunction) binding;
|
||||||
checkInSourceOnly= ASTInternal.isStatic(f, false);
|
checkIfInSourceOnly= ASTInternal.isStatic(f, false);
|
||||||
} else if (binding instanceof ITypedef || binding instanceof ICompositeType || binding instanceof IEnumeration) {
|
} else if (binding instanceof ITypedef || binding instanceof ICompositeType || binding instanceof IEnumeration) {
|
||||||
checkInSourceOnly= true;
|
checkIfInSourceOnly= true;
|
||||||
requireDefinition= true;
|
requireDefinition= true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkInSourceOnly) {
|
if (checkIfInSourceOnly) {
|
||||||
String path= ASTInternal.getDeclaredInSourceFileOnly(binding, requireDefinition);
|
String path= ASTInternal.getDeclaredInSourceFileOnly(binding, requireDefinition, glob);
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
return wpdom.getFileForASTPath(getLinkageID(), path);
|
return wpdom.getFileForASTPath(getLinkageID(), path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006, 2008 QNX Software Systems and others.
|
* Copyright (c) 2006, 2009 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* Doug Schaefer (QNX) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* IBM Corporation
|
* IBM Corporation
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
|
@ -43,7 +43,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* Container for c bindings
|
||||||
*/
|
*/
|
||||||
class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
||||||
|
|
||||||
|
@ -85,9 +85,10 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
pdomBinding = adaptBinding(parent, binding);
|
int[] localToFileHolder= {0};
|
||||||
|
pdomBinding = adaptBinding(parent, binding, localToFileHolder);
|
||||||
if (pdomBinding == null) {
|
if (pdomBinding == null) {
|
||||||
pdomBinding = createBinding(parent, binding);
|
pdomBinding = createBinding(parent, binding, localToFileHolder[0]);
|
||||||
if (pdomBinding != null) {
|
if (pdomBinding != null) {
|
||||||
pdom.putCachedResult(inputBinding, pdomBinding);
|
pdom.putCachedResult(inputBinding, pdomBinding);
|
||||||
}
|
}
|
||||||
|
@ -103,9 +104,8 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
||||||
return pdomBinding;
|
return pdomBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PDOMBinding createBinding(PDOMNode parent, IBinding binding) throws CoreException {
|
private PDOMBinding createBinding(PDOMNode parent, IBinding binding, int localToFile) throws CoreException {
|
||||||
PDOMBinding pdomBinding= null;
|
PDOMBinding pdomBinding= null;
|
||||||
PDOMNode inheritFileLocal= parent;
|
|
||||||
|
|
||||||
if (binding instanceof IField) { // must be before IVariable
|
if (binding instanceof IField) { // must be before IVariable
|
||||||
if (parent instanceof IPDOMMemberOwner)
|
if (parent instanceof IPDOMMemberOwner)
|
||||||
|
@ -125,7 +125,6 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
||||||
IType enumeration= ((IEnumerator)binding).getType();
|
IType enumeration= ((IEnumerator)binding).getType();
|
||||||
if (enumeration instanceof IEnumeration) {
|
if (enumeration instanceof IEnumeration) {
|
||||||
PDOMBinding pdomEnumeration = adaptBinding((IEnumeration) enumeration);
|
PDOMBinding pdomEnumeration = adaptBinding((IEnumeration) enumeration);
|
||||||
inheritFileLocal= pdomEnumeration;
|
|
||||||
if (pdomEnumeration instanceof PDOMCEnumeration)
|
if (pdomEnumeration instanceof PDOMCEnumeration)
|
||||||
pdomBinding = new PDOMCEnumerator(pdom, parent, (IEnumerator) binding, (PDOMCEnumeration)pdomEnumeration);
|
pdomBinding = new PDOMCEnumerator(pdom, parent, (IEnumerator) binding, (PDOMCEnumeration)pdomEnumeration);
|
||||||
}
|
}
|
||||||
|
@ -137,7 +136,7 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdomBinding != null) {
|
if (pdomBinding != null) {
|
||||||
pdomBinding.setLocalToFileRec(getLocalToFileRec(inheritFileLocal, binding));
|
pdomBinding.setLocalToFileRec(localToFile);
|
||||||
parent.addChild(pdomBinding);
|
parent.addChild(pdomBinding);
|
||||||
afterAddBinding(pdomBinding);
|
afterAddBinding(pdomBinding);
|
||||||
}
|
}
|
||||||
|
@ -228,10 +227,10 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final PDOMBinding adaptBinding(final IBinding inputBinding) throws CoreException {
|
public final PDOMBinding adaptBinding(final IBinding inputBinding) throws CoreException {
|
||||||
return adaptBinding(null, inputBinding);
|
return adaptBinding(null, inputBinding, FILE_LOCAL_REC_DUMMY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding) throws CoreException {
|
private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding, int[] localToFileHolder) throws CoreException {
|
||||||
if (inputBinding instanceof CompositeIndexBinding) {
|
if (inputBinding instanceof CompositeIndexBinding) {
|
||||||
inputBinding= ((CompositeIndexBinding) inputBinding).getRawBinding();
|
inputBinding= ((CompositeIndexBinding) inputBinding).getRawBinding();
|
||||||
}
|
}
|
||||||
|
@ -250,14 +249,14 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
result= doAdaptBinding(parent, binding);
|
result= doAdaptBinding(parent, binding, localToFileHolder);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
pdom.putCachedResult(inputBinding, result);
|
pdom.putCachedResult(inputBinding, result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final PDOMBinding doAdaptBinding(PDOMNode parent, final IBinding binding) throws CoreException {
|
private final PDOMBinding doAdaptBinding(PDOMNode parent, final IBinding binding, int[] localToFileHolder) throws CoreException {
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
parent= getAdaptedParent(binding);
|
parent= getAdaptedParent(binding);
|
||||||
}
|
}
|
||||||
|
@ -274,12 +273,24 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent == this) {
|
if (parent == this) {
|
||||||
int localToFileRec= getLocalToFileRec(inheritFileLocal, binding);
|
final int[] bindingTypes = new int[] {getBindingType(binding)};
|
||||||
return FindBinding.findBinding(getIndex(), getPDOM(), binding.getNameCharArray(), new int[] {getBindingType(binding)}, localToFileRec);
|
final char[] nameChars = binding.getNameCharArray();
|
||||||
|
PDOMBinding nonLocal= FindBinding.findBinding(getIndex(), getPDOM(), nameChars, bindingTypes, 0);
|
||||||
|
int localToFileRec= getLocalToFileRec(inheritFileLocal, binding, nonLocal);
|
||||||
|
if (localToFileRec == 0)
|
||||||
|
return nonLocal;
|
||||||
|
localToFileHolder[0]= localToFileRec;
|
||||||
|
return FindBinding.findBinding(getIndex(), getPDOM(), nameChars, bindingTypes, localToFileRec);
|
||||||
}
|
}
|
||||||
if (parent instanceof IPDOMMemberOwner) {
|
if (parent instanceof IPDOMMemberOwner) {
|
||||||
int localToFileRec= getLocalToFileRec(inheritFileLocal, binding);
|
final int[] bindingTypes = new int[] {getBindingType(binding)};
|
||||||
return FindBinding.findBinding(parent, getPDOM(), binding.getNameCharArray(), new int[] {getBindingType(binding)}, localToFileRec);
|
final char[] nameChars = binding.getNameCharArray();
|
||||||
|
PDOMBinding nonLocal= FindBinding.findBinding(parent, getPDOM(), nameChars, bindingTypes, 0);
|
||||||
|
int localToFileRec= getLocalToFileRec(inheritFileLocal, binding, nonLocal);
|
||||||
|
if (localToFileRec == 0)
|
||||||
|
return nonLocal;
|
||||||
|
localToFileHolder[0]= localToFileRec;
|
||||||
|
return FindBinding.findBinding(parent, getPDOM(), nameChars, bindingTypes, localToFileRec);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,7 @@ import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||||
import org.eclipse.cdt.internal.core.index.composite.CompositeIndexBinding;
|
import org.eclipse.cdt.internal.core.index.composite.CompositeIndexBinding;
|
||||||
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.IBTreeComparator;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMASTAdapter;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMASTAdapter;
|
||||||
|
@ -246,12 +247,13 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
pdomBinding = adaptBinding(parent, binding);
|
int fileLocalRec[]= {0};
|
||||||
|
pdomBinding = adaptBinding(parent, binding, fileLocalRec);
|
||||||
if (pdomBinding != null) {
|
if (pdomBinding != null) {
|
||||||
pdom.putCachedResult(inputBinding, pdomBinding);
|
pdom.putCachedResult(inputBinding, pdomBinding);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
pdomBinding = createBinding(parent, binding);
|
pdomBinding = createBinding(parent, binding, fileLocalRec[0]);
|
||||||
if (pdomBinding != null) {
|
if (pdomBinding != null) {
|
||||||
pdom.putCachedResult(inputBinding, pdomBinding);
|
pdom.putCachedResult(inputBinding, pdomBinding);
|
||||||
}
|
}
|
||||||
|
@ -293,9 +295,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PDOMBinding createBinding(PDOMNode parent, IBinding binding) throws CoreException, DOMException {
|
PDOMBinding createBinding(PDOMNode parent, IBinding binding, int fileLocalRec) throws CoreException, DOMException {
|
||||||
PDOMBinding pdomBinding= null;
|
PDOMBinding pdomBinding= null;
|
||||||
PDOMNode inheritFileLocal = parent;
|
|
||||||
|
|
||||||
// template parameters are created directly by their owners.
|
// template parameters are created directly by their owners.
|
||||||
if (binding instanceof ICPPTemplateParameter)
|
if (binding instanceof ICPPTemplateParameter)
|
||||||
|
@ -358,7 +359,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
PDOMBinding pdomEnumeration = adaptBinding((IEnumeration) enumeration);
|
PDOMBinding pdomEnumeration = adaptBinding((IEnumeration) enumeration);
|
||||||
if (pdomEnumeration instanceof PDOMCPPEnumeration) {
|
if (pdomEnumeration instanceof PDOMCPPEnumeration) {
|
||||||
pdomBinding = new PDOMCPPEnumerator(pdom, parent, etor, (PDOMCPPEnumeration)pdomEnumeration);
|
pdomBinding = new PDOMCPPEnumerator(pdom, parent, etor, (PDOMCPPEnumeration)pdomEnumeration);
|
||||||
inheritFileLocal= pdomEnumeration;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (binding instanceof ITypedef) {
|
} else if (binding instanceof ITypedef) {
|
||||||
|
@ -366,7 +366,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdomBinding != null) {
|
if (pdomBinding != null) {
|
||||||
pdomBinding.setLocalToFileRec(getLocalToFileRec(inheritFileLocal, binding));
|
pdomBinding.setLocalToFileRec(fileLocalRec);
|
||||||
parent.addChild(pdomBinding);
|
parent.addChild(pdomBinding);
|
||||||
afterAddBinding(pdomBinding);
|
afterAddBinding(pdomBinding);
|
||||||
}
|
}
|
||||||
|
@ -426,6 +426,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
|
|
||||||
private void addImplicitMethods(PDOMBinding type, ICPPClassType binding) throws CoreException {
|
private void addImplicitMethods(PDOMBinding type, ICPPClassType binding) throws CoreException {
|
||||||
try {
|
try {
|
||||||
|
final int fileLocalRec= type.getLocalToFileRec();
|
||||||
IScope scope = binding.getCompositeScope();
|
IScope scope = binding.getCompositeScope();
|
||||||
if (scope instanceof ICPPClassScope) {
|
if (scope instanceof ICPPClassScope) {
|
||||||
ICPPMethod[] implicit= ((ICPPClassScope) scope).getImplicitMethods();
|
ICPPMethod[] implicit= ((ICPPClassScope) scope).getImplicitMethods();
|
||||||
|
@ -433,7 +434,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
if (!(method instanceof IProblemBinding)) {
|
if (!(method instanceof IProblemBinding)) {
|
||||||
PDOMBinding pdomBinding= adaptBinding(method);
|
PDOMBinding pdomBinding= adaptBinding(method);
|
||||||
if (pdomBinding == null) {
|
if (pdomBinding == null) {
|
||||||
createBinding(type, method);
|
createBinding(type, method, fileLocalRec);
|
||||||
} else if (!pdomBinding.hasDefinition()) {
|
} else if (!pdomBinding.hasDefinition()) {
|
||||||
pdomBinding.update(this, method);
|
pdomBinding.update(this, method);
|
||||||
}
|
}
|
||||||
|
@ -550,10 +551,10 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final PDOMBinding adaptBinding(final IBinding inputBinding) throws CoreException {
|
public final PDOMBinding adaptBinding(final IBinding inputBinding) throws CoreException {
|
||||||
return adaptBinding(null, inputBinding);
|
return adaptBinding(null, inputBinding, FILE_LOCAL_REC_DUMMY);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding) throws CoreException {
|
private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding, int[] fileLocalRecHolder) throws CoreException {
|
||||||
if (cannotAdapt(inputBinding)) {
|
if (cannotAdapt(inputBinding)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -569,7 +570,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
result= doAdaptBinding(parent, binding);
|
result= doAdaptBinding(parent, binding, fileLocalRecHolder);
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
pdom.putCachedResult(inputBinding, result);
|
pdom.putCachedResult(inputBinding, result);
|
||||||
}
|
}
|
||||||
|
@ -579,7 +580,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
/**
|
/**
|
||||||
* Find the equivalent binding, or binding place holder within this PDOM
|
* Find the equivalent binding, or binding place holder within this PDOM
|
||||||
*/
|
*/
|
||||||
private final PDOMBinding doAdaptBinding(PDOMNode parent, IBinding binding) throws CoreException {
|
private final PDOMBinding doAdaptBinding(PDOMNode parent, IBinding binding, int[] fileLocalRecHolder) throws CoreException {
|
||||||
if (parent == null) {
|
if (parent == null) {
|
||||||
parent= adaptOrAddParent(false, binding);
|
parent= adaptOrAddParent(false, binding);
|
||||||
}
|
}
|
||||||
|
@ -596,21 +597,33 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parent == this) {
|
if (parent == this) {
|
||||||
int localToFileRec= getLocalToFileRec(inheritFileLocal, binding);
|
PDOMBinding glob= CPPFindBinding.findBinding(getIndex(), this, binding, 0);
|
||||||
return CPPFindBinding.findBinding(getIndex(), this, binding, localToFileRec);
|
final int loc= getLocalToFileRec(inheritFileLocal, binding, glob);
|
||||||
|
if (loc == 0)
|
||||||
|
return glob;
|
||||||
|
fileLocalRecHolder[0]= loc;
|
||||||
|
return CPPFindBinding.findBinding(getIndex(), this, binding, loc);
|
||||||
}
|
}
|
||||||
if (parent instanceof PDOMCPPNamespace) {
|
if (parent instanceof PDOMCPPNamespace) {
|
||||||
int localToFileRec= getLocalToFileRec(inheritFileLocal, binding);
|
final BTree btree = ((PDOMCPPNamespace) parent).getIndex();
|
||||||
return CPPFindBinding.findBinding(((PDOMCPPNamespace) parent).getIndex(), this, binding,
|
PDOMBinding glob= CPPFindBinding.findBinding(btree, this, binding, 0);
|
||||||
localToFileRec);
|
final int loc= getLocalToFileRec(inheritFileLocal, binding, glob);
|
||||||
|
if (loc == 0)
|
||||||
|
return glob;
|
||||||
|
fileLocalRecHolder[0]= loc;
|
||||||
|
return CPPFindBinding.findBinding(btree, this, binding, loc);
|
||||||
}
|
}
|
||||||
if (binding instanceof ICPPTemplateParameter && parent instanceof IPDOMCPPTemplateParameterOwner) {
|
if (binding instanceof ICPPTemplateParameter && parent instanceof IPDOMCPPTemplateParameterOwner) {
|
||||||
return (PDOMBinding) ((IPDOMCPPTemplateParameterOwner) parent).adaptTemplateParameter(
|
return (PDOMBinding) ((IPDOMCPPTemplateParameterOwner) parent).adaptTemplateParameter(
|
||||||
(ICPPTemplateParameter) binding);
|
(ICPPTemplateParameter) binding);
|
||||||
}
|
}
|
||||||
if (parent instanceof IPDOMMemberOwner) {
|
if (parent instanceof IPDOMMemberOwner) {
|
||||||
int localToFileRec= getLocalToFileRec(inheritFileLocal, binding);
|
PDOMBinding glob= CPPFindBinding.findBinding(parent, this, binding, 0);
|
||||||
return CPPFindBinding.findBinding(parent, this, binding, localToFileRec);
|
final int loc= getLocalToFileRec(inheritFileLocal, binding, glob);
|
||||||
|
if (loc == 0)
|
||||||
|
return glob;
|
||||||
|
fileLocalRecHolder[0]= loc;
|
||||||
|
return CPPFindBinding.findBinding(parent, this, binding, loc);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -957,7 +970,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected PDOMFile getLocalToFile(IBinding binding) throws CoreException {
|
protected PDOMFile getLocalToFile(IBinding binding, PDOMBinding glob) throws CoreException {
|
||||||
if (pdom instanceof WritablePDOM) {
|
if (pdom instanceof WritablePDOM) {
|
||||||
final WritablePDOM wpdom= (WritablePDOM) pdom;
|
final WritablePDOM wpdom= (WritablePDOM) pdom;
|
||||||
PDOMFile file= null;
|
PDOMFile file= null;
|
||||||
|
@ -967,7 +980,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
file= wpdom.getFileForASTPath(getLinkageID(), path);
|
file= wpdom.getFileForASTPath(getLinkageID(), path);
|
||||||
}
|
}
|
||||||
} else if (binding instanceof ICPPNamespaceAlias) {
|
} else if (binding instanceof ICPPNamespaceAlias) {
|
||||||
String path= ASTInternal.getDeclaredInSourceFileOnly(binding, false);
|
String path= ASTInternal.getDeclaredInSourceFileOnly(binding, false, glob);
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
file= wpdom.getFileForASTPath(getLinkageID(), path);
|
file= wpdom.getFileForASTPath(getLinkageID(), path);
|
||||||
}
|
}
|
||||||
|
@ -977,7 +990,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
IBinding owner= binding.getOwner();
|
IBinding owner= binding.getOwner();
|
||||||
if (owner instanceof ICPPNamespace) {
|
if (owner instanceof ICPPNamespace) {
|
||||||
if (owner.getNameCharArray().length == 0) {
|
if (owner.getNameCharArray().length == 0) {
|
||||||
String path= ASTInternal.getDeclaredInSourceFileOnly(owner, false);
|
String path= ASTInternal.getDeclaredInSourceFileOnly(owner, false, glob);
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
file= wpdom.getFileForASTPath(getLinkageID(), path);
|
file= wpdom.getFileForASTPath(getLinkageID(), path);
|
||||||
}
|
}
|
||||||
|
@ -993,6 +1006,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
if (binding instanceof ICPPMember) {
|
if (binding instanceof ICPPMember) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return super.getLocalToFile(binding);
|
return super.getLocalToFile(binding, glob);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue