com.google.javascript.jscomp
Interface SourceMap

All Known Implementing Classes:
SourceMap2, SourceMapLegacy

public interface SourceMap

Collects information mapping the generated (compiled) source back to its original source for debugging purposes.

See Also:
CodeConsumer, CodeGenerator, CodePrinter

Nested Class Summary
static class SourceMap.DetailLevel
          Source maps can be very large different levels of detail can be specified.
static class SourceMap.Format
           
 
Method Summary
 void addMapping(Node node, com.google.javascript.jscomp.Position startPosition, com.google.javascript.jscomp.Position endPosition)
          Adds a mapping for the given node.
 void appendTo(Appendable out, 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(String prefix)
          Sets the prefix used for wrapping the generated source file before it is written.
 

Method Detail

appendTo

void appendTo(Appendable out,
              String name)
              throws 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:
IOException

reset

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


addMapping

void addMapping(Node node,
                com.google.javascript.jscomp.Position startPosition,
                com.google.javascript.jscomp.Position endPosition)
Adds a mapping for the given node. Mappings must be added in order.

Parameters:
node - The node that the new mapping represents.
startPosition - The position on the starting line
endPosition - The position on the ending line.

setWrapperPrefix

void setWrapperPrefix(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.