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

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


  }

  private Expression evaluate(Variable input, boolean failOnUndefined) {
    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);
View Full Code Here


      negation.setExpliciteSign(false);
      return negation;
    }

    problemsHandler.nonNumberNegation(input);
    return new FaultyExpression(input);
  }
View Full Code Here

  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);

    if (colorsCalculator.accepts(input.getOperator(), leftValue, rightValue))
      return colorsCalculator.evalute(input, leftValue, rightValue);

    problemsHandler.cannotEvaluate(input);
    return new FaultyExpression(input);
  }
View Full Code Here

  }

  private Expression handleUndefinedVariable(Variable variable, boolean failOnUndefined) {
    if (failOnUndefined) {
      problemsHandler.undefinedVariable(variable);
      return new FaultyExpression(variable);
    } else {
      return null;
    }
  }
View Full Code Here

  }

  private Expression subtract(Expression first, double red1, double green1, double blue1, double alpha1, double red2, double green2, double blue2, double alpha2, HiddenTokenAwareTree parentToken) {
    if (first.getType()==ASTCssNodeType.NUMBER) {
      problemsHandler.subtractOrDiveColorFromNumber(first);
      return new FaultyExpression(first);
    }
   
    return createResultColor(parentToken, round(red1 - red2), round(green1 - green2), round(blue1 - blue2), alpha1, alpha2);
  }
View Full Code Here

  }

  private Expression divide(Expression first, double red1, double green1, double blue1, double alpha1, double red2, double green2, double blue2, double alpha2, HiddenTokenAwareTree parentToken) {
    if (first.getType()==ASTCssNodeType.NUMBER) {
      problemsHandler.subtractOrDiveColorFromNumber(first);
      return new FaultyExpression(first);
    }
   
    return createResultColor(parentToken, round(red1 / red2), round(green1 / green2), round(blue1 / blue2), alpha1, alpha2);
  }
View Full Code Here

        List<Expression> parametersClone = ArraysUtils.deeplyClonedList(parameters);
        Expression evaluatedParameterClone = evaluatedParameter.clone();
        return fixResult(function.evaluate(inputClone, parametersClone, evaluatedParameterClone, new SafeLessProblem(problemsHandler, inputClone)), input);
      }
    }
    return new FaultyExpression(input);
  }
View Full Code Here

    return new FaultyExpression(input);
  }

  private Expression fixResult(Expression result, FunctionExpression input) {
    if (result == null)
      return new FaultyExpression(input);

    fixNode(result, input);
    return result;
  }
View Full Code Here

      next = expanded.next();
      if (next.getType()==ASTCssNodeType.NUMBER) {
        NumberExpression nextNum = (NumberExpression) next;
        if (!canCompare(result, nextNum)) {
          problemsHandler.errorIncompatibleTypesCompared(functionCall, result.getSuffix(), nextNum.getSuffix());
          return new FaultyExpression(functionCall);
        }
       
        result = compareCompatible(result, nextNum);
      }
    }
View Full Code Here

      problemsHandler.wrongNumberOfArgumentsToFunctionMin(call.getParameter(), call.getName(), 1);

    Expression iParameter = parameters.get(0);
    if (iParameter.getType() != ASTCssNodeType.NUMBER) {
      problemsHandler.wrongArgumentTypeToFunction(iParameter, getName(), iParameter.getType(), ASTCssNodeType.NUMBER);
      return new FaultyExpression(iParameter);
    }

    NumberExpression parameter = (NumberExpression) iParameter;
    HiddenTokenAwareTree parentToken = parameter.getUnderlyingStructure();
    Double oValue = parameter.getValueAsDouble();
View Full Code Here

TOP

Related Classes of com.github.sommeri.less4j.core.ast.FaultyExpression

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.