Package com.github.sommeri.less4j.core.ast

Examples of com.github.sommeri.less4j.core.ast.Expression


  }

  public void addFilteredVariables(ExpressionFilter filter, VariablesDeclarationsStorage variablesSource) {
    for (Entry<String, Expression> entry : variablesSource.coolStorage.getAllEntries()) {
      String name = entry.getKey();
      Expression value = entry.getValue();
      if (filter.accepts(name, value))
        store(name, filter.apply(value));
    }
  }
View Full Code Here


 
  private final TypesConversionUtils utils = new TypesConversionUtils();

  @Override
  protected Expression evaluate(List<Expression> splitParameters, ProblemsHandler problemsHandler, FunctionExpression functionCall, HiddenTokenAwareTree token) {
    Expression expression = splitParameters.get(0);
    Expression unitExpression = splitParameters.get(1);
   
    String unit = utils.contentToString(unitExpression);
    if (expression.getType()!=ASTCssNodeType.NUMBER || unit==null)
      return new IdentifierExpression(functionCall.getUnderlyingStructure(), "false");
   
View Full Code Here

  @Override
  public Expression evaluate(List<Expression> parameters, ProblemsHandler problemsHandler, FunctionExpression call, Expression evaluatedParameter) {
    if (parameters.size()>1)
      problemsHandler.wrongNumberOfArgumentsToFunctionMin(call.getParameter(), call.getName(), 1);

    Expression parameter = parameters.get(0);
    if (checkType(parameter)) {
      return new IdentifierExpression(parameter.getUnderlyingStructure(), "true");
    } else {
      return new IdentifierExpression(parameter.getUnderlyingStructure(), "false");
    }
  }
View Full Code Here

    if (cycleDetector.wouldCycle(input)) {
      problemsHandler.variablesCycle(cycleDetector.getCycleFor(input));
      return new FaultyExpression(input);
    }

    Expression expression = lazyScope.getValue(input);
    if (expression == null) {
      return handleUndefinedVariable(input, failOnUndefined);
    }

    cycleDetector.enteringVariableValue(input);
    Expression result = evaluate(expression);
    cycleDetector.leftVariableValue();
    return result;
  }
View Full Code Here

    cycleDetector.leftVariableValue();
    return result;
  }

  public Expression evaluate(IndirectVariable input) {
    Expression reference = evaluate(lazyScope.getValue(input));

    CssPrinter printer = new InStringCssPrinter();
    printer.append(reference);
    String realName = printer.toString();
View Full Code Here

    IdentifierExpression identifier = (IdentifierExpression) value;
    return "true".equals(identifier.getValue());
  }

  public boolean booleanEvalueate(ComparisonExpression input) {
    Expression leftE = evaluate(input.getLeft());
    Expression rightE = evaluate(input.getRight());

    ComparisonExpressionOperator operator = input.getOperator();
    if (operator.getOperator() == ComparisonExpressionOperator.Operator.OPEQ)
      return comparator.equal(leftE, rightE);

    if (leftE.getType() != ASTCssNodeType.NUMBER) {
      problemsHandler.incompatibleComparisonOperand(leftE, operator);
      return false;
    }

    if (rightE.getType() != ASTCssNodeType.NUMBER) {
      problemsHandler.incompatibleComparisonOperand(rightE, operator);
      return false;
    }

    return compareNumbers((NumberExpression) leftE, (NumberExpression) rightE, operator);
View Full Code Here

  private boolean canCompareDimensions(Dimension left, Dimension right) {
    return true;
  }

  public Expression evaluate(FunctionExpression input) {
    Expression evaluatedParameter = evaluate(input.getParameter());
    List<Expression> splitParameters = (evaluatedParameter.getType() == ASTCssNodeType.EMPTY_EXPRESSION) ? new ArrayList<Expression>() : evaluatedParameter.splitByComma();

    if (!input.isCssOnlyFunction()) {
      for (FunctionsPackage pack : functions) {
        if (pack.canEvaluate(input, splitParameters))
          return pack.evaluate(input, splitParameters, evaluatedParameter);
View Full Code Here

    result.configureParentToAllChilds();
    return result;
  }

  public Expression evaluate(SignedExpression input) {
    Expression evaluate = evaluate(input.getExpression());
    if (evaluate instanceof NumberExpression) {
      NumberExpression negation = ((NumberExpression) evaluate).clone();
      if (input.getSign() == Sign.PLUS)
        return negation;
View Full Code Here

    problemsHandler.nonNumberNegation(input);
    return new FaultyExpression(input);
  }

  public Expression evaluate(BinaryExpression input) {
    Expression leftValue = evaluate(input.getLeft());
    Expression rightValue = evaluate(input.getRight());
    if (leftValue.isFaulty() || rightValue.isFaulty())
      return new FaultyExpression(input);

    if (arithmeticCalculator.accepts(input.getOperator(), leftValue, rightValue))
      return arithmeticCalculator.evalute(input, leftValue, rightValue);
View Full Code Here

    return true;
  }

  private boolean evaluate(GuardCondition guardCondition) {
    Expression condition = guardCondition.getCondition();
    boolean conditionStatus = booleanEvalueate(condition);

    return guardCondition.isNegated() ? !conditionStatus : conditionStatus;
  }
View Full Code Here

TOP

Related Classes of com.github.sommeri.less4j.core.ast.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.