Class TsrgFileWriter

java.lang.Object
net.fabricmc.mappingio.format.srg.TsrgFileWriter
All Implemented Interfaces:
Closeable, AutoCloseable, MappingVisitor, MappingWriter

public final class TsrgFileWriter extends Object implements MappingWriter
  • Constructor Details

    • TsrgFileWriter

      public TsrgFileWriter(Writer writer, boolean tsrg2)
  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • getFlags

      public Set<MappingFlag> getFlags()
      Specified by:
      getFlags in interface MappingVisitor
    • visitNamespaces

      public void visitNamespaces(String srcNamespace, List<String> dstNamespaces) throws IOException
      Specified by:
      visitNamespaces in interface MappingVisitor
      Throws:
      IOException
    • visitMetadata

      public void visitMetadata(String key, @Nullable @Nullable String value) throws IOException
      Specified by:
      visitMetadata in interface MappingVisitor
      Throws:
      IOException
    • visitClass

      public boolean visitClass(String srcName) throws IOException
      Description copied from interface: MappingVisitor
      Visit a class.
      Specified by:
      visitClass in interface MappingVisitor
      Parameters:
      srcName - The fully qualified source name of the class, in internal form (slashes instead of dots, dollar signs for delimiting inner classes).
      Returns:
      Whether the class's content should be visited too.
      Throws:
      IOException
    • visitField

      public boolean visitField(String srcName, @Nullable @Nullable String srcDesc) throws IOException
      Specified by:
      visitField in interface MappingVisitor
      Throws:
      IOException
    • visitMethod

      public boolean visitMethod(String srcName, @Nullable @Nullable String srcDesc) throws IOException
      Specified by:
      visitMethod in interface MappingVisitor
      Throws:
      IOException
    • visitMethodArg

      public boolean visitMethodArg(int argPosition, int lvIndex, @Nullable @Nullable String srcName) throws IOException
      Description copied from interface: MappingVisitor
      Visit a parameter.
      Specified by:
      visitMethodArg in interface MappingVisitor
      Parameters:
      argPosition - Always starts at 0 and gets incremented by 1 for each additional parameter.
      lvIndex - The parameter's local variable index in the current method, also known as slot. Starts at 0 for static methods, 1 otherwise. For each additional parameter, it gets incremented by 1, or by 2 if it's a double-wide primitive (long or double).
      srcName - The optional source name of the parameter.
      Returns:
      Whether the arg's content should be visited too.
      Throws:
      IOException
    • visitMethodVar

      public boolean visitMethodVar(int lvtRowIndex, int lvIndex, int startOpIdx, int endOpIdx, @Nullable @Nullable String srcName) throws IOException
      Description copied from interface: MappingVisitor
      Visit a variable.
      Specified by:
      visitMethodVar in interface MappingVisitor
      Parameters:
      lvtRowIndex - The variable's index in the method's LVT (local variable table). It is optional, so -1 can be passed instead. This is the case since LVTs themselves are optional debug information, see JVMS 4.7.13.
      lvIndex - The var's local variable index in the current method, also known as slot. For each additional variable, it gets incremented by 1, or by 2 if it's a double-wide primitive (long or double). The first variable starts at the last parameter's slot plus wideness.
      startOpIdx - Required for cases when the lvIndex alone doesn't uniquely identify a local variable. This is the case when variables get re-defined later on, in which case most decompilers opt to not re-define the existing var, but instead generate a new one (with both sharing the same lvIndex).
      endOpIdx - Counterpart to startOpIdx. Exclusive.
      srcName - The optional source name of the variable.
      Returns:
      Whether the var's content should be visited too.
      Throws:
      IOException
    • visitDstName

      public void visitDstName(MappedElementKind targetKind, int namespace, String name)
      Description copied from interface: MappingVisitor
      Destination name for the current element.
      Specified by:
      visitDstName in interface MappingVisitor
      Parameters:
      namespace - Namespace index (index into the dstNamespaces list in MappingVisitor.visitNamespaces(String, List)).
      name - Destination name.
    • visitElementContent

      public boolean visitElementContent(MappedElementKind targetKind) throws IOException
      Description copied from interface: MappingVisitor
      Determine whether the element content (comment, sub-elements) should be visited.

      Called after visiting the target itself (e.g. visitClass for targetKind=class), its dst names and descs, but before any child elements or the comment.

      This is also a notification about all available dst names having been passed on.

      Specified by:
      visitElementContent in interface MappingVisitor
      Returns:
      true if the contents are to be visited, false otherwise
      Throws:
      IOException
    • visitComment

      public void visitComment(MappedElementKind targetKind, String comment) throws IOException
      Description copied from interface: MappingVisitor
      Comment for the specified element (last content-visited or any parent).
      Specified by:
      visitComment in interface MappingVisitor
      Parameters:
      comment - Comment as a potentially multi-line string.
      Throws:
      IOException