C# Class Microsoft.Cci.PrimarySourceDocument

Inheritance: SourceDocument, IPrimarySourceDocument
显示文件 Open project: visualmutator/visualmutator Class Usage Examples

Private Properties

Property Type Description
FindBestStartPointForLine int
FindBestStartPointForPosition int
GetOwnStreamReaderAndReadAhead void
ObjectInvariant void
PrimarySourceDocument System
PrimarySourceDocument System
PrimarySourceDocument System
PrimarySourceDocument System
SetStreamReaderPositionTo void

Public Methods

Method Description
CopyTo ( int position, char destination, int destinationOffset, int length ) : int

Copies no more than the specified number of characters to the destination character array, starting at the specified position in the source document. Returns the actual number of characters that were copied. This number will be greater than zero as long as position is less than this.Length. The number will be precisely the number asked for unless there are not enough characters left in the document.

GetPrimarySourceLocation ( int position, int length ) : IPrimarySourceLocation

Obtains a primary source location instance that corresponds to the substring of the document specified by the given start position and length.

GetSourceLocation ( int position, int length ) : ISourceLocation

Obtains a source location instance that corresponds to the substring of the document specified by the given start position and length.

GetText ( ) : string

Returns the source text of the document in string form. Each call may do significant work, so be sure to cache this.

ToLineColumn ( int position, int &line, int &column ) : void

Maps the given (zero based) source position to a (one based) line and column, by scanning the source character by character, counting new lines until the given source position is reached. The source position and corresponding line+column are remembered and scanning carries on where it left off when this routine is called next. If the given position precedes the last given position, we use backward scanning. Optimal use of this method requires the client to sort calls in order of position.

This method behaves badly when applied to a really large file since it loads the entire file in memory as a UTF16 unicode string. In such cases, a slower implementation based on streaming would be more appropriate. However, it is assumed that getting source context information from such really large files is an extremely rare event and that bad performance in such cases is better than degraded performance in the common case.

ToPosition ( int line, int column ) : int

Maps a one based line and column pair to a zero based character position, by scanning the source character by character, counting new lines until the given source position is reached. The source position and corresponding line+column are remembered and scanning carries on where it left off when this routine is called next. If the given position precedes the last given position, scanning restarts from the start. Optimal use of this method requires the client to sort calls in order of position.

This method behaves badly when applied to a really large file since it loads the entire file in memory as a UTF16 unicode string. In such cases, a slower implementation based on streaming would be more appropriate. However, it is assumed that getting source context information from such really large files is an extremely rare event and that bad performance in such cases is better than degraded performance in the common case.

Private Methods

Method Description
FindBestStartPointForLine ( int line ) : int

From the set of stored states for position/(line,column) conversion, find the one that is closest to line.

FindBestStartPointForPosition ( int position ) : int

From the set of stored states for position/(line,column) conversion, find the one that is closed to position

GetOwnStreamReaderAndReadAhead ( StreamReader streamReader ) : void
ObjectInvariant ( ) : void
PrimarySourceDocument ( IName name, string location, StreamReader streamReader ) : System
PrimarySourceDocument ( IName name, string location, string text ) : System
PrimarySourceDocument ( PrimarySourceDocument template ) : System
PrimarySourceDocument ( string text, SourceDocument previousVersion, int position, int oldLength, int newLength ) : System
SetStreamReaderPositionTo ( int position ) : void

Advances or resets the stream reader so that this.buffer (the current window on the stream) spans the given position.

Method Details

CopyTo() public method

Copies no more than the specified number of characters to the destination character array, starting at the specified position in the source document. Returns the actual number of characters that were copied. This number will be greater than zero as long as position is less than this.Length. The number will be precisely the number asked for unless there are not enough characters left in the document.
public CopyTo ( int position, char destination, int destinationOffset, int length ) : int
position int The starting index to copy from. Must be greater than or equal to zero and position+length must be less than or equal to this.Length;
destination char The destination array.
destinationOffset int The starting index where the characters must be copied to in the destination array.
length int The maximum number of characters to copy. Must be greater than 0 and less than or equal to the number elements of the destination array.
return int

GetPrimarySourceLocation() public method

Obtains a primary source location instance that corresponds to the substring of the document specified by the given start position and length.
public GetPrimarySourceLocation ( int position, int length ) : IPrimarySourceLocation
position int
length int
return IPrimarySourceLocation

GetSourceLocation() public method

Obtains a source location instance that corresponds to the substring of the document specified by the given start position and length.
public GetSourceLocation ( int position, int length ) : ISourceLocation
position int
length int
return ISourceLocation

GetText() public method

Returns the source text of the document in string form. Each call may do significant work, so be sure to cache this.
public GetText ( ) : string
return string

ToLineColumn() public method

Maps the given (zero based) source position to a (one based) line and column, by scanning the source character by character, counting new lines until the given source position is reached. The source position and corresponding line+column are remembered and scanning carries on where it left off when this routine is called next. If the given position precedes the last given position, we use backward scanning. Optimal use of this method requires the client to sort calls in order of position.
This method behaves badly when applied to a really large file since it loads the entire file in memory as a UTF16 unicode string. In such cases, a slower implementation based on streaming would be more appropriate. However, it is assumed that getting source context information from such really large files is an extremely rare event and that bad performance in such cases is better than degraded performance in the common case.
public ToLineColumn ( int position, int &line, int &column ) : void
position int
line int
column int
return void

ToPosition() public method

Maps a one based line and column pair to a zero based character position, by scanning the source character by character, counting new lines until the given source position is reached. The source position and corresponding line+column are remembered and scanning carries on where it left off when this routine is called next. If the given position precedes the last given position, scanning restarts from the start. Optimal use of this method requires the client to sort calls in order of position.
This method behaves badly when applied to a really large file since it loads the entire file in memory as a UTF16 unicode string. In such cases, a slower implementation based on streaming would be more appropriate. However, it is assumed that getting source context information from such really large files is an extremely rare event and that bad performance in such cases is better than degraded performance in the common case.
public ToPosition ( int line, int column ) : int
line int
column int
return int