public class SourceFile extends java.lang.Object implements StaticSourceFile, java.io.Serializable
Modifier and Type | Class and Description |
---|---|
static class |
SourceFile.Builder
A builder interface for source files.
|
static interface |
SourceFile.Generator
A JavaScript source code provider.
|
StaticSourceFile.SourceKind
Constructor and Description |
---|
SourceFile(java.lang.String fileName,
StaticSourceFile.SourceKind kind)
Construct a new abstract source file.
|
Modifier and Type | Method and Description |
---|---|
static SourceFile.Builder |
builder()
Create a new builder for source files.
|
void |
clearCachedSource() |
static SourceFile |
fromCode(java.lang.String fileName,
java.lang.String code) |
static SourceFile |
fromCode(java.lang.String fileName,
java.lang.String code,
StaticSourceFile.SourceKind kind) |
static SourceFile |
fromFile(java.lang.String fileName) |
static SourceFile |
fromFile(java.lang.String fileName,
java.nio.charset.Charset charset) |
static SourceFile |
fromFile(java.lang.String fileName,
java.nio.charset.Charset charset,
StaticSourceFile.SourceKind kind) |
static SourceFile |
fromGenerator(java.lang.String fileName,
SourceFile.Generator generator) |
static SourceFile |
fromInputStream(java.lang.String fileName,
java.io.InputStream s)
Deprecated.
|
static SourceFile |
fromInputStream(java.lang.String fileName,
java.io.InputStream s,
java.nio.charset.Charset charset) |
static SourceFile |
fromPath(java.nio.file.Path path,
java.nio.charset.Charset charset) |
static SourceFile |
fromPath(java.nio.file.Path path,
java.nio.charset.Charset charset,
StaticSourceFile.SourceKind kind) |
static SourceFile |
fromReader(java.lang.String fileName,
java.io.Reader r) |
static SourceFile |
fromZipEntry(java.lang.String originalZipPath,
java.lang.String absoluteZipPath,
java.lang.String entryPath,
java.nio.charset.Charset inputCharset) |
static SourceFile |
fromZipEntry(java.lang.String originalZipPath,
java.lang.String absoluteZipPath,
java.lang.String entryPath,
java.nio.charset.Charset inputCharset,
StaticSourceFile.SourceKind kind) |
static java.util.List<SourceFile> |
fromZipFile(java.lang.String zipName,
java.nio.charset.Charset inputCharset) |
static java.util.List<SourceFile> |
fromZipInput(java.lang.String zipName,
java.io.InputStream input,
java.nio.charset.Charset inputCharset) |
java.lang.String |
getCode()
Gets all the code in this source file.
|
java.io.Reader |
getCodeReader()
Gets a reader for the code in this source file.
|
int |
getColumnOfOffset(int offset)
Gets the 0-based column number of the given source offset.
|
StaticSourceFile.SourceKind |
getKind()
Returns the source kind.
|
java.lang.String |
getLine(int lineNumber)
Gets the source line for the indicated line number.
|
int |
getLineOffset(int lineno)
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.
|
java.lang.String |
getName()
Returns a unique name for the source file.
|
java.lang.String |
getOriginalPath() |
Region |
getRegion(int lineNumber)
Get a region around the indicated line number.
|
void |
restoreFrom(SourceFile sourceFile) |
void |
setKind(StaticSourceFile.SourceKind kind)
Sets the source kind.
|
void |
setOriginalPath(java.lang.String originalPath) |
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
isExtern, isStrong, isWeak
public SourceFile(java.lang.String fileName, StaticSourceFile.SourceKind kind)
fileName
- The file name of the source file. It does not necessarily need to correspond to
a real path. But it should be unique. Will appear in warning messages emitted by the
compiler.kind
- The source kind.public int getLineOffset(int lineno)
StaticSourceFile
getLineOffset
in interface StaticSourceFile
lineno
- the line of the input to get the absolute offset of.public java.lang.String getCode() throws java.io.IOException
java.io.IOException
@GwtIncompatible(value="java.io.Reader") public java.io.Reader getCodeReader() throws java.io.IOException
java.io.IOException
public java.lang.String getOriginalPath()
public void setOriginalPath(java.lang.String originalPath)
public void clearCachedSource()
public java.lang.String getName()
getName
in interface StaticSourceFile
public StaticSourceFile.SourceKind getKind()
getKind
in interface StaticSourceFile
public void setKind(StaticSourceFile.SourceKind kind)
public int getLineOfOffset(int offset)
StaticSourceFile
getLineOfOffset
in interface StaticSourceFile
offset
- An absolute file offset.public int getColumnOfOffset(int offset)
StaticSourceFile
getColumnOfOffset
in interface StaticSourceFile
offset
- An absolute file offset.public java.lang.String getLine(int lineNumber)
lineNumber
- the line number, 1 being the first line of the file.null
if it does not exist,
or if there was an IO exception.public Region getRegion(int lineNumber)
lineNumber
- the line number, 1 being the first line of the file.null
if it does not exist,
or if there was an IO exception.public java.lang.String toString()
toString
in class java.lang.Object
@GwtIncompatible(value="fromZipInput") public static java.util.List<SourceFile> fromZipFile(java.lang.String zipName, java.nio.charset.Charset inputCharset) throws java.io.IOException
java.io.IOException
@GwtIncompatible(value="java.util.zip.ZipInputStream") public static java.util.List<SourceFile> fromZipInput(java.lang.String zipName, java.io.InputStream input, java.nio.charset.Charset inputCharset) throws java.io.IOException
java.io.IOException
@GwtIncompatible(value="java.io.File") public static SourceFile fromZipEntry(java.lang.String originalZipPath, java.lang.String absoluteZipPath, java.lang.String entryPath, java.nio.charset.Charset inputCharset) throws java.net.MalformedURLException
java.net.MalformedURLException
@GwtIncompatible(value="java.io.File") public static SourceFile fromZipEntry(java.lang.String originalZipPath, java.lang.String absoluteZipPath, java.lang.String entryPath, java.nio.charset.Charset inputCharset, StaticSourceFile.SourceKind kind) throws java.net.MalformedURLException
java.net.MalformedURLException
@GwtIncompatible(value="java.io.File") public static SourceFile fromFile(java.lang.String fileName, java.nio.charset.Charset charset, StaticSourceFile.SourceKind kind)
@GwtIncompatible(value="java.io.File") public static SourceFile fromFile(java.lang.String fileName, java.nio.charset.Charset charset)
@GwtIncompatible(value="java.io.File") public static SourceFile fromFile(java.lang.String fileName)
@GwtIncompatible(value="java.io.File") public static SourceFile fromPath(java.nio.file.Path path, java.nio.charset.Charset charset, StaticSourceFile.SourceKind kind)
@GwtIncompatible(value="java.io.File") public static SourceFile fromPath(java.nio.file.Path path, java.nio.charset.Charset charset)
public static SourceFile fromCode(java.lang.String fileName, java.lang.String code, StaticSourceFile.SourceKind kind)
public static SourceFile fromCode(java.lang.String fileName, java.lang.String code)
@Deprecated @GwtIncompatible(value="java.io.InputStream") public static SourceFile fromInputStream(java.lang.String fileName, java.io.InputStream s) throws java.io.IOException
fromInputStream(String, InputStream, Charset)
java.io.IOException
@GwtIncompatible(value="java.io.InputStream") public static SourceFile fromInputStream(java.lang.String fileName, java.io.InputStream s, java.nio.charset.Charset charset) throws java.io.IOException
java.io.IOException
@GwtIncompatible(value="java.io.Reader") public static SourceFile fromReader(java.lang.String fileName, java.io.Reader r) throws java.io.IOException
java.io.IOException
public static SourceFile fromGenerator(java.lang.String fileName, SourceFile.Generator generator)
public static SourceFile.Builder builder()
public void restoreFrom(SourceFile sourceFile)
Copyright © 2009-2019 Google. All Rights Reserved.