ITextSnapshotReader Interface
Provides the base requirements for an object that reads through characters and tokens from an ITextSnapshot.
public interface ITextSnapshotReader
Properties
BufferReader
Gets the ITextBufferReader that is wrapped by this reader and can be used for performing fast low-level text scanning on the snapshot.
ITextBufferReader BufferReader { get; }
Property Value
- ITextBufferReader:
The ITextBufferReader that can be used for performing fast low-level text scanning on the snapshot.
Character
Gets the character at the Offset.
char Character { get; }
Property Value
- System.Char:
The character at the Offset.
Remarks
This value is the same as the return value of the PeekCharacter() method.
IsAtSnapshotEnd
Gets whether the current Offset is at the end of the snapshot.
bool IsAtSnapshotEnd { get; }
Property Value
- System.Boolean:
true
if the current Offset is at the end of the snapshot; otherwise,false
.
IsAtSnapshotLineEnd
Gets whether the current Offset is at the end of an ITextSnapshotLine.
bool IsAtSnapshotLineEnd { get; }
Property Value
- System.Boolean:
true
if the current Offset is at the end of an ITextSnapshotLine; otherwise,false
.
IsAtSnapshotLineStart
Gets whether the current Offset is at the start of an ITextSnapshotLine.
bool IsAtSnapshotLineStart { get; }
Property Value
- System.Boolean:
true
if the current Offset is at the start of an ITextSnapshotLine; otherwise,false
.
IsAtSnapshotStart
Gets whether the current Offset is at the start of the snapshot.
bool IsAtSnapshotStart { get; }
Property Value
- System.Boolean:
true
if the current Offset is at the start of the snapshot; otherwise,false
.
IsAtTokenStart
bool IsAtTokenStart { get; }
Property Value
IsCharacterLineTerminator
Gets whether the Character is a newline character.
bool IsCharacterLineTerminator { get; }
Property Value
- System.Boolean:
true
if the Character is a newline character; otherwise,false
.
IsCharacterWhitespace
Gets whether the Character is categorized as a whitespace character.
bool IsCharacterWhitespace { get; }
Property Value
- System.Boolean:
true
if the Character is categorized as a whitespace character; otherwise,false
.
Language
Gets the ISyntaxLanguage that contains the current offset within the snapshot.
ISyntaxLanguage Language { get; }
Property Value
- ISyntaxLanguage:
The ISyntaxLanguage that contains the current offset within the snapshot.
Length
Gets the length of the snapshot.
int Length { get; }
Property Value
- System.Int32:
The length of the snapshot.
Offset
Gets or sets the current offset within the snapshot.
int Offset { get; set; }
Property Value
- System.Int32:
The current offset within the snapshot.
Options
Gets the ITextSnapshotReaderOptions that contains optimization options for the reader.
ITextSnapshotReaderOptions Options { get; }
Property Value
- ITextSnapshotReaderOptions:
The ITextSnapshotReaderOptions that contains optimization options for the reader.
Remarks
Configure the options before accessing any members on this reader instance.
Position
Gets the current TextPosition within the snapshot.
TextPosition Position { get; }
Property Value
- TextPosition:
The current TextPosition within the snapshot.
Snapshot
Gets the core ITextSnapshot that is examined by this reader.
ITextSnapshot Snapshot { get; }
Property Value
- ITextSnapshot:
The core ITextSnapshot that is examined by this reader.
SnapshotLine
Gets the ITextSnapshotLine that contains the Offset.
ITextSnapshotLine SnapshotLine { get; }
Property Value
- ITextSnapshotLine:
The ITextSnapshotLine that contains the Offset.
Token
IToken Token { get; }
Property Value
Remarks
This value is the same as the return value of the PeekToken() method.
TokenText
Gets the snapshot text contained by the Token.
Methods
GoToCurrentSnapshotLineEnd()
void GoToCurrentSnapshotLineEnd()
GoToCurrentSnapshotLineStart()
void GoToCurrentSnapshotLineStart()
GoToCurrentTokenStart()
void GoToCurrentTokenStart()
GoToCurrentWordEnd()
Moves to the current word's end offset.
bool GoToCurrentWordEnd()
Returns
- System.Boolean:
true
if the word end is found; otherwise,false
.
Remarks
If a proper word end is not found, the reader's Offset will be the end of the snapshot.
GoToCurrentWordStart()
Moves to the current word's start offset.
bool GoToCurrentWordStart()
Returns
- System.Boolean:
true
if the word start is found; otherwise,false
.
Remarks
If a proper word start is not found, the reader's Offset will be the beginning of the snapshot.
GoToNextMatchingTokenById(Int32, Int32)
Moves the Offset to the next matching token where there can be nested token pairs.
bool GoToNextMatchingTokenById(int startTokenId, int endTokenId)
Parameter | Type | Description |
---|---|---|
startTokenId | System.Int32 | The ID of the start IToken. |
endTokenId | System.Int32 | The ID of the related end IToken for which to search. |
Returns
- System.Boolean:
true
if the next matching token is found; otherwise,false
.
Remarks
This method is useful for bracket matching.
GoToNextSnapshotLineStart()
Moves the Offset to the start of the snapshot line after the snapshot line that contains the Offset.
void GoToNextSnapshotLineStart()
GoToNextToken()
Moves to the next token's start offset.
bool GoToNextToken()
Returns
- System.Boolean:
true
if the token is found; otherwise,false
.
Remarks
If a token is not found, the stream's Offset will be the end of the snapshot.
GoToNextToken(Int32)
Moves backward the specified number of tokens.
bool GoToNextToken(int count)
Parameter | Type | Description |
---|---|---|
count | System.Int32 | The number of tokens to move. |
Returns
- System.Boolean:
true
if a token is found; otherwise,false
.
Remarks
If a token is not found, the stream's Offset will be the end of the snapshot.
GoToNextToken(Predicate<IToken>)
Continues forward token scanning until the specified predicate returns true
, at which time the reader points to the token's start offset.
bool GoToNextToken(Predicate<IToken> predicate)
Parameter | Type | Description |
---|---|---|
predicate | System.Predicate<IToken> | The predicate to use. Return |
Returns
- System.Boolean:
true
if the token is found; otherwise,false
.
Remarks
If a token is not found, the stream's Offset will be the end of the snapshot.
GoToNextTokenWithId(Int32)
Moves to the next token's start offset whose token ID matches the specified ID.
bool GoToNextTokenWithId(int id)
Parameter | Type | Description |
---|---|---|
id | System.Int32 | The token ID to look for. |
Returns
- System.Boolean:
true
if the token is found; otherwise,false
.
Remarks
If a token is not found, the stream's Offset will be the end of the snapshot.
GoToNextTokenWithId(Int32[])
Moves to the next token's start offset whose token ID matches any of the specified IDs.
bool GoToNextTokenWithId(params int[] ids)
Parameter | Type | Description |
---|---|---|
ids | System.Int32[] | An array of token IDs to look for. |
Returns
- System.Boolean:
true
if the token is found; otherwise,false
.
Remarks
If a token is not found, the stream's Offset will be the end of the snapshot.
GoToNextTokenWithKey(String)
Moves to the next token's start offset whose token key matches the specified key.
bool GoToNextTokenWithKey(string key)
Parameter | Type | Description |
---|---|---|
key | System.String | The token key to look for. |
Returns
- System.Boolean:
true
if the token is found; otherwise,false
.
Remarks
If a token is not found, the stream's Offset will be the end of the snapshot.
GoToNextTokenWithKey(String[])
Moves to the next token's start offset whose token key matches any of the specified keys.
bool GoToNextTokenWithKey(params string[] keys)
Parameter | Type | Description |
---|---|---|
keys | System.String[] | An array of token keys to look for. |
Returns
- System.Boolean:
true
if the token is found; otherwise,false
.
Remarks
If a token is not found, the stream's Offset will be the end of the snapshot.
GoToNextWordStart()
Moves to the next word's start offset.
bool GoToNextWordStart()
Returns
- System.Boolean:
true
if the word start is found; otherwise,false
.
Remarks
If a proper word start is not found, the reader's Offset will be the end of the snapshot.
GoToPreviousMatchingTokenById(Int32, Int32)
Moves the Offset to the previous matching token where there can be nested token pairs.
bool GoToPreviousMatchingTokenById(int endTokenId, int startTokenId)
Parameter | Type | Description |
---|---|---|
endTokenId | System.Int32 | The ID of the end IToken. |
startTokenId | System.Int32 | The ID of the related start IToken for which to search. |
Returns
- System.Boolean:
true
if the previous matching token is found; otherwise,false
.
Remarks
This method is useful for bracket matching.
GoToPreviousSnapshotLineEnd()
void GoToPreviousSnapshotLineEnd()
GoToPreviousToken()
Moves to the previous token's start offset.
bool GoToPreviousToken()
Returns
- System.Boolean:
true
if the token is found; otherwise,false
.
Remarks
If a token is not found, the stream's Offset will be the beginning of the snapshot.
GoToPreviousToken(Int32)
Moves backward the specified number of tokens.
bool GoToPreviousToken(int count)
Parameter | Type | Description |
---|---|---|
count | System.Int32 | The number of tokens to move. |
Returns
- System.Boolean:
true
if a token is found; otherwise,false
.
Remarks
If a token is not found, the stream's Offset will be the beginning of the snapshot.
GoToPreviousToken(Predicate<IToken>)
Continues backward token scanning until the specified predicate returns true
, at which time the reader points to the token's start offset.
bool GoToPreviousToken(Predicate<IToken> predicate)
Parameter | Type | Description |
---|---|---|
predicate | System.Predicate<IToken> | The predicate to use. Return |
Returns
- System.Boolean:
true
if the token is found; otherwise,false
.
Remarks
If a token is not found, the stream's Offset will be the end of the snapshot.
GoToPreviousTokenWithId(Int32)
Moves to the previous token's start offset whose token ID matches the specified ID.
bool GoToPreviousTokenWithId(int id)
Parameter | Type | Description |
---|---|---|
id | System.Int32 | The token ID to look for. |
Returns
- System.Boolean:
true
if the token is found; otherwise,false
.
Remarks
If a token is not found, the stream's Offset will be the beginning of the snapshot.
GoToPreviousTokenWithId(Int32[])
Moves to the previous token's start offset whose token ID matches any of the specified IDs.
bool GoToPreviousTokenWithId(params int[] ids)
Parameter | Type | Description |
---|---|---|
ids | System.Int32[] | An array of token IDs to look for. |
Returns
- System.Boolean:
true
if the token is found; otherwise,false
.
Remarks
If a token is not found, the stream's Offset will be the beginning of the snapshot.
GoToPreviousTokenWithKey(String)
Moves to the previous token's start offset whose token key matches the specified key.
bool GoToPreviousTokenWithKey(string key)
Parameter | Type | Description |
---|---|---|
key | System.String | The token key to look for. |
Returns
- System.Boolean:
true
if the token is found; otherwise,false
.
Remarks
If a token is not found, the stream's Offset will be the beginning of the snapshot.
GoToPreviousTokenWithKey(String[])
Moves to the previous token's start offset whose token key matches any of the specified keys.
bool GoToPreviousTokenWithKey(params string[] keys)
Parameter | Type | Description |
---|---|---|
keys | System.String[] | An array of token keys to look for. |
Returns
- System.Boolean:
true
if the token is found; otherwise,false
.
Remarks
If a token is not found, the stream's Offset will be the beginning of the snapshot.
GoToPreviousWordStart()
Moves to the previous word's start character.
bool GoToPreviousWordStart()
Returns
- System.Boolean:
true
if the word start is found; otherwise,false
.
Remarks
If a proper word start is not found, the reader's Offset will be the beginning of the snapshot.
GoToSnapshotEnd()
void GoToSnapshotEnd()
GoToSnapshotStart()
void GoToSnapshotStart()
PeekCharacter()
Peeks at a single character without seeking past it.
char PeekCharacter()
Returns
- System.Char:
The character that was read.
PeekCharacterReverse()
Reverse peeks at a single character without seeking past it.
char PeekCharacterReverse()
Returns
- System.Char:
The character that was read.
PeekText(Int32)
Peeks at a string without seeking past it.
string PeekText(int maxCharCount)
Parameter | Type | Description |
---|---|---|
maxCharCount | System.Int32 | The maximum number of characters to read, if the end of the snapshot is not reached beforehand. |
Returns
- System.String:
The string that was read.
PeekTextReverse(Int32)
Reverse peeks at a string without seeking past it.
string PeekTextReverse(int maxCharCount)
Parameter | Type | Description |
---|---|---|
maxCharCount | System.Int32 | The maximum number of characters to read, if the start of the snapshot is not reached beforehand. |
Returns
- System.String:
The string that was read.
PeekToken()
Peeks at a single IToken from the snapshot without seeking past it.
PeekTokenReverse()
Reverse peeks at a single IToken from the snapshot without seeking past it.
ReadCharacter()
Reads a single character and seeks forward one offset.
char ReadCharacter()
Returns
- System.Char:
The character that was read.
ReadCharacterReverse()
Reverse reads a single character and seeks backward one offset.
char ReadCharacterReverse()
Returns
- System.Char:
The character that was read.
ReadCharacterReverseThrough(Char)
Reverse reads characters from the snapshot until the specified character is read through.
bool ReadCharacterReverseThrough(char ch)
Parameter | Type | Description |
---|---|---|
ch | System.Char | The desired character. |
Returns
- System.Boolean:
true
if the desired character was read; otherwise,false
if the start of the snapshot was reached.
ReadCharacterReverseThrough(Char, Int32)
Reverse reads characters from the snapshot until the specified character is read through, or the specified offset is reached.
bool ReadCharacterReverseThrough(char ch, int minOffset)
Parameter | Type | Description |
---|---|---|
ch | System.Char | The desired character. |
minOffset | System.Int32 | The minimum offset to check. |
Returns
- System.Boolean:
true
if the desired character was read; otherwise,false
if the specified offset was reached.
ReadCharacterThrough(Char)
Reads characters from the snapshot until the specified character is read through.
bool ReadCharacterThrough(char ch)
Parameter | Type | Description |
---|---|---|
ch | System.Char | The desired character. |
Returns
- System.Boolean:
true
if the desired character was read; otherwise,false
if the end of the snapshot was reached.
ReadCharacterThrough(Char, Int32)
Reads characters from the snapshot until the specified character is read through, or the specified offset is reached.
bool ReadCharacterThrough(char ch, int maxOffset)
Parameter | Type | Description |
---|---|---|
ch | System.Char | The desired character. |
maxOffset | System.Int32 | The maximum offset to check. |
Returns
- System.Boolean:
true
if the desired character was read; otherwise,false
if the specified offset was reached.
ReadText(Int32)
Reads a string and seeks forward to the end of it.
string ReadText(int maxCharCount)
Parameter | Type | Description |
---|---|---|
maxCharCount | System.Int32 | The maximum number of characters to read, if the end of the snapshot is not reached beforehand. |
Returns
- System.String:
The string that was read.
ReadTextReverse(Int32)
Reverse reads a string and seeks backward to the start of it.
string ReadTextReverse(int maxCharCount)
Parameter | Type | Description |
---|---|---|
maxCharCount | System.Int32 | The maximum number of characters to read, if the start of the snapshot is not reached beforehand. |
Returns
- System.String:
The string that was read.
ReadToken()
ReadTokenReverse()
SeekCharacter(Int32)
Moves the Offset by the specified amount.
void SeekCharacter(int delta)
Parameter | Type | Description |
---|---|---|
delta | System.Int32 | The amount of characters to move. This value may be negative. |