Record Class ScriptComments

java.lang.Object
java.lang.Record
com.darkcollective.relix.lang.ast.ScriptComments
Record Components:
namespace - the comments placed by the namespace declaration, as a statement's are; ScriptComments.StatementComments.NONE when it declares none
statements - one entry per statement, in the order of Script.statements(); empty when nothing is known about any
footer - the comments after the last statement, on lines of their own
footerSpaced - whether a blank line separated the footer from the statements

public record ScriptComments(ScriptComments.StatementComments namespace, List<ScriptComments.StatementComments> statements, List<Comment> footer, boolean footerSpaced) extends Record
The comments a parsed script carried, each placed by the code it was written next to, so that ScriptPrinter can put it back there.

A comment is not part of what a script means, and no phase above the parser reads one. These are kept only for printing: a formatter that dropped them could not be run over someone's files. A script built rather than parsed has NONE.

Since:
1.0
  • Field Details

    • NONE

      public static final ScriptComments NONE
      No comments at all: what a script built from statements carries.
  • Constructor Details

  • Method Details

    • statement

      public ScriptComments.StatementComments statement(int index)
      The comments placed by one statement.
      Parameters:
      index - the statement's position in Script.statements()
      Returns:
      its comments, or ScriptComments.StatementComments.NONE when none are recorded
      Since:
      1.0
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • namespace

      Returns the value of the namespace record component.
      Returns:
      the value of the namespace record component
    • statements

      public List<ScriptComments.StatementComments> statements()
      Returns the value of the statements record component.
      Returns:
      the value of the statements record component
    • footer

      public List<Comment> footer()
      Returns the value of the footer record component.
      Returns:
      the value of the footer record component
    • footerSpaced

      public boolean footerSpaced()
      Returns the value of the footerSpaced record component.
      Returns:
      the value of the footerSpaced record component