com.vaadin.sass.internal
Class ScssStylesheet

java.lang.Object
  extended by com.vaadin.sass.internal.tree.Node
      extended by com.vaadin.sass.internal.ScssStylesheet
All Implemented Interfaces:
Serializable

public class ScssStylesheet
extends Node

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.vaadin.sass.internal.tree.Node
Node.BuildStringStrategy, Node.PrintStrategy, Node.ToStringStrategy
 
Field Summary
 
Fields inherited from class com.vaadin.sass.internal.tree.Node
children, parentNode, PRINT_STRATEGY, TO_STRING_STRATEGY
 
Constructor Summary
ScssStylesheet()
          Read in a file SCSS and parse it into a ScssStylesheet
 
Method Summary
 void addChild(int index, VariableNode node)
           
 void addResolver(ScssStylesheetResolver resolver)
          Adds the given resolver to the resolver list
static void addVariable(VariableNode node)
           
static void closeVariableScope(Map<String,VariableNode> originalScope)
          End a scope for variables, replacing all active variables with those from the original scope (obtained from openVariableScope()).
 void compile()
          Applies all the visitors and compiles SCSS into Css.
static ScssStylesheet get()
           
static ScssStylesheet get(String identifier)
          Main entry point for the SASS compiler.
static ScssStylesheet get(String identifier, ScssStylesheet parentStylesheet)
          Main entry point for the SASS compiler.
static ScssStylesheet get(String identifier, ScssStylesheet parentStylesheet, SCSSDocumentHandler documentHandler, SCSSErrorHandler errorHandler)
          Main entry point for the SASS compiler.
 String getCharset()
           
 String getDirectory()
          Returns the directory containing this style sheet
 String getFileName()
          Returns the full file name for this style sheet
static FunctionDefNode getFunctionDefinition(String name)
           
static HashMap<Node,Node> getLastNodeAdded()
           
static MixinDefNode getMixinDefinition(String name)
           
 List<ScssStylesheetResolver> getResolvers()
          Retrieves a list of resolvers to use when resolving imports
static VariableNode getVariable(String string)
           
static ArrayList<VariableNode> getVariables()
           
static Map<String,VariableNode> openVariableScope()
          Start a new scope for variables.
 String printState()
          Prints out the current state of the node tree.
 void removeEmptyBlocks(Node node)
           
 org.w3c.css.sac.InputSource resolveStylesheet(String identifier, ScssStylesheet parentStylesheet)
           
 void setCharset(String charset)
           
 void setFile(File file)
           
 void setResolvers(List<ScssStylesheetResolver> resolvers)
          Sets the list of resolvers to use when resolving imports
 String toString()
           
 void traverse()
          Method for manipulating the data contained within the Node.
 boolean traverse(Node node)
          Traverses a node and its children recursively, calling all the appropriate handlers via Node.traverse().
static void warning(String msg)
           
 
Methods inherited from class com.vaadin.sass.internal.tree.Node
appendAll, appendChild, appendChild, appendChildrenAfter, copy, getChildren, getParentNode, hasChildren, removeChild, setChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScssStylesheet

public ScssStylesheet()
Read in a file SCSS and parse it into a ScssStylesheet

Parameters:
file -
Throws:
IOException
Method Detail

get

public static ScssStylesheet get(String identifier)
                          throws org.w3c.css.sac.CSSException,
                                 IOException
Main entry point for the SASS compiler. Takes in a file and builds up a ScssStylesheet tree out of it. Calling compile() on it will transform SASS into CSS. Calling printState() will print out the SCSS/CSS.

Parameters:
identifier - The file path. If null then null is returned.
Returns:
Throws:
org.w3c.css.sac.CSSException
IOException

get

public static ScssStylesheet get(String identifier,
                                 ScssStylesheet parentStylesheet)
                          throws org.w3c.css.sac.CSSException,
                                 IOException
Main entry point for the SASS compiler. Takes in a file and an optional parent style sheet, then builds up a ScssStylesheet tree out of it. Calling compile() on it will transform SASS into CSS. Calling printState() will print out the SCSS/CSS.

