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

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


  }

  private Expression buildFromEscapedScript(HiddenTokenAwareTree token, HiddenTokenAwareTree first) {
    String text = first.getText();
    text = text.substring(2, text.length() - 1);
    return new FunctionExpression(token, "~`", new EmbeddedScript(token, text));
  }
View Full Code Here


  }

  private Expression buildFromEmbeddedScript(HiddenTokenAwareTree token, HiddenTokenAwareTree first) {
    String text = first.getText();
    text = text.substring(1, text.length() - 1);
    return new FunctionExpression(token, "`", new EmbeddedScript(token, text));
  }
View Full Code Here

  }

  private FunctionExpression buildFromSpecialFunction(HiddenTokenAwareTree token, String function, HiddenTokenAwareTree first) {
    Expression parameter = extractUrlParameter(token, function, normalizeNewLineSymbols(first.getText()));
    parameter = packIntoListExpression(parameter);
    return new FunctionExpression(token, function, parameter);
  }
View Full Code Here

    List<HiddenTokenAwareTree> children = actual.getChildren();
    String name = buildFunctionName(children.get(0));

    if (children.size() == 1) {
      /* No arguments to the function */
      return new FunctionExpression(token, name, new EmptyExpression(token));
    }

    HiddenTokenAwareTree parameterNode = children.get(1);

    Expression parameter = (Expression) parentBuilder.switchOn(parameterNode);
    //FIXME: (API) this is a hack - if what come out is not comma separated list, add it to comma separated list. - once there is API changing version it will be better to store parameters list in the function
    if (!isListOfParameters(parameter)) {
      parameter = packIntoListExpression(parameter);
    }
    return new FunctionExpression(token, name, parameter);
  }
View Full Code Here

      // IE8 cannot handle a data-uri larger than 32KB. If this is exceeded
      // and the --ieCompat flag is enabled, return a normal url() instead.
      int fileSizeInKB = data.length / 1024;
      if (fileSizeInKB >= DATA_URI_MAX_KB) {
        problemsHandler.warnIE8UnsafeDataUri(functionCall, filename, fileSizeInKB, DATA_URI_MAX_KB);
        FunctionExpression result = new FunctionExpression(token, "url", functionCall.getParameter().clone());
        result.configureParentToAllChilds();
        return result;
      }

      return toDataUri(token, mimetype, data, fragments);
View Full Code Here

  private Expression toDataUri(HiddenTokenAwareTree token, String mimetype, String data, String fragments) {
    StringBuilder value = new StringBuilder("data:");
    value.append(mimetype).append(",").append(data).append(fragments);

    CssString parameter = new CssString(token, value.toString(), "\"");
    return new FunctionExpression(token, "url", parameter);
  }
View Full Code Here

    if (useBase64)
      value.append(";base64");
    value.append(",").append(data);

    CssString parameter = new CssString(token, value.toString(), "\'");
    return new FunctionExpression(token, "url", parameter);
  }
View Full Code Here

  @Override
  protected boolean checkType(Expression parameter) {
    if (parameter.getType() != ASTCssNodeType.FUNCTION)
      return false;
   
    FunctionExpression function = (FunctionExpression) parameter;
    return function.getName().equalsIgnoreCase("url");
  }
View Full Code Here

  @Override
  public Expression evaluate(FunctionExpression input, List<Expression> parameters, Expression evaluatedParameter) {
    for (LessFunction function : functions) {
      if (function.canEvaluate(input, parameters)) {
        FunctionExpression inputClone = input.clone();
        List<Expression> parametersClone = ArraysUtils.deeplyClonedList(parameters);
        Expression evaluatedParameterClone = evaluatedParameter.clone();
        return fixResult(function.evaluate(inputClone, parametersClone, evaluatedParameterClone, new SafeLessProblem(problemsHandler, inputClone)), input);
      }
    }
View Full Code Here

    while (expanded.hasNext() && next.getType()!=ASTCssNodeType.NUMBER) {
      next = expanded.next();
    }
   
    if (next.getType()!=ASTCssNodeType.NUMBER) {
      return new FunctionExpression(token, getName(), null);
    }
   
    NumberExpression result = (NumberExpression) next;
    while (expanded.hasNext()) {
      next = expanded.next();
View Full Code Here

TOP

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

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.