Interface SourceMapGenerator

  • All Known Implementing Classes:
    SourceMapGeneratorV3

    public interface SourceMapGenerator
    Collects information mapping the generated (compiled) source back to its original source for debugging purposes
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addMapping​(java.lang.String sourceName, java.lang.String symbolName, FilePosition sourceStartPosition, FilePosition outputStartPosition, FilePosition outputEndPosition)
      Adds a mapping for the given node.
      void addSourcesContent​(java.lang.String source, java.lang.String content)
      Adds a sourcesContent entry for the corresponding source.
      void appendIndexMapTo​(java.lang.Appendable out, java.lang.String name, java.util.List<SourceMapSection> sections)
      Appends the index source map to the given buffer.
      void appendTo​(java.lang.Appendable out, java.lang.String name)
      Appends the source map to the given buffer.
      void reset()
      Resets the source map for reuse.
      void setStartingPosition​(int offsetLine, int offsetIndex)
      Sets the source code that exists in the buffer for which the generated code is being generated.
      void setWrapperPrefix​(java.lang.String prefix)
      Sets the prefix used for wrapping the generated source file before it is written.
      void validate​(boolean validate)
      Whether to perform additional validation on the source map.
    • Method Detail

      • appendTo

        void appendTo​(java.lang.Appendable out,
                      java.lang.String name)
               throws java.io.IOException
        Appends the source map to the given buffer.
        Parameters:
        out - The stream to which the map will be appended.
        name - The name of the generated source file that this source map represents.
        Throws:
        java.io.IOException
      • appendIndexMapTo

        void appendIndexMapTo​(java.lang.Appendable out,
                              java.lang.String name,
                              java.util.List<SourceMapSection> sections)
                       throws java.io.IOException
        Appends the index source map to the given buffer.
        Parameters:
        out - The stream to which the map will be appended.
        name - The name of the generated source file that this source map represents.
        sections - An ordered list of map sections to include in the index.
        Throws:
        java.io.IOException
      • reset

        void reset()
        Resets the source map for reuse. A reset needs to be called between each generated output file.
      • addMapping

        void addMapping​(java.lang.String sourceName,
                        @Nullable
                        java.lang.String symbolName,
                        FilePosition sourceStartPosition,
                        FilePosition outputStartPosition,
                        FilePosition outputEndPosition)
        Adds a mapping for the given node. Mappings must be added in order.
        Parameters:
        sourceName - The file name to use in the generate source map to represent this source.
        symbolName - The symbol name associated with this position in the source map.
        sourceStartPosition - The starting position in the original source for represented range outputStartPosition to outputEndPosition in the generated file.
        outputStartPosition - The position on the starting line
        outputEndPosition - The position on the ending line.
      • addSourcesContent

        void addSourcesContent​(java.lang.String source,
                               java.lang.String content)
        Adds a sourcesContent entry for the corresponding source.
        Parameters:
        source - The source name.
        content - The source content.
      • setWrapperPrefix

        void setWrapperPrefix​(java.lang.String prefix)
        Sets the prefix used for wrapping the generated source file before it is written. This ensures that the source map is adjusted for the change in character offsets.
        Parameters:
        prefix - The prefix that is added before the generated source code.
      • setStartingPosition

        void setStartingPosition​(int offsetLine,
                                 int offsetIndex)
        Sets the source code that exists in the buffer for which the generated code is being generated. This ensures that the source map accurately reflects the fact that the source is being appended to an existing buffer and as such, does not start at line 0, position 0 but rather some other line and position.
        Parameters:
        offsetLine - The index of the current line being printed.
        offsetIndex - The column index of the current character being printed.
      • validate

        void validate​(boolean validate)
        Whether to perform additional validation on the source map.
        Parameters:
        validate -