Module aya.cli.impl

Record Class FaithfulPrettier

java.lang.Object
java.lang.Record
org.aya.cli.literate.FaithfulPrettier
Record Components:
problems - All problems of a single file
highlights - All highlights of a single file
All Implemented Interfaces:
Consumer<org.aya.literate.Literate>, org.aya.literate.LiterateConsumer

public record FaithfulPrettier(@NotNull kala.collection.immutable.ImmutableSeq<org.aya.util.reporter.Problem> problems, @NotNull kala.collection.immutable.ImmutableSeq<HighlightInfo> highlights, @NotNull org.aya.util.prettier.PrettierOptions options) extends Record implements org.aya.literate.LiterateConsumer
This prettier maintains all highlights created from SyntaxHighlight and all problems reported by Aya compiler. Implementation-wise, this prettier can be seen as a highlight server for a single file.

When the highlight of a code block is requested, it filters out all highlights and problems that belong to the code block, and then build a Doc containing the highlighted source code mixed with compiler outputs, as done in highlight(String, SourcePos).

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.aya.literate.LiterateConsumer

    org.aya.literate.LiterateConsumer.InstanceExtractinator<T extends org.aya.literate.Literate>, org.aya.literate.LiterateConsumer.LiterateExtractinator<T>
  • Constructor Summary

    Constructors
    Constructor
    Description
    FaithfulPrettier(@NotNull kala.collection.immutable.ImmutableSeq<org.aya.util.reporter.Problem> problems, @NotNull kala.collection.immutable.ImmutableSeq<HighlightInfo> highlights, @NotNull org.aya.util.prettier.PrettierOptions options)
    Creates an instance of a FaithfulPrettier record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    accept(@NotNull org.aya.literate.Literate literate)
    Highlight all aya code blocks
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    @NotNull org.aya.pretty.doc.Doc
    highlight(@NotNull String raw, @NotNull org.aya.util.error.SourcePos codeRange)
    Apply highlights to source code string.
    @NotNull kala.collection.immutable.ImmutableSeq<HighlightInfo>
    Returns the value of the highlights record component.
    @NotNull org.aya.util.prettier.PrettierOptions
    Returns the value of the options record component.
    @NotNull kala.collection.immutable.ImmutableSeq<org.aya.util.reporter.Problem>
    Returns the value of the problems record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface java.util.function.Consumer

    andThen
  • Constructor Details

    • FaithfulPrettier

      public FaithfulPrettier(@NotNull @NotNull kala.collection.immutable.ImmutableSeq<org.aya.util.reporter.Problem> problems, @NotNull @NotNull kala.collection.immutable.ImmutableSeq<HighlightInfo> highlights, @NotNull @NotNull org.aya.util.prettier.PrettierOptions options)
      Creates an instance of a FaithfulPrettier record class.
      Parameters:
      problems - the value for the problems record component
      highlights - the value for the highlights record component
      options - the value for the options record component
  • Method Details

    • accept

      public void accept(@NotNull @NotNull org.aya.literate.Literate literate)
      Highlight all aya code blocks
      Specified by:
      accept in interface Consumer<org.aya.literate.Literate>
      Specified by:
      accept in interface org.aya.literate.LiterateConsumer
    • highlight

      @NotNull public @NotNull org.aya.pretty.doc.Doc highlight(@NotNull @NotNull String raw, @NotNull @NotNull org.aya.util.error.SourcePos codeRange)
      Apply highlights to source code string.
      Parameters:
      raw - the source code
      codeRange - where the raw start from (the 'raw' might be a piece of the source code, so it probably not starts from 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • problems

      @NotNull public @NotNull kala.collection.immutable.ImmutableSeq<org.aya.util.reporter.Problem> problems()
      Returns the value of the problems record component.
      Returns:
      the value of the problems record component
    • highlights

      @NotNull public @NotNull kala.collection.immutable.ImmutableSeq<HighlightInfo> highlights()
      Returns the value of the highlights record component.
      Returns:
      the value of the highlights record component
    • options

      @NotNull public @NotNull org.aya.util.prettier.PrettierOptions options()
      Returns the value of the options record component.
      Returns:
      the value of the options record component