Parameters:
identifier - The file path. If null then null is returned.
parentStylesheet - Style sheet from which to inherit resolvers and encoding. May be null.
Returns:
Throws:
org.w3c.css.sac.CSSException
IOException

get

public static ScssStylesheet get(String identifier,
                                 ScssStylesheet parentStylesheet,
                                 SCSSDocumentHandler documentHandler,
                                 SCSSErrorHandler errorHandler)
                          throws org.w3c.css.sac.CSSException,
                                 IOException
Main entry point for the SASS compiler. Takes in a file, an optional parent stylesheet, and document and error handlers. Then builds up a ScssStylesheet tree out of it. Calling compile() on it will transform SASS into CSS. Calling printState() will print out the SCSS/CSS.

Parameters:
identifier - The file path. If null then null is returned.
parentStylesheet - Style sheet from which to inherit resolvers and encoding. May be null.
documentHandler - Instance of document handler. May not be null.
errorHandler - Instance of error handler. May not be null.
Returns:
Throws:
org.w3c.css.sac.CSSException
IOException

resolveStylesheet

public org.w3c.css.sac.InputSource resolveStylesheet(String identifier,
                                                     ScssStylesheet parentStylesheet)

getResolvers

public List<ScssStylesheetResolver> getResolvers()
Retrieves a list of resolvers to use when resolving imports

Returns:
the resolvers used to resolving imports

setResolvers

public void setResolvers(List<ScssStylesheetResolver> resolvers)
Sets the list of resolvers to use when resolving imports

Parameters:
resolvers - the resolvers to set

addResolver

public void addResolver(ScssStylesheetResolver resolver)
Adds the given resolver to the resolver list

Parameters:
resolver - The resolver to add

compile

public void compile()
             throws Exception
Applies all the visitors and compiles SCSS into Css.

Throws:
Exception

printState

public String printState()
Prints out the current state of the node tree. Will return SCSS before compile and CSS after. For now this is an own method with it's own implementation that most node types will implement themselves.

Overrides:
printState in class Node
Returns:
State as a string

toString

public String toString()
Overrides:
toString in class Object

addChild

public void addChild(int index,
                     VariableNode node)

get

public static ScssStylesheet get()

traverse

public void traverse()
Description copied from class: Node
Method for manipulating the data contained within the Node. Traversing a node is allowed to modify the node, replace it with one or more nodes at the same or later position in its parent and modify the children of the node, but not modify or remove preceding nodes in its parent.

Specified by:
traverse in class Node

traverse

public boolean traverse(Node node)
Traverses a node and its children recursively, calling all the appropriate handlers via Node.traverse(). The node itself may be removed during the traversal and replaced with other nodes at the same position or later on the child list of its parent.

Parameters:
node - node to traverse
Returns:
true if the node was removed (and possibly replaced by others), false if not

openVariableScope

public static Map<String,VariableNode> openVariableScope()
Start a new scope for variables. Any variables set or modified after opening a new scope are only valid until the scope is closed, at which time they are replaced with their old values.

Returns:
old scope to give to a paired closeVariableScope(Map) call at the end of the scope (unmodifiable map).

closeVariableScope

public static void closeVariableScope(Map<String,VariableNode> originalScope)
End a scope for variables, replacing all active variables with those from the original scope (obtained from openVariableScope()).

Parameters:
originalScope - original scope

removeEmptyBlocks

public void removeEmptyBlocks(Node node)

addVariable

public static void addVariable(VariableNode node)

getVariable

public static VariableNode getVariable(String string)

getVariables

public static ArrayList<VariableNode> getVariables()

getMixinDefinition

public static MixinDefNode getMixinDefinition(String name)

getFunctionDefinition

public static FunctionDefNode getFunctionDefinition(String name)

setFile

public void setFile(File file)

getDirectory

public String getDirectory()
Returns the directory containing this style sheet

Returns:
The directory containing this style sheet

getFileName

public String getFileName()
Returns the full file name for this style sheet

Returns:
The full file name for this style sheet

getLastNodeAdded

public static HashMap<Node,Node> getLastNodeAdded()

warning

public static final void warning(String msg)

getCharset

public String getCharset()

setCharset

public void setCharset(String charset)


Copyright © 2013–2014 Vaadin. All rights reserved.