Package com.google.javascript.rhino
Class SimpleSourceFile
java.lang.Object
com.google.javascript.rhino.SimpleSourceFile
- All Implemented Interfaces:
StaticSourceFile
,Serializable
A simple implementation of
StaticSourceFile
for testing.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.google.javascript.rhino.StaticSourceFile
StaticSourceFile.SourceKind
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
getColumnOfOffset
(int offset) Gets the 0-based column number of the given source offset.getKind()
The source kind.int
getLineOffset
(int line) 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.getName()
The name of the file.boolean
Whether this source file contains code that should be optimized using a minimal set of known-safe optimizations.toString()
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, isNonCode, isStrong, isTypeScriptSource, isWeak
-
Constructor Details
-
SimpleSourceFile
-
-
Method Details
-
getName
Description copied from interface:StaticSourceFile
The name of the file. Must be unique across all files in the compilation.- Specified by:
getName
in interfaceStaticSourceFile
-
getKind
Description copied from interface:StaticSourceFile
The source kind.- Specified by:
getKind
in interfaceStaticSourceFile
-
isClosureUnawareCode
public boolean isClosureUnawareCode()Description copied from interface:StaticSourceFile
Whether this source file contains code that should be optimized using a minimal set of known-safe optimizations. In particular, code in this StaticSourceFile is unlikely to be well-typed (or have types annotated at all), and is likely written by someone unaware of the limitations of this compiler.- Specified by:
isClosureUnawareCode
in interfaceStaticSourceFile
-
getColumnOfOffset
public int getColumnOfOffset(int offset) Description copied from interface:StaticSourceFile
Gets the 0-based column number of the given source offset.- Specified by:
getColumnOfOffset
in 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:StaticSourceFile
Gets the 1-based line number of the given source offset.- Specified by:
getLineOfOffset
in 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:StaticSourceFile
Returns 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:
getLineOffset
in 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
-