public final class Snapshot extends Object
Source
representing file or document, or from some other Snapshot.
So Snapshot can represent some block of code written
in different language embedded inside some top level language too. It can contain
some generated parts of code that is not contained in the original
file. Snapshot is immutable. It means that Snapshot created
from document opened in editor contains some copy of original text.
You do not need to call Snapshot methods under
any locks, but on other hand Snapshot may not be up to date.Modifier and Type | Method and Description |
---|---|
Embedding |
create(CharSequence charSequence,
String mimeType)
Creates a new embedding for given charSequence.
|
Embedding |
create(int offset,
int length,
String mimeType)
Creates a new embedding form part of this snapshot defined by offset and length.
|
int |
getEmbeddedOffset(int originalOffset)
Gets an offset in this snapshot corresponding to an offset
in the original source.
|
MimePath |
getMimePath()
Returns this snapshot's mime path.
|
String |
getMimeType()
Returns this snapshot's mime type.
|
int |
getOriginalOffset(int snapshotOffset)
Gets an offset in the original source corresponding to an offset in this snapshot.
|
Source |
getSource()
Returns source this snapshot has originally been created from.
|
CharSequence |
getText()
Returns content of this snapshot.
|
TokenHierarchy<?> |
getTokenHierarchy()
Get the
TokenHierarchy lexed from this snapshot. |
String |
toString() |
public Embedding create(int offset, int length, String mimeType)
offset
- A start offset of the new embedding. Start offset
is relative to the current snapshot.length
- A length of the new embedding.mimeType
- Mime type of the new embedding.IndexOutOfBoundsException
- when bounds of the new embedding exceeds
original snapshot.public Embedding create(CharSequence charSequence, String mimeType)
charSequence
- A text of new embedding.mimeType
- Mime type of the new embedding.public CharSequence getText()
public String getMimeType()
public MimePath getMimePath()
public TokenHierarchy<?> getTokenHierarchy()
TokenHierarchy
lexed from this snapshot.TokenHierarchy
created by a Lexer
registered
for this Snapshot
's mime type or null
if there is
no such Lexer
.public int getOriginalOffset(int snapshotOffset)
-1
if snapshotOffset
can't
be translated back to the original source. For example on the snapshotOffset
is in a "virtual" area of text. That is in a text generated by some EmbeddingProvider
,
which has no representation in the top level source code.snapshotOffset
- The offset in this snapshot.-1
.public int getEmbeddedOffset(int originalOffset)
-1
if originalOffset
points to an area in the original source, which is not part of this snapshot.originalOffset
- The offset in the original source.-1
.public Source getSource()