Package com.google.javascript.rhino
Class SimpleSourceFile
- java.lang.Object
-
- com.google.javascript.rhino.SimpleSourceFile
-
- All Implemented Interfaces:
StaticSourceFile,java.io.Serializable
public final class SimpleSourceFile extends java.lang.Object implements StaticSourceFile, java.io.Serializable
A simple implementation ofStaticSourceFilefor testing.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.google.javascript.rhino.StaticSourceFile
StaticSourceFile.SourceKind
-
-
Constructor Summary
Constructors Constructor Description SimpleSourceFile(java.lang.String name, StaticSourceFile.SourceKind kind)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetColumnOfOffset(int offset)Gets the 0-based column number of the given source offset.StaticSourceFile.SourceKindgetKind()The source kind.intgetLineOffset(int line)Returns the offset of the given line number relative to the file start.intgetLineOfOffset(int offset)Gets the 1-based line number of the given source offset.java.lang.StringgetName()The name of the file.java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.google.javascript.rhino.StaticSourceFile
isExtern, isStrong, isWeak
-
-
-
-
Constructor Detail
-
SimpleSourceFile
public SimpleSourceFile(java.lang.String name, StaticSourceFile.SourceKind kind)
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:StaticSourceFileThe name of the file. Must be unique across all files in the compilation.- Specified by:
getNamein interfaceStaticSourceFile
-
getKind
public StaticSourceFile.SourceKind getKind()
Description copied from interface:StaticSourceFileThe source kind.- Specified by:
getKindin interfaceStaticSourceFile
-
getColumnOfOffset
public int getColumnOfOffset(int offset)
Description copied from interface:StaticSourceFileGets the 0-based column number of the given source offset.- Specified by:
getColumnOfOffsetin interfaceStaticSourceFile- 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.
-
getLineOfOffset
public int getLineOfOffset(int offset)
Description copied from interface:StaticSourceFileGets the 1-based line number of the given source offset.- Specified by:
getLineOfOffsetin interfaceStaticSourceFile- 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.
-
getLineOffset
public int getLineOffset(int line)
Description copied from interface:StaticSourceFileReturns 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.- Specified by:
getLineOffsetin interfaceStaticSourceFile- Parameters:
line- the line of the input to get the absolute offset of.- Returns:
- the absolute offset of the start of the provided line.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-