示例#1
0
  private boolean appendFunctionExpression(FunctionExpression node) {
    cssOnly.append(node.getName());
    cssOnly.append('(');
    append(node.getParameter());
    cssOnly.append(')');

    return true;
  }
示例#2
0
  @Override
  public Expression evaluate(
      List<Expression> parameters,
      ProblemsHandler problemsHandler,
      FunctionExpression call,
      Expression evaluatedParameter) {
    if (parameters.size() > 1)
      problemsHandler.wrongNumberOfArgumentsToFunction(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");
    }
  }
示例#3
0
  public String extractFilename(
      Expression urlInput, ProblemsHandler problemsHandler, Configuration configuration) {
    ExpressionEvaluator expressionEvaluator =
        new ExpressionEvaluator(problemsHandler, configuration);
    Expression urlExpression = expressionEvaluator.evaluate(urlInput);

    if (urlExpression.getType() != ASTCssNodeType.FUNCTION)
      return toJavaFileSeparator(contentToString(urlExpression));

    // this is the only place in the compiler that can interpret the url function
    FunctionExpression function = (FunctionExpression) urlExpression;
    if (!"url".equals(function.getName().toLowerCase())) return null;

    List<Expression> parameters =
        expressionEvaluator.evaluate(function.getParameter()).splitByComma();
    if (parameters.isEmpty()) return null;

    return toJavaFileSeparator(contentToString(parameters.get(0)));
  }