mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 395884 - Fixed a bug introduced in the previous commit.
This commit is contained in:
parent
9db71c4ba6
commit
b7643e8b81
1 changed files with 26 additions and 3 deletions
|
@ -97,18 +97,41 @@ public class EvalBinding extends CPPEvaluation {
|
|||
* otherwise returns -1
|
||||
*/
|
||||
public int getFunctionParameterPosition() {
|
||||
if (fParameterPosition < 0 && fBinding instanceof CPPParameter) {
|
||||
fParameterPosition = ((CPPParameter) fBinding).getParameterPosition();
|
||||
if (fParameterPosition < 0) {
|
||||
if (fBinding instanceof CPPParameter) {
|
||||
fParameterPosition = ((CPPParameter) fBinding).getParameterPosition();
|
||||
} else {
|
||||
ICPPFunction parameterOwner = getParameterOwner();
|
||||
if (parameterOwner != null) {
|
||||
ICPPParameter[] parameters = fParameterOwner.getParameters();
|
||||
fParameterPosition = findInArray(parameters, fBinding);
|
||||
}
|
||||
}
|
||||
}
|
||||
return fParameterPosition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds a given object in an array.
|
||||
*
|
||||
* @param array the array to find the object in
|
||||
* @param obj the object to find
|
||||
* @return the index of the object in the array, or -1 if the object is not in the array
|
||||
*/
|
||||
private static int findInArray(Object[] array, Object obj) {
|
||||
for (int i = 0; i < array.length; i++) {
|
||||
if (obj == array[i])
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the function owning the parameter if the binding is a function parameter,
|
||||
* otherwise {@code null}.
|
||||
*/
|
||||
public ICPPFunction getParameterOwner() {
|
||||
if (fParameterOwner == null && fBinding instanceof CPPParameter) {
|
||||
if (fParameterOwner == null && fBinding instanceof ICPPParameter) {
|
||||
IBinding owner = ((CPPParameter) fBinding).getOwner();
|
||||
if (owner instanceof ICPPFunction)
|
||||
fParameterOwner = (ICPPFunction) owner;
|
||||
|
|
Loading…
Add table
Reference in a new issue