All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.sommeri.less4j.LessFunction Maven / Gradle / Ivy

Go to download

Less language is an extension of css and less4j compiles it into regular css. It adds several dynamic features into css: variables, expressions, nested rules. Less4j is a port. The original compiler was written in JavaScript and is called less.js. The less language is mostly defined in less.js documentation/issues and by what less.js actually do. Links to less.js: * home page: http://lesscss.org/ * source code & issues: https://github.com/cloudhead/less.js

There is a newer version: 1.17.2
Show newest version
package com.github.sommeri.less4j;

import java.util.List;

import com.github.sommeri.less4j.core.ast.ComposedExpression;
import com.github.sommeri.less4j.core.ast.Expression;
import com.github.sommeri.less4j.core.ast.FunctionExpression;

/**
 * Implement this interface to create custom less function. 
 *
 */
public interface LessFunction {

  /**
   * Returns true if this function can evaluate the less function.    
   * 
   * @param input - function to be evaluated
   * @param parameters - function parameters 
   * 
   * @return true only if the implementation can evaluate the input function.
   */
  public boolean canEvaluate(FunctionExpression input, List parameters);

  /**
   * Evaluates less function in parameter. Will be called only if {@link #canEvaluate(FunctionExpression, List)} returns true.
   * 
   * The evaluatedParameter contains function arguments as parsed into a single abstract 
   * syntax tree node. A function called with multiple arguments would be sent an instance of 
   * {@link ComposedExpression} with  arguments bundled in as childs. 
   * 
   * The evaluatedParameter contains list of function arguments. It is convenience argument 
   * and contains evaluatedParameter expression split by commas.
   * 
   * @param input - input function
   * @param parameters - function arguments split (evaluated)
   * @param evaluatedParameter - all function arguments as a single expression (evaluated)  
   * @param problems - errors and warnings collector
   * 
   * @return result of function evaluation. Must NOT return null and should return 
   *     correct abstract syntax tree node. Eg. 
   *     * solved parent child relationships (both ways), 
   *     * each node instance can appear in the three only once,
   *     * correctly filled underlying structure properties.
   */
  public Expression evaluate(FunctionExpression input, List parameters, Expression evaluatedParameter, LessProblems problems);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy