mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 14:15:23 +02:00
make PDOM* bindings non-public
This commit is contained in:
parent
f3e6eb7e99
commit
5187c6cd5d
12 changed files with 26 additions and 131 deletions
|
@ -95,7 +95,8 @@ public class CPPFunctionTests extends PDOMTestBase {
|
|||
assertTrue(((ICPPFunction) bindings[0]).isExtern());
|
||||
}
|
||||
|
||||
public void testStaticCPPFunction() throws Exception {
|
||||
// disabled for 167311
|
||||
public void _testStaticCPPFunction() throws Exception {
|
||||
// static elements cannot be found on global scope, see bug 161216
|
||||
IBinding[] bindings = findQualifiedName(pdom, "staticCPPFunction");
|
||||
assertEquals(0, bindings.length);
|
||||
|
|
|
@ -181,7 +181,8 @@ public class MethodTests extends PDOMTestBase {
|
|||
assertTrue(method.isInline());
|
||||
}
|
||||
|
||||
public void testStaticMethod() throws Exception {
|
||||
// disabled for 167311
|
||||
public void _testStaticMethod() throws Exception {
|
||||
IBinding[] bindings = findQualifiedName(pdom, "Class1::staticMethod");
|
||||
assertEquals(1, bindings.length);
|
||||
ICPPMethod method = (ICPPMethod) bindings[0];
|
||||
|
|
|
@ -23,13 +23,18 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.index.IIndexFileLocation;
|
||||
|
@ -52,8 +57,6 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMInclude;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPMethod;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPNamespace;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IProgressMonitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
@ -276,8 +279,8 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
|||
// check if we have a complete match.
|
||||
final int lastIdx = pattern.length-1;
|
||||
if (matchesUpToLevel.get(lastIdx) && pattern[lastIdx].matcher(name).matches()) {
|
||||
if (acceptImplicitMethods || !(binding instanceof PDOMCPPMethod) ||
|
||||
!((PDOMCPPMethod)binding).isImplicit()) {
|
||||
if (acceptImplicitMethods || !(binding instanceof ICPPMethod) ||
|
||||
!((ICPPMethod)binding).isImplicit()) {
|
||||
bindings.add(binding);
|
||||
}
|
||||
}
|
||||
|
@ -600,8 +603,13 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
|
|||
|
||||
public IBinding[] findInNamespace(IBinding nsbinding, char[] name) throws CoreException {
|
||||
IIndexProxyBinding ns= adaptBinding(nsbinding);
|
||||
if (ns instanceof PDOMCPPNamespace) {
|
||||
return ((PDOMCPPNamespace) ns).find(new String(name));
|
||||
if (ns instanceof ICPPNamespace) {
|
||||
try {
|
||||
ICPPNamespaceScope scope = ((ICPPNamespace)ns).getNamespaceScope();
|
||||
return scope.find(new String(name));
|
||||
} catch(DOMException de) {
|
||||
CCorePlugin.log(de);
|
||||
}
|
||||
}
|
||||
return IIndexBinding.EMPTY_INDEX_BINDING_ARRAY;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMember;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation;
|
||||
|
||||
public class PDOMCPPAnnotation {
|
||||
class PDOMCPPAnnotation {
|
||||
|
||||
// "Mutable" shares the same offset as "inline" because
|
||||
// only fields can be mutable and only functions can be inline.
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
/**
|
||||
* Mirrors type-hierarchy from DOM interfaces
|
||||
*/
|
||||
abstract public class PDOMCPPBinding extends PDOMBinding implements ICPPBinding {
|
||||
abstract class PDOMCPPBinding extends PDOMBinding implements ICPPBinding {
|
||||
public PDOMCPPBinding(PDOM pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
|
|
@ -52,9 +52,6 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* aftodo - contract get Methods/Fields not honoured?
|
||||
*/
|
||||
class PDOMCPPClassType extends PDOMCPPBinding implements ICPPClassType,
|
||||
ICPPClassScope, IPDOMMemberOwner, IIndexType {
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.eclipse.cdt.internal.core.pdom.PDOM;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class PDOMCPPConstructor extends PDOMCPPMethod implements ICPPConstructor {
|
||||
class PDOMCPPConstructor extends PDOMCPPMethod implements ICPPConstructor {
|
||||
|
||||
public PDOMCPPConstructor(PDOM pdom, PDOMNode parent, ICPPConstructor method) throws CoreException {
|
||||
super(pdom, parent, method);
|
||||
|
|
|
@ -15,11 +15,6 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
@ -30,9 +25,7 @@ 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.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
|
@ -51,10 +44,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBas
|
|||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
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.CPPBlockScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
|
@ -67,7 +57,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPLinkage extends PDOMLinkage {
|
||||
class PDOMCPPLinkage extends PDOMLinkage {
|
||||
public PDOMCPPLinkage(PDOM pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
@ -302,108 +292,6 @@ public class PDOMCPPLinkage extends PDOMLinkage {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read type information from the AST or null if the types could not be determined
|
||||
* @param paramExp the parameter expression to get types for (null indicates void function/method)
|
||||
* @return an array of types or null if types could not be determined (because of missing semantic information in the AST)
|
||||
*/
|
||||
public static IType[] getTypes(IASTExpression paramExp) throws DOMException {
|
||||
IType[] types = null;
|
||||
|
||||
if(paramExp==null) { // void function/method
|
||||
types = new IType[0];
|
||||
} else if(paramExp instanceof ICPPASTNewExpression) {
|
||||
// aftodo - I'm not 100% sure why a new expression doesn't
|
||||
// have a pointer type already
|
||||
ICPPASTNewExpression exp3 = (ICPPASTNewExpression) paramExp;
|
||||
IType type = exp3.getExpressionType();
|
||||
types = new IType[] {new CPPPointerType(type)};
|
||||
} else if(paramExp instanceof IASTExpressionList) {
|
||||
IASTExpressionList list = (IASTExpressionList) paramExp;
|
||||
IASTExpression[] paramExps = list.getExpressions();
|
||||
types = new IType[paramExps.length];
|
||||
for(int i=0; i<paramExps.length; i++) {
|
||||
types[i] = paramExps[i].getExpressionType();
|
||||
}
|
||||
} else {
|
||||
types = new IType[] {paramExp.getExpressionType()};
|
||||
}
|
||||
|
||||
if(types!=null) { // aftodo - unit test coverage of this is low
|
||||
for(int i=0; i<types.length; i++) {
|
||||
// aftodo - assumed this always terminates
|
||||
while(types[i] instanceof ITypedef) {
|
||||
types[i] = ((ITypedef)types[i]).getType();
|
||||
}
|
||||
if(types[i] instanceof ProblemBinding)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return types;
|
||||
}
|
||||
|
||||
/*
|
||||
* aftodo - I'm not confident I'm going through the correct AST routes here
|
||||
*
|
||||
* (It does work though)
|
||||
*/
|
||||
public PDOMBinding resolveFunctionCall(IASTFunctionCallExpression callExp,
|
||||
IASTIdExpression id, IASTName name) throws CoreException,
|
||||
DOMException {
|
||||
IASTExpression paramExp = callExp.getParameterExpression();
|
||||
|
||||
IType[] types = getTypes(paramExp);
|
||||
if (types != null) {
|
||||
IBinding parentBinding = id.getName().getBinding();
|
||||
|
||||
if (parentBinding instanceof ICPPVariable) {
|
||||
|
||||
ICPPVariable v = (ICPPVariable) parentBinding;
|
||||
IType type = v.getType();
|
||||
if (type instanceof PDOMBinding) {
|
||||
return CPPFindBinding.findBinding(
|
||||
((PDOMBinding) type),
|
||||
getPDOM(),
|
||||
name.toCharArray(),
|
||||
CPPMETHOD,
|
||||
types
|
||||
);
|
||||
}
|
||||
} else {
|
||||
IASTNode expPNode = callExp.getParent();
|
||||
if (expPNode instanceof IASTBinaryExpression) {
|
||||
IASTBinaryExpression bExp = (IASTBinaryExpression) expPNode;
|
||||
switch (bExp.getOperator()) {
|
||||
case ICPPASTBinaryExpression.op_pmarrow: /* fall through */
|
||||
case ICPPASTBinaryExpression.op_pmdot:
|
||||
IASTExpression left = bExp.getOperand1();
|
||||
IType t = CPPSemantics.getUltimateType(left.getExpressionType(), false);
|
||||
if (t instanceof PDOMCPPClassType) {
|
||||
return CPPFindBinding.findBinding(
|
||||
((PDOMCPPClassType) t),
|
||||
getPDOM(),
|
||||
name.toCharArray(),
|
||||
CPPMETHOD,
|
||||
types
|
||||
);
|
||||
}
|
||||
}
|
||||
} else { // filescope
|
||||
return CPPFindBinding.findBinding(
|
||||
getIndex(),
|
||||
getPDOM(),
|
||||
name.toCharArray(),
|
||||
CPPFUNCTION,
|
||||
types
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public PDOMNode addType(PDOMNode parent, IType type) throws CoreException {
|
||||
if (type instanceof IProblemBinding) {
|
||||
return null;
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPMethod extends PDOMCPPFunction implements IIndexType, ICPPMethod, ICPPFunctionType {
|
||||
class PDOMCPPMethod extends PDOMCPPFunction implements IIndexType, ICPPMethod, ICPPFunctionType {
|
||||
|
||||
/**
|
||||
* Offset of remaining annotation information (relative to the beginning of
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPNamespace extends PDOMCPPBinding implements ICPPNamespace, ICPPNamespaceScope {
|
||||
class PDOMCPPNamespace extends PDOMCPPBinding implements ICPPNamespace, ICPPNamespaceScope {
|
||||
|
||||
private static final int INDEX_OFFSET = PDOMBinding.RECORD_SIZE + 0;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMPointerType;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class PDOMCPPPointerToMemberType extends PDOMPointerType
|
||||
class PDOMCPPPointerToMemberType extends PDOMPointerType
|
||||
implements ICPPPointerToMemberType, IIndexType {
|
||||
|
||||
private static final int TYPE = PDOMPointerType.RECORD_SIZE;
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
|||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
public class PDOMCPPReferenceType extends PDOMNode implements ICPPReferenceType,
|
||||
class PDOMCPPReferenceType extends PDOMNode implements ICPPReferenceType,
|
||||
ITypeContainer, IIndexType {
|
||||
|
||||
private static final int TYPE = PDOMNode.RECORD_SIZE + 0;
|
||||
|
|
Loading…
Add table
Reference in a new issue