Package com.google.javascript.jscomp
Interface SourceExcerptProvider
-
- All Known Implementing Classes:
AbstractCompiler
,Compiler
public interface SourceExcerptProvider
A source excerpt provider is responsible for building source code excerpt of specific locations, such as a specific line or a region around a given line number.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
SourceExcerptProvider.ExcerptFormatter
A excerpt formatter is responsible of formatting source excerpts.static class
SourceExcerptProvider.SourceExcerpt
Source excerpt variety.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description java.lang.String
getSourceLine(java.lang.String sourceName, int lineNumber)
Get the line indicated by the line number.Region
getSourceLines(java.lang.String sourceName, int lineNumber, int length)
Gets the specific lines returned by the beginning and excerpt length.com.google.debugging.sourcemap.proto.Mapping.OriginalMapping
getSourceMapping(java.lang.String sourceName, int lineNumber, int columnNumber)
If the source file is associated with an inputSourceMap, does a lookup for the original file position based on this source map.Region
getSourceRegion(java.lang.String sourceName, int lineNumber)
Get a region around the indicated line number.
-
-
-
Method Detail
-
getSourceLine
java.lang.String getSourceLine(java.lang.String sourceName, int lineNumber)
Get the line indicated by the line number. This call will return only the specific line.- Parameters:
lineNumber
- the line number, 1 being the first line of the file- Returns:
- the line indicated, or
null
if it does not exist
-
getSourceLines
@Nullable Region getSourceLines(java.lang.String sourceName, int lineNumber, int length)
Gets the specific lines returned by the beginning and excerpt length. Must not start or end with a carriage return. Implementations may decide to truncate lines but will always include the first line and never be longer than the specified length.- Parameters:
lineNumber
- the line number, 1 being the first line of the filelength
- the desired length of the excerpt (in chars). If -1, returns just a single line. Otherwise, returns as many lines as needed. (including the remainder of the last line)- Returns:
- the region around the line number indicated, or
null
if it does not exist
-
getSourceRegion
@Nullable Region getSourceRegion(java.lang.String sourceName, int lineNumber)
Get a region around the indicated line number. The exact definition of a region is implementation specific, but it must contain the line indicated by the line number. A region must not start or end by a carriage return.- Parameters:
lineNumber
- the line number, 1 being the first line of the file- Returns:
- the region around the line number indicated, or
null
if it does not exist
-
getSourceMapping
com.google.debugging.sourcemap.proto.Mapping.OriginalMapping getSourceMapping(java.lang.String sourceName, int lineNumber, int columnNumber)
If the source file is associated with an inputSourceMap, does a lookup for the original file position based on this source map.
-
-