Class SourceMapGeneratorV1

java.lang.Object
com.google.debugging.sourcemap.SourceMapGeneratorV1
All Implemented Interfaces:
SourceMapGenerator

public class SourceMapGeneratorV1 extends Object implements SourceMapGenerator
Collects information mapping the generated (compiled) source back to its original source for debugging purposes.
  • Constructor Details

    • SourceMapGeneratorV1

      public SourceMapGeneratorV1()
  • Method Details

    • addMapping

      public void addMapping(String sourceName, @Nullable String symbolName, FilePosition sourceStartPosition, FilePosition startPosition, FilePosition endPosition)
      Adds a mapping for the given node. Mappings must be added in order.
      Specified by:
      addMapping in interface SourceMapGenerator
      Parameters:
      startPosition - The position on the starting line
      endPosition - The position on the ending line.
      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.
    • setWrapperPrefix

      public void setWrapperPrefix(String prefix)
      Sets the prefix used for wrapping the generated source file before it is output. This ensures that the source map is adjusted as needed.
      Specified by:
      setWrapperPrefix in interface SourceMapGenerator
      Parameters:
      prefix - The prefix that is added before the generated source code.
    • setStartingPosition

      public void setStartingPosition(int offsetLine, int offsetIndex)
      Sets the source code that exists in the buffer to 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.
      Specified by:
      setStartingPosition in interface SourceMapGenerator
      Parameters:
      offsetLine - The index of the current line being printed.
      offsetIndex - The column index of the current character being printed.
    • reset

      public void reset()
      Resets the source map for reuse for the generation of a new source file.
      Specified by:
      reset in interface SourceMapGenerator
    • appendTo

      public void appendTo(Appendable out, String name) throws IOException
      Appends the source map in LavaBug format to the given buffer.
      Specified by:
      appendTo in interface SourceMapGenerator
      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:
      IOException
    • validate

      public void validate(boolean validate)
      Description copied from interface: SourceMapGenerator
      Whether to perform additional validation on the source map.
      Specified by:
      validate in interface SourceMapGenerator
    • appendIndexMapTo

      public void appendIndexMapTo(Appendable out, String name, List<SourceMapSection> appSections)
      Description copied from interface: SourceMapGenerator
      Appends the index source map to the given buffer.
      Specified by:
      appendIndexMapTo in interface SourceMapGenerator
      Parameters:
      out - The stream to which the map will be appended.
      name - The name of the generated source file that this source map represents.
      appSections - An ordered list of map sections to include in the index.