Package org.eclipse.dltk.ti.goals

Examples of org.eclipse.dltk.ti.goals.ExpressionTypeGoal


  public CloneEvaluator(IGoal goal) {
    super(goal);
  }

  public IGoal[] init() {
    ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal;
    CloneExpression cloneExpression = (CloneExpression) typedGoal
        .getExpression();
    return new IGoal[] { new ExpressionTypeGoal(typedGoal.getContext(),
        cloneExpression.getExpr()) };
  }
View Full Code Here


  public InstanceCreationEvaluator(IGoal goal) {
    super(goal);
  }

  public IGoal[] init() {
    ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal;
    ClassInstanceCreation expression = (ClassInstanceCreation) typedGoal
        .getExpression();
    Expression className = expression.getClassName();
    if ((className instanceof TypeReference)) {
      if (isSelf((TypeReference) className)
          && (goal.getContext() instanceof MethodContext)) {
        MethodContext methodContext = (MethodContext) goal.getContext();
        result = methodContext.getInstanceType();
        return IGoal.NO_GOALS;
      } else {
        return new IGoal[] { new ExpressionTypeGoal(goal.getContext(),
            className) };
      }
    }
    result = UnknownType.INSTANCE;
    return IGoal.NO_GOALS;
View Full Code Here

  public StaticConstantAccessEvaluator(IGoal goal) {
    super(goal);
  }

  public IGoal[] init() {
    ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal;
    StaticConstantAccess expr = (StaticConstantAccess) typedGoal
        .getExpression();

    Expression dispatcher = expr.getDispatcher();
    if (dispatcher instanceof TypeReference) {
      TypeReference typeReference = (TypeReference) dispatcher;
View Full Code Here

  public UnaryOperationEvaluator(IGoal goal) {
    super(goal);
  }

  public IGoal[] init() {
    ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal;
    UnaryOperation unaryOp = (UnaryOperation) typedGoal.getExpression();
    switch (unaryOp.getOperatorType()) {
    case UnaryOperation.OP_MINUS:
    case UnaryOperation.OP_PLUS:
      result = new SimpleType(SimpleType.TYPE_NUMBER);
      break;
    case UnaryOperation.OP_TILDA:
      return new IGoal[] { new ExpressionTypeGoal(goal.getContext(),
          unaryOp.getExpr()) };
    case UnaryOperation.OP_NOT:
      result = new SimpleType(SimpleType.TYPE_BOOLEAN);
      break;
    }
View Full Code Here

  public PostfixExpressionEvaluator(IGoal goal) {
    super(goal);
  }

  public IGoal[] init() {
    ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal;
    PostfixExpression postfixExpression = (PostfixExpression) typedGoal
        .getExpression();
    return new IGoal[] { new ExpressionTypeGoal(goal.getContext(),
        postfixExpression.getVariable()) };
  }
View Full Code Here

  public AssignmentEvaluator(IGoal goal) {
    super(goal);
  }

  public IGoal[] init() {
    ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal;
    Assignment expression = (Assignment) typedGoal.getExpression();
    return new IGoal[] { new ExpressionTypeGoal(typedGoal.getContext(),
        expression.getValue()) };
  }
View Full Code Here

  }

  private IGoal produceNextSubgoal(IGoal previousGoal,
      IEvaluatedType previousResult, GoalState goalState) {

    ExpressionTypeGoal typedGoal = (ExpressionTypeGoal) goal;
    CallExpression expression = (CallExpression) typedGoal.getExpression();

    // just starting to evaluate method, evaluate method receiver first:
    if (state == STATE_INIT) {
      ASTNode receiver = expression.getReceiver();
      if (receiver == null) {
        state = STATE_GOT_RECEIVER;
      } else {
        state = STATE_WAITING_RECEIVER;
        return new ExpressionTypeGoal(goal.getContext(), receiver);
      }
    }

    // receiver must been evaluated now, lets evaluate method return type:
    if (state == STATE_WAITING_RECEIVER) {
      receiverType = previousResult;
      previousResult = null;
      if (receiverType == null) {
        return null;
      }
      state = STATE_GOT_RECEIVER;
    }

    // we've evaluated receiver, lets evaluate the method return type now
    // (using PHP Doc first):
    if (state == STATE_GOT_RECEIVER) {
      state = STATE_WAITING_METHOD_PHPDOC;
      return new PHPDocMethodReturnTypeGoal(typedGoal.getContext(),
          receiverType, expression.getName());
    }

    // PHPDoc logic is done, start evaluating 'return' statements here:
    if (state == STATE_WAITING_METHOD_PHPDOC) {
      if (goalState != GoalState.PRUNED && previousResult != null
          && previousResult != UnknownType.INSTANCE) {
        result = previousResult;
        previousResult = null;
        // BUG 404031, stop read if found not simple element
        if (!PHPTypeInferenceUtils.isSimple(result)) {
          return null;
        }
      }
      state = STATE_WAITING_METHOD;
      CallArgumentsList args = expression.getArgs();
      String[] argNames = null;
      if (args != null && args.getChilds() != null) {
        List<ASTNode> childs = args.getChilds();
        int i = 0;
        argNames = new String[childs.size()];
        for (ASTNode 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(), argNames);
    }

    if (state == STATE_WAITING_METHOD) {
      if (goalState != GoalState.PRUNED && previousResult != null
View Full Code Here

        ConstantDeclarationSearcher searcher = new ConstantDeclarationSearcher(
            fileOffsets, constantName);
        try {
          moduleDeclaration.traverse(searcher);
          for (Scalar scalar : searcher.getDeclarations()) {
            subGoals.add(new ExpressionTypeGoal(goal.getContext(),
                scalar));
          }
        } catch (Exception e) {
          if (DLTKCore.DEBUG) {
            e.printStackTrace();
View Full Code Here

      if ((((Assignment) typedGoal.getExpression().getNode()).getValue() instanceof ArrayCreation)) {
        ArrayCreation arrayCreation = (ArrayCreation) ((Assignment) typedGoal
            .getExpression().getNode()).getValue();

        for (ArrayElement arrayElement : arrayCreation.getElements()) {
          subGoals.add(new ExpressionTypeGoal(typedGoal.getContext(),
              arrayElement.getValue()));
        }
        subGoals.toArray(new IGoal[subGoals.size()]);

        List<Declaration> decls = typedGoal.getExpression()
            .getDeclarations();

        IContext context = goal.getContext();
        for (int i = 0; i < decls.size(); ++i) {
          Declaration decl = decls.get(i);
          // TODO check ArrayCreation and its element type
          if (decl instanceof ArrayDeclaration) {
            ArrayDeclaration arrayDeclaration = (ArrayDeclaration) decl;
            subGoals.add(new ArrayDeclarationGoal(context,
                arrayDeclaration));
          } else {
            ASTNode declNode = decl.getNode();
            if (declNode instanceof ForEachStatement) {
              subGoals.add(new ForeachStatementGoal(context,
                  ((ForEachStatement) declNode)
                      .getExpression()));
            } else {
              subGoals.add(new ExpressionTypeGoal(context,
                  declNode));
            }
          }
        }
View Full Code Here

                  sourceRange.getLength(), null, type,
                  declaringType);
              try {
                moduleDeclaration.traverse(searcher);
                if (searcher.getResult() != null) {
                  subGoals.add(new ExpressionTypeGoal(
                      searcher.getContext(), searcher
                          .getResult()));
                }
              } catch (Exception e) {
                if (DLTKCore.DEBUG) {
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.ti.goals.ExpressionTypeGoal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.