Class SourceFile.Builder

java.lang.Object
com.google.javascript.jscomp.SourceFile.Builder
Enclosing class:
SourceFile

public static final class SourceFile.Builder extends Object
A builder interface for source files.

Allows users to customize the Charset, and the original path of the source file (if it differs from the path on disk).

  • Method Details

    • withKind

      @CanIgnoreReturnValue public SourceFile.Builder withKind(StaticSourceFile.SourceKind kind)
      Set the source kind.
    • withCharset

      @CanIgnoreReturnValue public SourceFile.Builder withCharset(Charset charset)
      Set the charset to use when reading from an input stream or file.
    • withPath

      public SourceFile.Builder withPath(String path)
    • withPath

      public SourceFile.Builder withPath(Path path)
    • withContent

      @CanIgnoreReturnValue public SourceFile.Builder withContent(String x)
    • withContent

      @CanIgnoreReturnValue public SourceFile.Builder withContent(InputStream x)
    • withZipEntryPath

      @CanIgnoreReturnValue public SourceFile.Builder withZipEntryPath(String zipPath, String entryPath)
    • withOriginalPath

      @CanIgnoreReturnValue public SourceFile.Builder withOriginalPath(String originalPath)
      Sets a name for this source file that does not need to correspond to a path on disk.

      Allow passing a reasonable human-readable name in cases like for zip files and for generated files with unstable artifact prefixes.

      The name must still be unique.

    • setIsStubSourceFileForAlreadyProvidedInput

      @CanIgnoreReturnValue public SourceFile.Builder setIsStubSourceFileForAlreadyProvidedInput()
      Sets that this SourceFile is a stub file for an input that was already provided to the compiler in the form of TypedAST.
    • build

      public SourceFile build()