aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJacek Pospychala2012-11-15 09:24:18 (EST)
committerJacek Pospychala2012-11-15 09:25:11 (EST)
commitad8faaf586933ac5fead3426e4f413659f3c584f (patch)
tree81b1302895c6aa905d50e67cd6a97be2d2253489
parent4077a247a1305ab3d0b5f6412625b2ca647dd776 (diff)
downloadorg.eclipse.pdt-ad8faaf586933ac5fead3426e4f413659f3c584f.zip
org.eclipse.pdt-ad8faaf586933ac5fead3426e4f413659f3c584f.tar.gz
org.eclipse.pdt-ad8faaf586933ac5fead3426e4f413659f3c584f.tar.bz2
Bug 394385 - Method return type binding based on method arguments values
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/MethodCallTypeEvaluator.java20
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/goals/AbstractMethodReturnTypeGoal.java11
-rw-r--r--plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/goals/MethodElementReturnTypeGoal.java4
3 files changed, 32 insertions, 3 deletions
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/MethodCallTypeEvaluator.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/MethodCallTypeEvaluator.java
index 3b4f489..25aba46 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/MethodCallTypeEvaluator.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/evaluators/MethodCallTypeEvaluator.java
@@ -12,8 +12,10 @@
package org.eclipse.php.internal.core.typeinference.evaluators;
import java.util.Arrays;
+import java.util.List;
import org.eclipse.dltk.ast.ASTNode;
+import org.eclipse.dltk.ast.expressions.CallArgumentsList;
import org.eclipse.dltk.ast.expressions.CallExpression;
import org.eclipse.dltk.evaluation.types.UnknownType;
import org.eclipse.dltk.ti.GoalState;
@@ -21,6 +23,8 @@ import org.eclipse.dltk.ti.goals.ExpressionTypeGoal;
import org.eclipse.dltk.ti.goals.GoalEvaluator;
import org.eclipse.dltk.ti.goals.IGoal;
import org.eclipse.dltk.ti.types.IEvaluatedType;
+import org.eclipse.php.internal.core.compiler.ast.nodes.Scalar;
+import org.eclipse.php.internal.core.compiler.ast.parser.ASTUtils;
import org.eclipse.php.internal.core.typeinference.PHPTypeInferenceUtils;
import org.eclipse.php.internal.core.typeinference.goals.MethodElementReturnTypeGoal;
import org.eclipse.php.internal.core.typeinference.goals.phpdoc.PHPDocMethodReturnTypeGoal;
@@ -84,8 +88,22 @@ public class MethodCallTypeEvaluator extends GoalEvaluator {
previousResult = null;
}
state = STATE_WAITING_METHOD;
+ CallArgumentsList args = expression.getArgs();
+ String[] argNames = null;
+ if (args != null && args.getChilds() != null) {
+ List childs = args.getChilds();
+ int i = 0;
+ argNames = new String[childs.size()];
+ for (Object o : childs) {
+ if (o instanceof Scalar) {
+ Scalar arg = (Scalar) o;
+ argNames[i] = ASTUtils.stripQuotes(arg.getValue());
+ }
+ i++;
+ }
+ }
return new MethodElementReturnTypeGoal(typedGoal.getContext(),
- receiverType, expression.getName());
+ receiverType, expression.getName(), argNames);
}
if (state == STATE_WAITING_METHOD) {
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/goals/AbstractMethodReturnTypeGoal.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/goals/AbstractMethodReturnTypeGoal.java
index d735514..dfb6af3 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/goals/AbstractMethodReturnTypeGoal.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/goals/AbstractMethodReturnTypeGoal.java
@@ -26,6 +26,7 @@ public abstract class AbstractMethodReturnTypeGoal extends AbstractTypeGoal {
private final String methodName;
private IType[] types;
private IEvaluatedType evaluatedType;
+ private String[] argNames;
public AbstractMethodReturnTypeGoal(IContext context,
IEvaluatedType evaluatedType, String methodName) {
@@ -43,6 +44,16 @@ public abstract class AbstractMethodReturnTypeGoal extends AbstractTypeGoal {
this.types = types;
}
+ public AbstractMethodReturnTypeGoal(IContext context,
+ IEvaluatedType evaluatedType, String methodName, String[] argNames) {
+ this(context, evaluatedType, methodName);
+ this.argNames = argNames;
+ }
+
+ public String[] getArgNames() {
+ return argNames;
+ }
+
public String getMethodName() {
return methodName;
}
diff --git a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/goals/MethodElementReturnTypeGoal.java b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/goals/MethodElementReturnTypeGoal.java
index 610bd63..2a20404 100644
--- a/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/goals/MethodElementReturnTypeGoal.java
+++ b/plugins/org.eclipse.php.core/src/org/eclipse/php/internal/core/typeinference/goals/MethodElementReturnTypeGoal.java
@@ -18,8 +18,8 @@ import org.eclipse.dltk.ti.types.IEvaluatedType;
public class MethodElementReturnTypeGoal extends AbstractMethodReturnTypeGoal {
public MethodElementReturnTypeGoal(IContext context,
- IEvaluatedType evaluatedType, String methodName) {
- super(context, evaluatedType, methodName);
+ IEvaluatedType evaluatedType, String methodName, String[] argNames) {
+ super(context, evaluatedType, methodName, argNames);
}
public MethodElementReturnTypeGoal(IContext context, IType[] types,