ISourceModule sourceModule = method.getSourceModule();
ModuleDeclaration module = SourceParserUtil
.getModuleDeclaration(sourceModule);
MethodDeclaration decl = null;
try {
decl = PHPModelUtils.getNodeByMethod(module, method);
} catch (ModelException e) {
if (DLTKCore.DEBUG) {
e.printStackTrace();
}
}
// final boolean found[] = new boolean[1];
if (decl != null) {
final IContext innerContext = ASTUtils.findContext(
sourceModule, module, decl);
if (innerContext instanceof MethodContext) {
MethodContext mc = (MethodContext) innerContext;
mc.setCurrentType(mat.types[i]);
}
if (goal.getContext() instanceof IModelCacheContext
&& innerContext instanceof IModelCacheContext) {
((IModelCacheContext) innerContext)
.setCache(((IModelCacheContext) goal.getContext())
.getCache());
}
ASTVisitor visitor = new ASTVisitor() {
public boolean visitGeneral(ASTNode node) throws Exception {
if (node instanceof ReturnStatement) {
ReturnStatement statement = (ReturnStatement) node;
Expression expr = statement.getExpr();
if (expr == null) {
evaluated.add(PHPSimpleTypes.VOID);
} else {
subGoals.add(new ExpressionTypeGoal(
innerContext, expr));
}
} else if (node instanceof YieldExpression) {
YieldExpression statement = (YieldExpression) node;
Expression expr = statement.getExpr();
if (expr == null) {
yieldEvaluated.add(PHPSimpleTypes.NULL);
} else {
final ExpressionTypeGoal yg = new ExpressionTypeGoal(
innerContext, expr);
subGoals.add(yg);
yieldGoals.add(yg);
}
}
return super.visitGeneral(node);
}
};
try {
decl.traverse(visitor);
} catch (Exception e) {
if (DLTKCore.DEBUG) {
e.printStackTrace();
}
}