Class StringNode

All Implemented Interfaces:
MoveCheckable, TreeMember, ParseTree, SyntaxTree, TerminalNode, Tree
Direct Known Subclasses:
Directive

public class StringNode extends UnparsableCSTNode
String node provides a terminal node with arbitrary contents. This is useful for inserting strings into the printed code such as comments. Only use this terminal node for non-parsed tokens like comments, whitespace or preprocessor directives. For all other syntax features, use the local roots system. Parse tree search doesn't work inside string nodes as they are not parsed.
See Also:
  • Constructor Details

    • StringNode

      public StringNode(String content)
      Creates a new string node with the given string content.
      Parameters:
      content - The string to create a token for
    • StringNode

      public StringNode(String content, boolean doNewlineInsertion)
      Creates a new string node with the given string content and a newline insertion flag.
      Parameters:
      content - The string to create a token for
      doNewlineInsertion - Whether to insert a newline before each group of unparsable CST nodes in the printer
  • Method Details

    • getPrinted

      protected String getPrinted()
      Description copied from class: TerminalCSTNode
      Generates the string representation of this CST object as it would be in the generated code.
      Specified by:
      getPrinted in class TerminalCSTNode
      Returns:
      The printed string for this CST object
    • doNewlineInsertion

      public boolean doNewlineInsertion()
      Description copied from class: UnparsableCSTNode
      If true, the printer will insert a newline before each group of consecutive unparsable CST nodes.
      Overrides:
      doNewlineInsertion in class UnparsableCSTNode
      Returns:
      If newline insertion should happen with this node
    • getContent

      protected String getContent()
      Returns the string node's content.
      Returns:
      The content