Interface StaticSourceFile

All Known Implementing Classes:
SimpleSourceFile, SourceFile

public interface StaticSourceFile
The StaticSourceFile contains information about a compiler input.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Source kinds.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    getColumnOfOffset(int offset)
    Gets the 0-based column number of the given source offset.
    The source kind.
    int
    getLineOffset(int lineNumber)
    Returns the offset of the given line number relative to the file start.
    int
    getLineOfOffset(int offset)
    Gets the 1-based line number of the given source offset.
    The name of the file.
    boolean
    Whether this source file contains code that should be optimized using a minimal set of known-safe optimizations.
    default boolean
    Whether the source kind is EXTERN.
    default boolean
    Whether the source kind is NON_CODE.
    default boolean
    Whether the source kind is STRONG.
    default boolean
     
    default boolean
    Whether the source kind is WEAK.
  • Method Details

    • getName

      String getName()
      The name of the file. Must be unique across all files in the compilation.
    • getKind

      The source kind.
    • isStrong

      default boolean isStrong()
      Whether the source kind is STRONG.
    • isWeak

      default boolean isWeak()
      Whether the source kind is WEAK.
    • isExtern

      default boolean isExtern()
      Whether the source kind is EXTERN.
    • isNonCode

      default boolean isNonCode()
      Whether the source kind is NON_CODE.
    • isTypeScriptSource

      default boolean isTypeScriptSource()
    • isClosureUnawareCode

      boolean isClosureUnawareCode()
      Whether this source file contains code that should be optimized using a minimal set of known-safe optimizations. In particular, code in this StaticSourceFile is unlikely to be well-typed (or have types annotated at all), and is likely written by someone unaware of the limitations of this compiler.
    • getLineOffset

      int getLineOffset(int lineNumber)
      Returns the offset of the given line number relative to the file start. Line number should be 1-based.

      If the source file doesn't have line information, it should return Integer.MIN_VALUE. The negative offsets will make it more obvious what happened.

      Parameters:
      lineNumber - the line of the input to get the absolute offset of.
      Returns:
      the absolute offset of the start of the provided line.
      Throws:
      IllegalArgumentException - if lineno is less than 1 or greater than the number of lines in the source.
    • getLineOfOffset

      int getLineOfOffset(int offset)
      Gets the 1-based line number of the given source offset.
      Parameters:
      offset - An absolute file offset.
      Returns:
      The 1-based line number of that offset. The behavior is undefined if this offset does not exist in the source file.
    • getColumnOfOffset

      int getColumnOfOffset(int offset)
      Gets the 0-based column number of the given source offset.
      Parameters:
      offset - An absolute file offset.
      Returns:
      The 0-based column number of that offset. The behavior is undefined if this offset does not exist in the source file.