|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.google.javascript.jscomp.SourceFile
public class SourceFile
An abstract representation of a source file that provides access to language-neutral features. The source file can be loaded from various locations, such as from disk or from a preloaded string.
Nested Class Summary | |
---|---|
static class |
SourceFile.Builder
A builder interface for source files. |
static interface |
SourceFile.Generator
A JavaScript source code provider. |
Constructor Summary | |
---|---|
SourceFile(String fileName)
Construct a new abstract source file. |
Method Summary | |
---|---|
static SourceFile.Builder |
builder()
Create a new builder for source files. |
void |
clearCachedSource()
|
static SourceFile |
fromCode(String fileName,
String code)
|
static SourceFile |
fromCode(String fileName,
String originalPath,
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)
|
static SourceFile |
fromInputStream(String fileName,
String originalPath,
InputStream s)
|
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. |
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. |
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()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
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.Method Detail |
---|
public int getLineOffset(int lineno)
StaticSourceFile
getLineOffset
in interface StaticSourceFile
lineno
- the line of the input to get the absolute offset of.
public String getCode() throws IOException
IOException
public Reader getCodeReader() throws IOException
IOException
public String getOriginalPath()
public void setOriginalPath(String originalPath)
public void clearCachedSource()
public String getName()
getName
in interface StaticSourceFile
public boolean isExtern()
isExtern
in interface StaticSourceFile
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.public String toString()
toString
in class Object
public static SourceFile fromFile(String fileName, Charset c)
public static SourceFile fromFile(String fileName)
public static SourceFile fromFile(File file, Charset c)
public static SourceFile fromFile(File file)
public static SourceFile fromCode(String fileName, String code)
public static SourceFile fromCode(String fileName, String originalPath, String code)
public static SourceFile fromInputStream(String fileName, InputStream s) throws IOException
IOException
public static SourceFile fromInputStream(String fileName, String originalPath, InputStream s) throws IOException
IOException
public static SourceFile fromReader(String fileName, Reader r) throws IOException
IOException
public static SourceFile fromGenerator(String fileName, SourceFile.Generator generator)
public static SourceFile.Builder builder()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |