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 Object implements Locatable
A node of the abstract syntax tree.

TODO(oana): Declare this class as: public abstract class CssNode<T extends CssNode> {...}

  • Constructor Details

    • 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 - parent
      sourceCodeLocation - sourceCodeLocation
    • CssNode

      protected CssNode(@Nullable CssNode parent, @Nullable List<CssCommentNode> comments, @Nullable SourceCodeLocation sourceCodeLocation)
      Constructor of a node.
      Parameters:
      parent - parent
      comments - comments
      sourceCodeLocation - sourceCodeLocation
  • Method Details

    • deepCopy

      public abstract CssNode deepCopy()
    • getParent

      public CssNode getParent()
    • getSourceCodeLocation

      public SourceCodeLocation getSourceCodeLocation()
      Specified by:
      getSourceCodeLocation in interface Locatable
    • setSourceCodeLocation

      public void setSourceCodeLocation(@Nullable SourceCodeLocation sourceCodeLocation)
    • appendComment

      public void appendComment(CssCommentNode comment)
    • setComments

      public void setComments(List<CssCommentNode> comments)
    • getComments

      public List<CssCommentNode> getComments()
    • hasComment

      public boolean hasComment(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 Object obj)
      This is the default implementation of equals(). The method is marked final so 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. Use Comparator instead.

      Overrides:
      equals in class Object
      See Also:
    • hashCode

      public final int hashCode()
      This is the default implementation of hashCode(). The method is marked final so that nobody changes the default behavior.
      Overrides:
      hashCode in class Object
      See Also:
    • toString

      public String toString()
      This is the default implementation of toString().

      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:
      toString in class Object
      See Also:
    • ancestors

      public Iterable<CssNode> ancestors()
      This node and the transitive closure of its parents.
    • inFunArgs

      public boolean inFunArgs()
      Returns true when any of a node's ancestors() is a function node.
    • getVisitController

      public VisitController getVisitController()
    • deepCopyNodes

      public static <N extends CssNode> List<N> deepCopyNodes(List<N> nodes)