Class AbstractRenderer

java.lang.Object
org.pkl.core.stdlib.AbstractRenderer
All Implemented Interfaces:
VmValueVisitor
Direct Known Subclasses:
PcfRenderer, RendererNodes.Renderer

public abstract class AbstractRenderer extends Object implements VmValueVisitor
Base class for renderers that are part of the standard library.
  • Field Details

    • LINE_BREAK

      protected static final char LINE_BREAK
      See Also:
    • name

      protected final String name
      The name of this renderer.
    • builder

      protected final StringBuilder builder
    • indent

      protected final String indent
      The indent to be used.
    • converter

      protected final PklConverter converter
    • currPath

      protected Deque<Object> currPath
    • enclosingValue

      @Nullable protected @Nullable VmValue enclosingValue
      The value directly enclosing the currently visited value, if any.
    • currIndent

      protected final StringBuilder currIndent
      The current indent. Modified by increaseIndent() and decreaseIndent().
    • currSourceSection

      @Nullable protected @Nullable com.oracle.truffle.api.source.SourceSection currSourceSection
      The (closest) SourceSection of the value being visited, for better error messages.
  • Constructor Details

  • Method Details

    • renderDocument

      public final void renderDocument(Object value)
    • renderValue

      public final void renderValue(Object value)
    • visit

      public void visit(Object value)
      Specified by:
      visit in interface VmValueVisitor
    • visitDocument

      protected abstract void visitDocument(Object value)
    • visitTopLevelValue

      protected abstract void visitTopLevelValue(Object value)
    • visitRenderDirective

      protected abstract void visitRenderDirective(VmTyped value)
      Perform logic for rendering a render directive. Render directives should be rendered verbatim.
    • startDynamic

      protected abstract void startDynamic(VmDynamic value)
    • startTyped

      protected abstract void startTyped(VmTyped value)
    • startListing

      protected abstract void startListing(VmListing value)
    • startMapping

      protected abstract void startMapping(VmMapping value)
    • startList

      protected abstract void startList(VmList value)
    • startSet

      protected abstract void startSet(VmSet value)
    • startMap

      protected abstract void startMap(VmMap value)
    • visitElement

      protected abstract void visitElement(long index, Object value, boolean isFirst)
      Visits an element of a VmDynamic, VmListing, VmList, or VmSet.
    • visitEntryKey

      protected abstract void visitEntryKey(Object key, boolean isFirst)
      Visits an entry key of a VmDynamic, VmMapping, or VmMap.
    • visitEntryValue

      protected abstract void visitEntryValue(Object value)
      Visits an entry value of a VmDynamic, VmMapping, or VmMap.
    • visitProperty

      protected abstract void visitProperty(Identifier name, Object value, boolean isFirst)
      Visits a property of a VmDynamic or VmTyped.
    • endDynamic

      protected abstract void endDynamic(VmDynamic value, boolean isEmpty)
    • endTyped

      protected abstract void endTyped(VmTyped value, boolean isEmpty)
    • endListing

      protected abstract void endListing(VmListing value, boolean isEmpty)
    • endMapping

      protected abstract void endMapping(VmMapping value, boolean isEmpty)
    • endList

      protected abstract void endList(VmList value)
    • endSet

      protected abstract void endSet(VmSet value)
    • endMap

      protected abstract void endMap(VmMap value)
    • visitTyped

      public void visitTyped(VmTyped value)
      Specified by:
      visitTyped in interface VmValueVisitor
    • visitDynamic

      public final void visitDynamic(VmDynamic value)
      Specified by:
      visitDynamic in interface VmValueVisitor
    • canRenderPropertyOrEntryOf

      protected boolean canRenderPropertyOrEntryOf(VmDynamic object)
    • visitListing

      public final void visitListing(VmListing value)
      Specified by:
      visitListing in interface VmValueVisitor
    • visitMapping

      public final void visitMapping(VmMapping value)
      Specified by:
      visitMapping in interface VmValueVisitor
    • visitList

      public final void visitList(VmList value)
      Specified by:
      visitList in interface VmValueVisitor
    • visitSet

      public final void visitSet(VmSet value)
      Specified by:
      visitSet in interface VmValueVisitor
    • visitMap

      public final void visitMap(VmMap value)
      Specified by:
      visitMap in interface VmValueVisitor
    • visitTypeAlias

      public final void visitTypeAlias(VmTypeAlias value)
      Specified by:
      visitTypeAlias in interface VmValueVisitor
    • visitClass

      public final void visitClass(VmClass value)
      Specified by:
      visitClass in interface VmValueVisitor
    • visitFunction

      public final void visitFunction(VmFunction value)
      Specified by:
      visitFunction in interface VmValueVisitor
    • cannotRenderTypeAddConverter

      protected void cannotRenderTypeAddConverter(VmValue value)
    • cannotRenderNonStringKey

      protected void cannotRenderNonStringKey(Object key)
    • increaseIndent

      protected void increaseIndent()
    • decreaseIndent

      protected void decreaseIndent()