Class CssNode
- java.lang.Object
-
- com.google.common.css.compiler.ast.CssNode
-
- All Implemented Interfaces:
Locatable
- Direct Known Subclasses:
CssCombinatorNode,CssDeclarationNode,CssKeyframeRulesetNode,CssKeyNode,CssNodesListNode,CssRefinerNode,CssRootNode,CssRulesetNode,CssSelectorNode,CssValueNode
public abstract class CssNode extends java.lang.Object implements Locatable
A node of the abstract syntax tree.TODO(oana): Declare this class as: public abstract class CssNode<T extends CssNode> {...}
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCssNode()Constructor of a node.protectedCssNode(CssNode parent)Constructor of a node.protectedCssNode(CssNode parent, SourceCodeLocation sourceCodeLocation)Constructor of a node.protectedCssNode(CssNode parent, java.util.List<CssCommentNode> comments, SourceCodeLocation sourceCodeLocation)Constructor of a node.protectedCssNode(SourceCodeLocation sourceCodeLocation)Constructor of a node.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Iterable<CssNode>ancestors()This node and the transitive closure of itsparents.voidappendComment(CssCommentNode comment)abstract CssNodedeepCopy()static <N extends CssNode>
java.util.List<N>deepCopyNodes(java.util.List<N> nodes)booleanequals(java.lang.Object obj)This is the default implementation ofequals().java.util.List<CssCommentNode>getComments()CssNodegetParent()booleangetShouldBeFlipped()SourceCodeLocationgetSourceCodeLocation()VisitControllergetVisitController()booleanhasComment(java.lang.String comment)Returns whether one of the comments attached to this node exactly matches the given string.inthashCode()This is the default implementation ofhashCode().booleaninFunArgs()Returns true when any of anode'sancestors()is a function node.voidsetComments(java.util.List<CssCommentNode> comments)voidsetShouldBeFlipped(boolean shouldBeFlipped)Marks a node whether it should be flipped or not.voidsetSourceCodeLocation(SourceCodeLocation sourceCodeLocation)java.lang.StringtoString()This is the default implementation oftoString().
-
-
-
Constructor Detail
-
CssNode
protected CssNode()
Constructor of a node.
-
CssNode
protected CssNode(@Nullable SourceCodeLocation sourceCodeLocation)Constructor of a node.- Parameters:
sourceCodeLocation- sourceCodeLocation
-
CssNode
protected CssNode(@Nullable CssNode parent)Constructor of a node.- Parameters:
parent- parent
-
CssNode
protected CssNode(@Nullable CssNode parent, @Nullable SourceCodeLocation sourceCodeLocation)Constructor of a node.- Parameters:
parent- parentsourceCodeLocation- sourceCodeLocation
-
CssNode
protected CssNode(@Nullable CssNode parent, @Nullable java.util.List<CssCommentNode> comments, @Nullable SourceCodeLocation sourceCodeLocation)Constructor of a node.- Parameters:
parent- parentcomments- commentssourceCodeLocation- sourceCodeLocation
-
-
Method Detail
-
deepCopy
public abstract CssNode deepCopy()
-
getParent
public CssNode getParent()
-
getSourceCodeLocation
public SourceCodeLocation getSourceCodeLocation()
- Specified by:
getSourceCodeLocationin interfaceLocatable
-
setSourceCodeLocation
public void setSourceCodeLocation(@Nullable SourceCodeLocation sourceCodeLocation)
-
appendComment
public void appendComment(CssCommentNode comment)
-
setComments
public void setComments(java.util.List<CssCommentNode> comments)
-
getComments
public java.util.List<CssCommentNode> getComments()
-
hasComment
public boolean hasComment(java.lang.String comment)
Returns whether one of the comments attached to this node exactly matches the given string.- Parameters:
comment- comment
-
getShouldBeFlipped
public boolean getShouldBeFlipped()
-
setShouldBeFlipped
public void setShouldBeFlipped(boolean shouldBeFlipped)
Marks a node whether it should be flipped or not.- Parameters:
shouldBeFlipped- Whether the node should be flipped or not.
-
equals
public final boolean equals(@Nullable java.lang.Object obj)This is the default implementation ofequals(). The method is markedfinalso that nobody changes the default behavior.The rationale for not allowing redefinition of equals is that different compiler passes and different optimizations have their own notion of equality. In order to avoid confusion and errors everybody that needs a custom definition of equality and custom hash codes should use customized collections with custom comparators or hash code providers.
In addition, this class should not implement
Comparable. UseComparatorinstead.- Overrides:
equalsin classjava.lang.Object- See Also:
Object.equals(Object)
-
hashCode
public final int hashCode()
This is the default implementation ofhashCode(). The method is markedfinalso that nobody changes the default behavior.- Overrides:
hashCodein classjava.lang.Object- See Also:
equals(Object),Object.hashCode()
-
toString
public java.lang.String toString()
This is the default implementation oftoString().Overriding this method should only be done for debugging or logging purposes, not for the actual functionality of the compiler. If a string representation of a tree is needed, define a Visitor that builds the desired representation.
- Overrides:
toStringin classjava.lang.Object- See Also:
Object.toString()
-
ancestors
public java.lang.Iterable<CssNode> ancestors()
This node and the transitive closure of itsparents.
-
inFunArgs
public boolean inFunArgs()
Returns true when any of anode'sancestors()is a function node.
-
getVisitController
public VisitController getVisitController()
-
deepCopyNodes
public static <N extends CssNode> java.util.List<N> deepCopyNodes(java.util.List<N> nodes)
-
-