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 
    A excerpt formatter is responsible of formatting source excerpts.
    static enum 
    Source excerpt variety.
  • Method Summary

    Modifier and Type
    Method
    Description
    getSourceLine(String sourceName, int lineNumber)
    Get the line indicated by the line number.
    @Nullable Region
    getSourceLines(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(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.
    @Nullable Region
    getSourceRegion(String sourceName, int lineNumber)
    Get a region around the indicated line number.
  • Method Details

    • getSourceLine

      String getSourceLine(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(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 file
      length - 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(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(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.