public class SourceMapGeneratorV3 extends Object implements SourceMapGenerator
Modifier and Type | Class and Description |
---|---|
static interface |
SourceMapGeneratorV3.ExtensionMergeAction
This interface provides the merging strategy when an extension conflict
appears because of merging two source maps on method
mergeMapSection(int, int, java.lang.String) . |
Constructor and Description |
---|
SourceMapGeneratorV3() |
Modifier and Type | Method and Description |
---|---|
void |
addExtension(String name,
Object object)
Adds field extensions to the json source map.
|
void |
addMapping(String sourceName,
String symbolName,
FilePosition sourceStartPosition,
FilePosition startPosition,
FilePosition endPosition)
Adds a mapping for the given node.
|
void |
appendIndexMapTo(Appendable out,
String name,
List<SourceMapSection> sections)
Appends the index source map to the given buffer.
|
void |
appendTo(Appendable out,
String name)
Writes out the source map in the following format (line numbers are for
reference only and are not part of the format):
1.
|
Object |
getExtension(String name)
Returns the value mapped by the specified extension
or
null if this extension does not exist. |
boolean |
hasExtension(String name)
Check whether or not the sourcemap has an extension.
|
void |
mergeMapSection(int line,
int column,
String mapSectionContents)
Merges current mapping with
mapSectionContents considering the
offset (line, column) . |
void |
mergeMapSection(int line,
int column,
String mapSectionContents,
SourceMapGeneratorV3.ExtensionMergeAction mergeAction)
Works like
mergeMapSection(int, int, String) , except that
extensions from the @{code mapSectionContents} are merged to the top level
source map. |
void |
removeExtension(String name)
Removes an extension by name if present.
|
void |
reset()
Resets the source map for reuse.
|
void |
setSourceRoot(String path)
A prefix to be added to the beginning of each sourceName passed to
addMapping(java.lang.String, java.lang.String, com.google.debugging.sourcemap.FilePosition, com.google.debugging.sourcemap.FilePosition, com.google.debugging.sourcemap.FilePosition) . |
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.
|
void |
validate(boolean validate)
Whether to perform additional validation on the source map.
|
public void reset()
reset
in interface SourceMapGenerator
public void validate(boolean validate)
SourceMapGenerator
validate
in interface SourceMapGenerator
validate
- Whether to perform (potentially costly) validation on the
generated source map.public void setWrapperPrefix(String prefix)
setWrapperPrefix
in interface SourceMapGenerator
prefix
- The prefix that is added before the generated source code.public void setStartingPosition(int offsetLine, int offsetIndex)
setStartingPosition
in interface SourceMapGenerator
offsetLine
- The index of the current line being printed.offsetIndex
- The column index of the current character being printed.public void addMapping(String sourceName, @Nullable String symbolName, FilePosition sourceStartPosition, FilePosition startPosition, FilePosition endPosition)
addMapping
in interface SourceMapGenerator
startPosition
- The position on the starting lineendPosition
- 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.public void mergeMapSection(int line, int column, String mapSectionContents) throws SourceMapParseException
mapSectionContents
considering the
offset (line, column)
. Any extension in the map section will be
ignored.line
- The line offsetcolumn
- The column offsetmapSectionContents
- The map section to be appendedSourceMapParseException
public void mergeMapSection(int line, int column, String mapSectionContents, SourceMapGeneratorV3.ExtensionMergeAction mergeAction) throws SourceMapParseException
mergeMapSection(int, int, String)
, except that
extensions from the @{code mapSectionContents} are merged to the top level
source map. For conflicts a mergeAction
is performed.line
- The line offsetcolumn
- The column offsetmapSectionContents
- The map section to be appendedmergeAction
- The merge action for conflicting extensionsSourceMapParseException
public void appendTo(Appendable out, String name) throws IOException
appendTo
in interface SourceMapGenerator
out
- The stream to which the map will be appended.name
- The name of the generated source file that this source map
represents.IOException
public void setSourceRoot(String path)
addMapping(java.lang.String, java.lang.String, com.google.debugging.sourcemap.FilePosition, com.google.debugging.sourcemap.FilePosition, com.google.debugging.sourcemap.FilePosition)
. Debuggers expect (prefix + sourceName) to be a URL
for loading the source code.path
- The URL prefix to save in the sourcemap file. (Not validated.)public void addExtension(String name, Object object) throws SourceMapParseException
SourceMapParseExtension
will be thrown.name
- The name of the extension with format organization_fieldobject
- The value of the extension as a valid json valueSourceMapParseException
- if extension name is malformedpublic void removeExtension(String name)
name
- The name of the extension with format organization_fieldpublic boolean hasExtension(String name)
name
- The name of the extension with format organization_fieldpublic Object getExtension(String name)
null
if this extension does not exist.name
- null
public void appendIndexMapTo(Appendable out, String name, List<SourceMapSection> sections) throws IOException
appendIndexMapTo
in interface SourceMapGenerator
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.IOException
Copyright © 2009-2015 Google. All Rights Reserved.