Package org.eclipse.dltk.ast.expressions

Examples of org.eclipse.dltk.ast.expressions.Expression


  public static RutaCondition createCondition(Expression... exprsArray) {
    List<Expression> exprL = new ArrayList<Expression>();
    if (exprsArray != null) {
      for (int i = 0; i < exprsArray.length; i++) {
        Expression expression = exprsArray[i];
        if (expression != null) {
          exprL.add(expression);
        }
      }
    }
View Full Code Here


  public static RutaCondition createCondition(Token type, Expression... exprsArray) {
    List<Expression> exprL = new ArrayList<Expression>();
    if (exprsArray != null) {
      for (int i = 0; i < exprsArray.length; i++) {
        Expression expression = exprsArray[i];
        if (expression != null) {
          exprL.add(expression);
        }
      }
    }
View Full Code Here

      if (childs.size() < 1) {
        IProblem problem = problemFactory.createWrongNumberOfArgumentsProblem(name, element, 1);
        rep.reportProblem(problem);
        ok = false;
      }
      Expression expr = childs.get(0);
      if (expr.getKind() != RutaTypeConstants.RUTA_TYPE_S) {
        IProblem problem = problemFactory.createWrongArgumentTypeProblem(expr, "TypeExpression");
        rep.reportProblem(problem);
        ok = false;
      }
      return ok;
View Full Code Here

      if (childs.size() != 1) {
        IProblem problem = problemFactory.createWrongNumberOfArgumentsProblem(name, element, 1);
        rep.reportProblem(problem);
        ok = false;
      }
      Expression expr = childs.get(0);
      if (expr.getKind() != RutaTypeConstants.RUTA_TYPE_AT) {
        IProblem problem = problemFactory.createWrongArgumentTypeProblem(expr, "TypeExpression");
        rep.reportProblem(problem);
        ok = false;
      }
      return ok;
View Full Code Here

    }
  }

  private boolean checkVariableWithoutDollarCompletion(RutaStatement statement, int position) {
    // TODO: Add more compecated check.
    Expression e = statement.getAt(0);
    if (e instanceof SimpleReference) {
      SimpleReference ref = (SimpleReference) e;
      String name = ref.getName();
      if (name.equals("set")) {
        return true;
View Full Code Here

  private ASTNode getRealNode(ASTNode node) {
    if (node instanceof RutaAction) {
      RutaAction a = (RutaAction) node;
      if (ActionFactory.IMPLICIT.equals(a.getName()) && !a.getChilds().isEmpty()) {
        Expression expression = a.getChilds().get(0);
        if (expression != null && !expression.getChilds().isEmpty()) {
          return (ASTNode) expression.getChilds().get(0);
        }
      }
    }
    if (node instanceof RutaCondition) {
      RutaCondition c = (RutaCondition) node;
      if (ConditionFactory.IMPLICIT.equals(c.getName()) && !c.getChilds().isEmpty()) {
        Expression expression = c.getChilds().get(0);
        if (expression != null && !expression.getChilds().isEmpty()) {
          return (ASTNode) expression.getChilds().get(0);
        }
      }
    }
    return node;
  }
View Full Code Here

    }
    int start = 0;
    int end = 0;
    if (!exprList.isEmpty()) {
      start = exprList.get(0).sourceStart();
      Expression expression = exprList.get(exprList.size() - 1);
      if (expression != null) {
        end = expression.sourceEnd();
      } else {
        exprList.get(0).sourceEnd();
      }
    }
    return new RutaListExpression(start, end, exprList, type);
View Full Code Here

    int nameStart = bounds[0];
    int nameEnd = bounds[1];
    List<Expression> exprs = new ArrayList<Expression>();
    if (exprsRaw != null) {
      for (Object expressionObj : exprsRaw) {
        Expression expr = (Expression) expressionObj;
        if (expr != null) {
          exprs.add(expr);
        }
      }
      if (!exprs.isEmpty()) {
        Expression lastExpr = (Expression) exprs.get(exprs.size() - 1);
        bounds[1] = Math.max(bounds[1], lastExpr.sourceEnd());
      }
    }
    return new RutaFunction(bounds[0], bounds[1], exprs,
            kind, type.getText(), nameStart,
            nameEnd);
View Full Code Here

  @Override
  public void traverse(ASTVisitor visitor) throws Exception {
    if (visitor.visit(this)) {
      for (Iterator<Expression> iterator = exprs.iterator(); iterator.hasNext();) {
        Expression expr = iterator.next();
        if (expr != null) {
          expr.traverse(visitor);
        }
      }
      visitor.endvisit(this);
    }
  }
View Full Code Here

    @Override
    public boolean visit(Expression s) throws Exception {

      if (s instanceof RutaRuleElement) {
        RutaRuleElement re = (RutaRuleElement) s;
        Expression head = re.getHead();
        if (head != null) {
          String type = currentFile.getSource().substring(head.sourceStart(), head.sourceEnd());
          matchedType = type;
        }
      }
      if (s instanceof RutaVariableReference) {
        RutaVariableReference ref = (RutaVariableReference) s;
        // filter AnnotationTypeReferences
        if ((ref.getType() & RutaTypeConstants.RUTA_TYPE_AT) != 0) {
          return false;
        }
        if (!isVariableDeclared(ref)) {
          return false;
        }
        checkTypeOfReference(ref);
        return false;
      }
      // check assign types
      if (s instanceof RutaAction) {
        RutaAction tma = (RutaAction) s;

        String actionName = currentFile.getSource().substring(tma.getNameStart(), tma.getNameEnd());
        String[] keywords = RutaKeywordsManager.getKeywords(IRutaKeywords.ACTION);
        List<String> asList = Arrays.asList(keywords);
        if (!StringUtils.isEmpty(actionName) && !"-".equals(actionName)
                && !asList.contains(actionName)) {
          IProblem problem = problemFactory.createUnknownActionProblem(tma);
          rep.reportProblem(problem);
        }

        IRutaExtension extension = actionExtensions.get(actionName);
        if (extension != null) {
          // boolean checkSyntax =
          extension.checkSyntax(tma, problemFactory, rep);
        }

        if (tma.getName().equals("GETFEATURE") || tma.getName().equals("SETFEATURE")) {
          List<?> childs = tma.getChilds();
          RutaStringExpression stringExpr = (RutaStringExpression) childs.get(0);
          String feat = stringExpr.toString();
          feat = getFeatureName(stringExpr, feat);
          boolean featureFound = findFeature(matchedType, feat);
          if (!featureFound) {
            IProblem problem = problemFactory.createUnknownFeatureProblem(stringExpr, matchedType);
            rep.reportProblem(problem);
          }
        }

        if (tma.getKind() == RutaActionConstants.A_ASSIGN) {
          List<?> childs = tma.getChilds();
          try {
            RutaVariableReference ref = (RutaVariableReference) childs.get(0);
            RutaExpression expr = (RutaExpression) childs.get(1);
            int type = expr.getKind();
            if (ref.getType() == RutaTypeConstants.RUTA_TYPE_G) {
              ref.setType(type);
            }
          } catch (IndexOutOfBoundsException e) {
            // exception should have been recognized and reported in
            // parser
            return false;
          } catch (ClassCastException e) {
            // exception should have been recognized and reported in
            // parser
            return false;
          }
        }
        if (s instanceof RutaStructureAction) {
          RutaStructureAction sa = (RutaStructureAction) s;
          Expression struct = sa.getStructure();
          String structure = null;
          if (struct != null) {
            structure = currentFile.getSource().substring(struct.sourceStart(), struct.sourceEnd());
          }
          Map<Expression, Expression> assignments = sa.getAssignments();
          // hotfix... correct name in ast
          String action = currentFile.getSource().substring(sa.getNameStart(), sa.getNameEnd());
          if (assignments != null && !action.equals("TRIE")) {
View Full Code Here

TOP

Related Classes of org.eclipse.dltk.ast.expressions.Expression

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.