public class SourceFile extends Object implements StaticSourceFile, 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.
|
| Constructor and Description |
|---|
SourceFile(String fileName)
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(String fileName,
String code) |
static SourceFile |
fromFile(File file) |
static SourceFile |
fromFile(File file,
Charset c) |
static SourceFile |
fromFile(String fileName) |
static SourceFile |
fromFile(String fileName,
Charset c) |
static SourceFile |
fromGenerator(String fileName,
SourceFile.Generator generator) |
static SourceFile |
fromInputStream(String fileName,
InputStream s)
Deprecated.
|
static SourceFile |
fromInputStream(String fileName,
InputStream s,
Charset charset) |
static SourceFile |
fromReader(String fileName,
Reader r) |
String |
getCode()
Gets all the code in this source file.
|
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.
|
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.
|
String |
getName()
Returns a unique name for the source file.
|
String |
getOriginalPath() |
Region |
getRegion(int lineNumber)
Get a region around the indicated line number.
|
boolean |
isExtern()
Returns whether this is an extern.
|
void |
setOriginalPath(String originalPath) |
String |
toString() |
public SourceFile(String fileName)
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.public int getLineOffset(int lineno)
StaticSourceFilegetLineOffset in interface StaticSourceFilelineno - the line of the input to get the absolute offset of.public String getCode() throws IOException
IOException@GwtIncompatible(value="java.io.Reader") public Reader getCodeReader() throws IOException
IOExceptionpublic String getOriginalPath()
public void setOriginalPath(String originalPath)
public void clearCachedSource()
public String getName()
getName in interface StaticSourceFilepublic boolean isExtern()
isExtern in interface StaticSourceFilepublic int getLineOfOffset(int offset)
StaticSourceFilegetLineOfOffset in interface StaticSourceFileoffset - An absolute file offset.public int getColumnOfOffset(int offset)
StaticSourceFilegetColumnOfOffset in interface StaticSourceFileoffset - An absolute file offset.public 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.@GwtIncompatible(value="java.io.File") public static SourceFile fromFile(String fileName, Charset c)
public static SourceFile fromFile(String fileName)
@GwtIncompatible(value="java.io.File") public static SourceFile fromFile(File file, Charset c)
@GwtIncompatible(value="java.io.File") public static SourceFile fromFile(File file)
public static SourceFile fromCode(String fileName, String code)
@Deprecated @GwtIncompatible(value="java.io.InputStream") public static SourceFile fromInputStream(String fileName, InputStream s) throws IOException
fromInputStream(String, InputStream, Charset)IOException@GwtIncompatible(value="java.io.InputStream") public static SourceFile fromInputStream(String fileName, InputStream s, Charset charset) throws IOException
IOException@GwtIncompatible(value="java.io.Reader") public static SourceFile fromReader(String fileName, Reader r) throws IOException
IOExceptionpublic static SourceFile fromGenerator(String fileName, SourceFile.Generator generator)
public static SourceFile.Builder builder()
Copyright © 2009-2015 Google. All Rights Reserved.