Version

TextDocumentSnapshotScanner Overview

Topic Overview

Purpose

This topic provides an overview of the TextDocumentSnapshotScanner object’s properties and methods.

Introduction

TextDocumentSnapshotScanner summary

Created via the snapshot’s CreateScanner method the TextDocumentSnapshotScanner class targets a specific instance of a TextDocumentSnaphot and is useful for efficiently scanning through the snapshot’s lines, tokens and words.

Note
Note:

even though the snapshot that it targets is thread safe, the scanner is not. Therefore, create the scanner on the same thread using it (namely, each thread accessing a scanner should create its own). Trying to access the properties and methods of a scanner created on another thread will raise an InvalidOperationException.

Note
Note

Also note that the TextDocumentSnapshotScanner class implements IDisposable and should be used inside of a ‘using’ block or explicitly disposed.

TextDocumentSnapshotScanner Properties

Property List

Property Description

CurrentOffset

This represents the current position of the scanner. When first creating the scanner, the initial property is set to zero. It can be explicitly set, or manipulated by calling any of the ‘SeekTo’ methods in the Methods List table below.

CurrentCharacter

Returns the character at the CurrentOffset

CurrentLine

Returns the line that contains the CurrentOffset.

CurrentToken

Returns the token that contains the CurrentOffset.

Note
Note:

Setting the CurrentOffset to the snapshot’s Length causes the special EOS (end of stream) token to return.

CurrentWord

Returns the word that contains the CurrentOffset`,` or null if the CurrentOffset is not within a word

Snapshot

Returns the associated TextDocumentSnapshot. (read-only)

TextDocumentSnapshotScanner Methods

Method List

Method Description

PeekNextToken

This method returns the next token without changing the CurrentOffset. Use this method’s optional filter (Func<Token, bool>) parameter to skip over tokens that are unimportant (for example,. whitespace, comments or new lines).

PeekPreviousToken

This method returns the previous token without changing the CurrentOffset. Use this method’s optional filter (Func<Token, bool>) to skip over tokens that are not important (for example, whitespace, comments or new lines).

PeekNextWord

This method returns the next word without changing the CurrentOffset.

PeekPreviousWord

This method returns the previous word without changing the CurrentOffset.

SeekToEnd

This method moves the CurrentOffset to the end of the document.

SeekToLine

This method moves the CurrentOffset to a specific line in the document.

SeekToStart

This method moves the CurrentOffset to the start of the document.

SeekToToken

This method moves the CurrentOffset to a specific token in the document.

SeekToWord

This method moves the CurrentOffset to a specific word in the document.

LineFromOffset

This method retrieves a SnapshotLineInfo object for the line of text containing the character at the specified offset.

TokenFromOffset

This method retrieves the Token object containing the character at the specified offset.

WordFromOffset

This method retrieves the Word object containing the character at the specified offset.

Related Content

Topics

The following topic provides additional information related to this topic.

Topic Purpose

This topic describes the Infragistics Syntax Parsing Engine’s main class, TextDocument, and contains links to topics outlining its most important methods, events and properties.

This topic provides an overview of the TextDocumentSnapshot object’s properties and methods.