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

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


  @Override
  public Expression evaluate(List<Expression> parameters, ProblemsHandler problemsHandler, FunctionExpression call, Expression evaluatedParameter) {
    if (parameters.isEmpty())
      problemsHandler.errFormatWrongFirstParameter(call.getParameter());

    Expression format = parameters.get(0);
    if (format.getType() == ASTCssNodeType.STRING_EXPRESSION)
      return evaluate((CssString) format, parameters.subList(1, parameters.size()), problemsHandler, call.getUnderlyingStructure());

    if (format.getType() == ASTCssNodeType.ESCAPED_VALUE)
      return evaluate((EscapedValue) format, parameters.subList(1, parameters.size()), problemsHandler, call.getUnderlyingStructure());

    if (!format.isFaulty())
      problemsHandler.errFormatWrongFirstParameter(call.getParameter());

    return new FaultyExpression(call);
  }
View Full Code Here


  private TypesConversionUtils conversions = new TypesConversionUtils();

  @Override
  public Expression evaluate(List<Expression> parameters, ProblemsHandler problemsHandler, FunctionExpression call, Expression evaluatedParameter) {
    Expression targetExpression = parameters.get(0);
    String string = conversions.contentToString(targetExpression);
    String pattern = conversions.contentToString(parameters.get(1));
    String replacement = conversions.contentToString(parameters.get(2));
    String flags = parameters.size() > 3 ? conversions.contentToString(parameters.get(3)) : "";

    Expression replaced = regexp(targetExpression, string, pattern, replacement, flags, problemsHandler, call);
    return replaced;
  }
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 (!(parameter instanceof EmbeddedScript)) {
      problemsHandler.wrongArgumentTypeToFunction(parameter, name+"...`", parameter.getType(),ASTCssNodeType.EMBEDDED_SCRIPT);
      return new FaultyExpression(call);
    }
   
    warn(call, problemsHandler);
   
View Full Code Here

public class UnknownFunction implements Function {

  @Override
  public Expression evaluate(List<Expression> parameters, ProblemsHandler problemsHandler, FunctionExpression call, Expression evaluatedParameter) {
    Expression oldParameter = call.getParameter();
    oldParameter.setParent(null);
    call.setParameter(evaluatedParameter);
    call.configureParentToAllChilds();
   
    return call;
  }
View Full Code Here

    returner.append(">");

    Iterator<Expression> iterator = stops.iterator();
    boolean isFirstStop = true;
    while (iterator.hasNext()) {
      Expression stop = iterator.next();
      if (!addColorStop(returner, stop, isFirstStop, !iterator.hasNext(), functionCall, problemsHandler))
        return new FaultyExpression(functionCall);
      isFirstStop = false;
    }
View Full Code Here

      if (expressions.isEmpty() || expressions.size() > 2) {
        problemsHandler.errorSvgGradientArgument(errorNode);
        return false;
      }

      Expression color = expressions.get(0);
      Expression position = expressions.size() > 1 ? expressions.get(1) : null;
      addColorStop(returner, color, position, isFirst, isLast, errorNode, problemsHandler);
    } else {
      addColorStop(returner, colorStop, null, isFirst, isLast, errorNode, problemsHandler);
    }
    return true;
View Full Code Here

    return "@" + group.substring(2, group.length() - 1);
  }

  @Override
  protected String replacementValue(ExpressionEvaluator expressionEvaluator, HiddenTokenAwareTree technicalUnderlying, MatchRange matchRange) {
    Expression value = expressionEvaluator.evaluateIfPresent(new Variable(technicalUnderlying, matchRange.getName()));
    if (value == null) {
      return matchRange.getFullMatch();
    }

    String result = embeddedScriptEvaluator.toScript(value, problemsHandler);
View Full Code Here

class Saturate extends CssNameClashMultiParameterFunction {

  @Override
  public Expression evaluate(List<Expression> splitParameters, ProblemsHandler problemsHandler, FunctionExpression call, Expression evaluatedParameter) {
    Expression firstParam = splitParameters.get(0);
    if (firstParam.getType() != ASTCssNodeType.COLOR_EXPRESSION) {
      UnknownFunction unknownFunction = new UnknownFunction();
      return unknownFunction.evaluate(splitParameters, problemsHandler, call, evaluatedParameter);
    }

    ColorExpression color = (ColorExpression) firstParam;
View Full Code Here

   
    if ("%".equalsIgnoreCase(name)) {
      return "%";
    }

    Expression replacement = replacements.next();
    // special case: imitating less.js behavior on incorrect color input
    if ("S".equals(name) && replacement.getType()==ASTCssNodeType.COLOR_EXPRESSION) {
      return "undefined";
    }

    if ("s".equalsIgnoreCase(name)) {
      InStringCssPrinter printer = new InStringCssPrinter();
View Full Code Here

      this.expressionEvaluator = expressionEvaluator;
      this.importTargetScope = importTargetScope;
    }

    public Expression apply(Expression input) {
      Expression result = expressionEvaluator.evaluate(input);
      IScope newScope = apply(result.getScope());
      result.setScope(newScope);
      return result;
    }
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.