1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fixed testFunctionTemplateWithUsing test case.

This commit is contained in:
Sergey Prigogin 2008-04-28 05:35:38 +00:00
parent 6aa23c119f
commit 98cf46261c
2 changed files with 86 additions and 101 deletions

View file

@ -2074,7 +2074,7 @@ public class AST2TemplateTests extends AST2BaseTest {
// using ns::pair; // using ns::pair;
// using ns::make_pair; // using ns::make_pair;
// pair<int, int> p = make_pair(1, 2); // pair<int, int> p = make_pair(1, 2);
public void _testFunctionTemplateWithUsing() throws Exception { public void testFunctionTemplateWithUsing() throws Exception {
BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true); BindingAssertionHelper bh= new BindingAssertionHelper(getAboveComment(), true);
ICPPFunction fn= bh.assertNonProblem("make_pair(1", 9, ICPPFunction.class); ICPPFunction fn= bh.assertNonProblem("make_pair(1", 9, ICPPFunction.class);
} }

View file

@ -540,9 +540,9 @@ public class CPPSemantics {
else else
obj = ArrayUtil.addAll(Object.class, (Object[])obj, (Object[]) so); obj = ArrayUtil.addAll(Object.class, (Object[])obj, (Object[]) so);
} else { } else {
if (so instanceof IBinding || so instanceof IASTName) if (so instanceof IBinding || so instanceof IASTName) {
obj = new Object[] { obj, so }; obj = new Object[] { obj, so };
else { } else {
Object[] temp = new Object[((Object[])so).length + 1]; Object[] temp = new Object[((Object[])so).length + 1];
temp[0] = obj; temp[0] = obj;
obj = ArrayUtil.addAll(Object.class, temp, (Object[]) so); obj = ArrayUtil.addAll(Object.class, temp, (Object[]) so);
@ -668,8 +668,7 @@ public class CPPSemantics {
} }
if ((!data.contentAssist && (data.problem != null || data.hasResults())) || if ((!data.contentAssist && (data.problem != null || data.hasResults())) ||
(friendInLocalClass && !(scope instanceof ICPPClassScope))) (friendInLocalClass && !(scope instanceof ICPPClassScope))) {
{
return; return;
} }
@ -779,8 +778,9 @@ public class CPPSemantics {
} else if (data.astName != null) { } else if (data.astName != null) {
inherited = parent.getBindings(data.astName, true, data.prefixLookup); inherited = parent.getBindings(data.astName, true, data.prefixLookup);
} }
} else } else {
inherited = lookupInScope(data, parent, null); inherited = lookupInScope(data, parent, null);
}
if (inherited == null || data.contentAssist) { if (inherited == null || data.contentAssist) {
Object temp = lookupInParents(data, parent); Object temp = lookupInParents(data, parent);
@ -990,7 +990,7 @@ public class CPPSemantics {
if (data == null) { if (data == null) {
data = new LookupData(); data = new LookupData();
} }
final boolean isIndexBased= data.tu == null ? false : data.tu.getIndex() != null; final boolean isIndexBased= data.tu != null && data.tu.getIndex() != null;
Object possible = null; Object possible = null;
IASTNode[] nodes = null; IASTNode[] nodes = null;
IASTNode parent = ASTInternal.getPhysicalNodeOfScope(scope); IASTNode parent = ASTInternal.getPhysicalNodeOfScope(scope);
@ -1440,14 +1440,13 @@ public class CPPSemantics {
public static IBinding resolveAmbiguities(IASTName name, Object[] bindings) { public static IBinding resolveAmbiguities(IASTName name, Object[] bindings) {
bindings = ArrayUtil.trim(Object.class, bindings); bindings = ArrayUtil.trim(Object.class, bindings);
if (bindings == null || bindings.length == 0) if (bindings == null || bindings.length == 0) {
return null; return null;
else if (bindings.length == 1) { } else if (bindings.length == 1) {
if (bindings[0] instanceof IBinding) if (bindings[0] instanceof IBinding)
return (IBinding) bindings[0]; return (IBinding) bindings[0];
else if (bindings[0] instanceof IASTName && ((IASTName) bindings[0]).getBinding() != null) else if (bindings[0] instanceof IASTName && ((IASTName) bindings[0]).getBinding() != null)
return ((IASTName) bindings[0]).getBinding(); return ((IASTName) bindings[0]).getBinding();
} }
if (name.getPropertyInParent() != STRING_LOOKUP_PROPERTY) { if (name.getPropertyInParent() != STRING_LOOKUP_PROPERTY) {
@ -1517,8 +1516,8 @@ public class CPPSemantics {
if (pointOfDecl < 0 && nd != null) { if (pointOfDecl < 0 && nd != null) {
ASTNodeProperty prop = nd.getPropertyInParent(); ASTNodeProperty prop = nd.getPropertyInParent();
//point of declaration for a name is immediately after its complete declarator and before its initializer
if (prop == IASTDeclarator.DECLARATOR_NAME || nd instanceof IASTDeclarator) { if (prop == IASTDeclarator.DECLARATOR_NAME || nd instanceof IASTDeclarator) {
// point of declaration for a name is immediately after its complete declarator and before its initializer
IASTDeclarator dtor = (IASTDeclarator)((nd instanceof IASTDeclarator) ? nd : nd.getParent()); IASTDeclarator dtor = (IASTDeclarator)((nd instanceof IASTDeclarator) ? nd : nd.getParent());
while (dtor.getParent() instanceof IASTDeclarator) while (dtor.getParent() instanceof IASTDeclarator)
dtor = (IASTDeclarator) dtor.getParent(); dtor = (IASTDeclarator) dtor.getParent();
@ -1527,9 +1526,8 @@ public class CPPSemantics {
pointOfDecl = ((ASTNode)init).getOffset() - 1; pointOfDecl = ((ASTNode)init).getOffset() - 1;
else else
pointOfDecl = ((ASTNode)dtor).getOffset() + ((ASTNode)dtor).getLength(); pointOfDecl = ((ASTNode)dtor).getOffset() + ((ASTNode)dtor).getLength();
} } else if (prop == IASTEnumerator.ENUMERATOR_NAME) {
//point of declaration for an enumerator is immediately after it enumerator-definition // point of declaration for an enumerator is immediately after it enumerator-definition
else if (prop == IASTEnumerator.ENUMERATOR_NAME) {
IASTEnumerator enumtor = (IASTEnumerator) nd.getParent(); IASTEnumerator enumtor = (IASTEnumerator) nd.getParent();
if (enumtor.getValue() != null) { if (enumtor.getValue() != null) {
ASTNode exp = (ASTNode) enumtor.getValue(); ASTNode exp = (ASTNode) enumtor.getValue();
@ -1543,8 +1541,9 @@ public class CPPSemantics {
} else if (prop == ICPPASTNamespaceAlias.ALIAS_NAME) { } else if (prop == ICPPASTNamespaceAlias.ALIAS_NAME) {
nd = (ASTNode) nd.getParent(); nd = (ASTNode) nd.getParent();
pointOfDecl = nd.getOffset() + nd.getLength(); pointOfDecl = nd.getOffset() + nd.getLength();
} else } else {
pointOfDecl = nd.getOffset() + nd.getLength(); pointOfDecl = nd.getOffset() + nd.getLength();
}
} }
return (pointOfDecl < pointOfRef); return (pointOfDecl < pointOfRef);
} }
@ -1553,7 +1552,7 @@ public class CPPSemantics {
if (!data.hasResults() || data.contentAssist) if (!data.hasResults() || data.contentAssist)
return null; return null;
final boolean indexBased= data.tu == null ? false : data.tu.getIndex() != null; final boolean indexBased= data.tu != null && data.tu.getIndex() != null;
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ObjectSet<IFunction> fns= ObjectSet.EMPTY_SET, templateFns= ObjectSet.EMPTY_SET; ObjectSet<IFunction> fns= ObjectSet.EMPTY_SET, templateFns= ObjectSet.EMPTY_SET;
IBinding type = null; IBinding type = null;
@ -1570,9 +1569,9 @@ public class CPPSemantics {
if (!name.isReference()) { if (!name.isReference()) {
checkResolvedNamesOnly= true; checkResolvedNamesOnly= true;
declaredBefore= true; declaredBefore= true;
} } else {
else
continue; continue;
}
} }
if (o instanceof IASTName) { if (o instanceof IASTName) {
IASTName on= (IASTName) o; IASTName on= (IASTName) o;
@ -1581,8 +1580,9 @@ public class CPPSemantics {
continue; continue;
} else if (o instanceof IBinding) { } else if (o instanceof IBinding) {
temp = (IBinding) o; temp = (IBinding) o;
} else } else {
continue; continue;
}
if (!(temp instanceof ICPPMember) && !declaredBefore) if (!(temp instanceof ICPPMember) && !declaredBefore)
continue; continue;
@ -1610,8 +1610,7 @@ public class CPPSemantics {
if (!fnsFromAST) { if (!fnsFromAST) {
fns.put(function); fns.put(function);
} }
} } else {
else {
if (!fnsFromAST) { if (!fnsFromAST) {
fns.clear(); fns.clear();
fnsFromAST= true; fnsFromAST= true;
@ -1623,19 +1622,17 @@ public class CPPSemantics {
if (type == null) { if (type == null) {
type = temp; type = temp;
} else if (type instanceof ICPPClassTemplate && temp instanceof ICPPSpecialization && } else if (type instanceof ICPPClassTemplate && temp instanceof ICPPSpecialization &&
((IType) type).isSameType((IType) ((ICPPSpecialization)temp).getSpecializedBinding())) ((IType) type).isSameType((IType) ((ICPPSpecialization)temp).getSpecializedBinding())) {
{ // ok, stay with the template, the specialization, if applicable, will come out during instantiation
//ok, stay with the template, the specialization, if applicable, will come out during instantiation
} else if (type != temp && !((IType)type).isSameType((IType) temp)) { } else if (type != temp && !((IType)type).isSameType((IType) temp)) {
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name()); return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name());
} }
} else { } else {
if (obj == null) if (obj == null) {
obj = temp; obj = temp;
else if (obj == temp) { } else if (obj == temp) {
//ok, delegates are synonyms //ok, delegates are synonyms
} } else {
else {
// ignore index stuff in case we have bindings from the ast // ignore index stuff in case we have bindings from the ast
boolean ibobj= isFromIndex(obj); boolean ibobj= isFromIndex(obj);
boolean ibtemp= isFromIndex(temp); boolean ibtemp= isFromIndex(temp);
@ -1643,9 +1640,9 @@ public class CPPSemantics {
if (ibobj != ibtemp) { if (ibobj != ibtemp) {
if (ibobj) if (ibobj)
obj= temp; obj= temp;
} } else {
else
return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name()); return new ProblemBinding(data.astName, IProblemBinding.SEMANTIC_AMBIGUOUS_LOOKUP, data.name());
}
} }
} }
} }
@ -1660,6 +1657,7 @@ public class CPPSemantics {
// if (fns == null) return type; // if (fns == null) return type;
bindings = (IBinding[]) ArrayUtil.append(IBinding.class, bindings, type); bindings = (IBinding[]) ArrayUtil.append(IBinding.class, bindings, type);
bindings = (IBinding[]) ArrayUtil.addAll(IBinding.class, bindings, fns.keyArray()); bindings = (IBinding[]) ArrayUtil.addAll(IBinding.class, bindings, fns.keyArray());
bindings = (IBinding[]) ArrayUtil.addAll(IBinding.class, bindings, templateFns.keyArray());
} }
bindings = (IBinding[]) ArrayUtil.trim(IBinding.class, bindings); bindings = (IBinding[]) ArrayUtil.trim(IBinding.class, bindings);
ICPPUsingDeclaration composite = new CPPUsingDeclaration(data.astName, bindings); ICPPUsingDeclaration composite = new CPPUsingDeclaration(data.astName, bindings);
@ -1669,7 +1667,7 @@ public class CPPSemantics {
int numTemplateFns = templateFns.size(); int numTemplateFns = templateFns.size();
if (numTemplateFns > 0) { if (numTemplateFns > 0) {
if (data.functionParameters != null && !data.forDefinition()) { if (data.functionParameters != null && !data.forDefinition()) {
IFunction[] fs = CPPTemplates.selectTemplateFunctions(templateFns, data.functionParameters, data.astName); IFunction[] fs = CPPTemplates.selectTemplateFunctions(templateFns, data.functionParameters, data.astName);
if (fs != null && fs.length > 0) { if (fs != null && fs.length > 0) {
if (fns == ObjectSet.EMPTY_SET) if (fns == ObjectSet.EMPTY_SET)
fns = new ObjectSet<IFunction>(fs.length); fns = new ObjectSet<IFunction>(fs.length);
@ -1728,7 +1726,7 @@ public class CPPSemantics {
int numParameters = (fParams != null) ? fParams.length : 0; int numParameters = (fParams != null) ? fParams.length : 0;
int num; int num;
boolean def = data.forDefinition(); boolean def = data.forDefinition();
//Trim the list down to the set of viable functions // Trim the list down to the set of viable functions
IFunction function = null; IFunction function = null;
int size = functions.length; int size = functions.length;
for (int i = 0; i < size && functions[i] != null; i++) { for (int i = 0; i < size && functions[i] != null; i++) {
@ -1739,16 +1737,15 @@ public class CPPSemantics {
} }
num = function.getParameters().length; num = function.getParameters().length;
//if there are m arguments in the list, all candidate functions having m parameters // if there are m arguments in the list, all candidate functions having m parameters
//are viable // are viable
if (num == numParameters) { if (num == numParameters) {
if (def && !isMatchingFunctionDeclaration(function, data)) { if (def && !isMatchingFunctionDeclaration(function, data)) {
functions[i] = null; functions[i] = null;
} }
continue; continue;
} } else if (numParameters == 0 && num == 1) {
//check for void // check for void
else if (numParameters == 0 && num == 1) {
IParameter param = function.getParameters()[0]; IParameter param = function.getParameters()[0];
IType t = param.getType(); IType t = param.getType();
if (t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void) if (t instanceof IBasicType && ((IBasicType)t).getType() == IBasicType.t_void)
@ -1756,25 +1753,24 @@ public class CPPSemantics {
} }
if (def) { if (def) {
//if this is for a definition, we had to match the number of parameters. // if this is for a definition, we had to match the number of parameters.
functions[i] = null; functions[i] = null;
continue; continue;
} }
//A candidate function having fewer than m parameters is viable only if it has an
//ellipsis in its parameter list.
if (num < numParameters) { if (num < numParameters) {
// A candidate function having fewer than m parameters is viable only if it has an
// ellipsis in its parameter list.
if (function.takesVarArgs()) if (function.takesVarArgs())
continue; continue;
//not enough parameters, remove it // not enough parameters, remove it
functions[i] = null; functions[i] = null;
} } else {
//a candidate function having more than m parameters is viable only if the (m+1)-st //a candidate function having more than m parameters is viable only if the (m+1)-st
//parameter has a default argument //parameter has a default argument
else {
IParameter[] params = function.getParameters(); IParameter[] params = function.getParameters();
for (int j = num - 1; j >= numParameters; j--) { for (int j = num - 1; j >= numParameters; j--) {
if (!((ICPPParameter)params[j]).hasDefaultValue()) { if (!((ICPPParameter) params[j]).hasDefaultValue()) {
functions[i] = null; functions[i] = null;
break; break;
} }
@ -1957,8 +1953,9 @@ public class CPPSemantics {
} else { } else {
target = targetParameters[j]; target = targetParameters[j];
} }
} else } else {
varArgs = true; varArgs = true;
}
if (isImpliedObject && ASTInternal.isStatic(currFn, false)) { if (isImpliedObject && ASTInternal.isStatic(currFn, false)) {
//13.3.1-4 for static member functions, the implicit object parameter is considered to match any object //13.3.1-4 for static member functions, the implicit object parameter is considered to match any object
@ -2012,23 +2009,22 @@ public class CPPSemantics {
ambiguous |= (hasWorse && hasBetter) || (!hasWorse && !hasBetter); ambiguous |= (hasWorse && hasBetter) || (!hasWorse && !hasBetter);
if (!hasWorse) { if (!hasWorse) {
//if they are both template functions, we can order them that way // if they are both template functions, we can order them that way
boolean bestIsTemplate = (bestFn instanceof ICPPSpecialization && boolean bestIsTemplate = (bestFn instanceof ICPPSpecialization &&
((ICPPSpecialization)bestFn).getSpecializedBinding() instanceof ICPPFunctionTemplate); ((ICPPSpecialization) bestFn).getSpecializedBinding() instanceof ICPPFunctionTemplate);
boolean currIsTemplate = (currFn instanceof ICPPSpecialization && boolean currIsTemplate = (currFn instanceof ICPPSpecialization &&
((ICPPSpecialization)currFn).getSpecializedBinding() instanceof ICPPFunctionTemplate); ((ICPPSpecialization) currFn).getSpecializedBinding() instanceof ICPPFunctionTemplate);
if (bestIsTemplate && currIsTemplate) { if (bestIsTemplate && currIsTemplate) {
ICPPFunctionTemplate t1 = (ICPPFunctionTemplate) ((ICPPSpecialization)bestFn).getSpecializedBinding(); ICPPFunctionTemplate t1 = (ICPPFunctionTemplate) ((ICPPSpecialization) bestFn).getSpecializedBinding();
ICPPFunctionTemplate t2 = (ICPPFunctionTemplate) ((ICPPSpecialization)currFn).getSpecializedBinding(); ICPPFunctionTemplate t2 = (ICPPFunctionTemplate) ((ICPPSpecialization) currFn).getSpecializedBinding();
int order = CPPTemplates.orderTemplateFunctions(t1, t2); int order = CPPTemplates.orderTemplateFunctions(t1, t2);
if (order < 0) { if (order < 0) {
hasBetter = true; hasBetter = true;
} else if (order > 0) { } else if (order > 0) {
ambiguous = false; ambiguous = false;
} }
} } else if (bestIsTemplate && !currIsTemplate) {
//we prefer normal functions over template functions, unless we specified template arguments // we prefer normal functions over template functions, unless we specified template arguments
else if (bestIsTemplate && !currIsTemplate) {
if (data.preferTemplateFunctions()) if (data.preferTemplateFunctions())
ambiguous = false; ambiguous = false;
else else
@ -2038,7 +2034,6 @@ public class CPPSemantics {
hasBetter = true; hasBetter = true;
else else
ambiguous = false; ambiguous = false;
} }
if (hasBetter) { if (hasBetter) {
//the new best function. //the new best function.
@ -2129,8 +2124,8 @@ public class CPPSemantics {
ASTNodeProperty prop = null; ASTNodeProperty prop = null;
while (node != null) { while (node != null) {
prop = node.getPropertyInParent(); prop = node.getPropertyInParent();
//target is an object or reference being initialized
if (prop == IASTDeclarator.INITIALIZER) { if (prop == IASTDeclarator.INITIALIZER) {
// target is an object or reference being initialized
IASTDeclarator dtor = (IASTDeclarator) node.getParent(); IASTDeclarator dtor = (IASTDeclarator) node.getParent();
return CPPVisitor.createType(dtor); return CPPVisitor.createType(dtor);
} else if (prop == IASTInitializerExpression.INITIALIZER_EXPRESSION) { } else if (prop == IASTInitializerExpression.INITIALIZER_EXPRESSION) {
@ -2140,21 +2135,18 @@ public class CPPSemantics {
return CPPVisitor.createType(dtor); return CPPVisitor.createType(dtor);
} }
return null; return null;
} } else if (prop == IASTBinaryExpression.OPERAND_TWO &&
//target is the left side of an assignment ((IASTBinaryExpression)node.getParent()).getOperator() == IASTBinaryExpression.op_assign) {
else if (prop == IASTBinaryExpression.OPERAND_TWO && // target is the left side of an assignment
((IASTBinaryExpression)node.getParent()).getOperator() == IASTBinaryExpression.op_assign)
{
IASTBinaryExpression binaryExp = (IASTBinaryExpression) node.getParent(); IASTBinaryExpression binaryExp = (IASTBinaryExpression) node.getParent();
IASTExpression exp = binaryExp.getOperand1(); IASTExpression exp = binaryExp.getOperand1();
return CPPVisitor.getExpressionType(exp); return CPPVisitor.getExpressionType(exp);
} } else if (prop == IASTFunctionCallExpression.PARAMETERS ||
//target is a parameter of a function (prop == IASTExpressionList.NESTED_EXPRESSION &&
else if (prop == IASTFunctionCallExpression.PARAMETERS || node.getParent().getPropertyInParent() == IASTFunctionCallExpression.PARAMETERS)) {
(prop == IASTExpressionList.NESTED_EXPRESSION && node.getParent().getPropertyInParent() == IASTFunctionCallExpression.PARAMETERS)) // target is a parameter of a function
{ // if this function call refers to an overloaded function, there is more than one possiblity
//if this function call refers to an overloaded function, there is more than one possiblity // for the target type
//for the target type
IASTFunctionCallExpression fnCall = null; IASTFunctionCallExpression fnCall = null;
int idx = -1; int idx = -1;
if (prop == IASTFunctionCallExpression.PARAMETERS) { if (prop == IASTFunctionCallExpression.PARAMETERS) {
@ -2185,15 +2177,12 @@ public class CPPSemantics {
result = (IType[]) ArrayUtil.append(IType.class, result, pts[idx]); result = (IType[]) ArrayUtil.append(IType.class, result, pts[idx]);
} }
return result; return result;
} } else if (prop == IASTCastExpression.OPERAND) {
//target is an explicit type conversion // target is an explicit type conversion
else if (prop == IASTCastExpression.OPERAND)
{
IASTCastExpression cast = (IASTCastExpression) node.getParent(); IASTCastExpression cast = (IASTCastExpression) node.getParent();
return CPPVisitor.createType(cast.getTypeId().getAbstractDeclarator()); return CPPVisitor.createType(cast.getTypeId().getAbstractDeclarator());
} } else if (prop == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) {
//target is a template non-type parameter (14.3.2-5) //target is a template non-type parameter (14.3.2-5)
else if (prop == ICPPASTTemplateId.TEMPLATE_ID_ARGUMENT) {
ICPPASTTemplateId id = (ICPPASTTemplateId) node.getParent(); ICPPASTTemplateId id = (ICPPASTTemplateId) node.getParent();
IASTNode[] args = id.getTemplateArguments(); IASTNode[] args = id.getTemplateArguments();
int i = 0; int i = 0;
@ -2213,10 +2202,8 @@ public class CPPSemantics {
return null; return null;
} }
} }
} } else if (prop == IASTReturnStatement.RETURNVALUE) {
//target is the return value of a function, operator or conversion // target is the return value of a function, operator or conversion
else if (prop == IASTReturnStatement.RETURNVALUE)
{
while (!(node instanceof IASTFunctionDefinition)) { while (!(node instanceof IASTFunctionDefinition)) {
node = node.getParent(); node = node.getParent();
} }
@ -2231,13 +2218,10 @@ public class CPPSemantics {
} catch (DOMException e) { } catch (DOMException e) {
} }
} }
} } else if (prop == IASTUnaryExpression.OPERAND) {
else if (prop == IASTUnaryExpression.OPERAND) {
IASTUnaryExpression parent = (IASTUnaryExpression) node.getParent(); IASTUnaryExpression parent = (IASTUnaryExpression) node.getParent();
if (parent.getOperator() == IASTUnaryExpression.op_bracketedPrimary || if (parent.getOperator() == IASTUnaryExpression.op_bracketedPrimary ||
parent.getOperator() == IASTUnaryExpression.op_amper) parent.getOperator() == IASTUnaryExpression.op_amper) {
{
node = parent; node = parent;
continue; continue;
} }
@ -2267,14 +2251,15 @@ public class CPPSemantics {
for (int i = 0; i < items.length; i++) { for (int i = 0; i < items.length; i++) {
Object o = items[i]; Object o = items[i];
if (o == null) break; if (o == null) break;
if (o instanceof IASTName) if (o instanceof IASTName) {
temp = ((IASTName) o).resolveBinding(); temp = ((IASTName) o).resolveBinding();
else if (o instanceof IBinding) { } else if (o instanceof IBinding) {
temp = (IBinding) o; temp = (IBinding) o;
if (!declaredBefore(temp, name, isIndexBased)) if (!declaredBefore(temp, name, isIndexBased))
continue; continue;
} else } else {
continue; continue;
}
try { try {
if (temp instanceof IFunction) { if (temp instanceof IFunction) {
@ -2365,7 +2350,6 @@ public class CPPSemantics {
return contentAssistLookup(data, name); return contentAssistLookup(data, name);
} }
private static IBinding[] contentAssistLookup(LookupData data, Object start) { private static IBinding[] contentAssistLookup(LookupData data, Object start) {
try { try {
lookup(data, start); lookup(data, start);
@ -2380,9 +2364,9 @@ public class CPPSemantics {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
key = map.keyAt(i); key = map.keyAt(i);
obj = map.get(key); obj = map.get(key);
if (obj instanceof IBinding) if (obj instanceof IBinding) {
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, obj); result = (IBinding[]) ArrayUtil.append(IBinding.class, result, obj);
else if (obj instanceof IASTName) { } else if (obj instanceof IASTName) {
IBinding binding = ((IASTName) obj).resolveBinding(); IBinding binding = ((IASTName) obj).resolveBinding();
if (binding != null && !(binding instanceof IProblemBinding)) if (binding != null && !(binding instanceof IProblemBinding))
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding); result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding);
@ -2390,9 +2374,9 @@ public class CPPSemantics {
Object[] objs = (Object[]) obj; Object[] objs = (Object[]) obj;
for (int j = 0; j < objs.length && objs[j] != null; j++) { for (int j = 0; j < objs.length && objs[j] != null; j++) {
Object item = objs[j]; Object item = objs[j];
if (item instanceof IBinding) if (item instanceof IBinding) {
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, item); result = (IBinding[]) ArrayUtil.append(IBinding.class, result, item);
else if (item instanceof IASTName) { } else if (item instanceof IASTName) {
IBinding binding = ((IASTName) item).resolveBinding(); IBinding binding = ((IASTName) item).resolveBinding();
if (binding != null && !(binding instanceof IProblemBinding)) if (binding != null && !(binding instanceof IProblemBinding))
result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding); result = (IBinding[]) ArrayUtil.append(IBinding.class, result, binding);
@ -2419,18 +2403,19 @@ public class CPPSemantics {
ObjectSet<IBinding> set = new ObjectSet<IBinding>(items.length); ObjectSet<IBinding> set = new ObjectSet<IBinding>(items.length);
IBinding binding = null; IBinding binding = null;
for (int i = 0; i < items.length; i++) { for (int i = 0; i < items.length; i++) {
if (items[i] instanceof IASTName) if (items[i] instanceof IASTName) {
binding = ((IASTName) items[i]).resolveBinding(); binding = ((IASTName) items[i]).resolveBinding();
else if (items[i] instanceof IBinding) } else if (items[i] instanceof IBinding) {
binding = (IBinding) items[i]; binding = (IBinding) items[i];
else } else {
binding = null; binding = null;
}
if (binding != null) { if (binding != null) {
if (binding instanceof ICPPUsingDeclaration) { if (binding instanceof ICPPUsingDeclaration) {
set.addAll(((ICPPUsingDeclaration)binding).getDelegates()); set.addAll(((ICPPUsingDeclaration) binding).getDelegates());
} else if (binding instanceof CPPCompositeBinding) { } else if (binding instanceof CPPCompositeBinding) {
set.addAll(((CPPCompositeBinding)binding).getBindings()); set.addAll(((CPPCompositeBinding) binding).getBindings());
} else { } else {
set.put(binding); set.put(binding);
} }