Enhanced C#
Language of your choice: library documentation

Documentation moved to ecsharp.net

GitHub doesn't support HTTP redirects, so you'll be redirected in 3 seconds.

 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Properties | Public Member Functions | List of all members
Loyc.Syntax.SourceFileWithLineRemaps Class Reference

An wrapper around ISourceFile that applies line remapping information (if the source file uses it). More...


Source file:
Inheritance diagram for Loyc.Syntax.SourceFileWithLineRemaps:
Loyc.WrapperBase< T > Loyc.Syntax.ISourceFile Loyc.Syntax.IIndexPositionMapper Loyc.Syntax.IIndexToLine

Remarks

An wrapper around ISourceFile that applies line remapping information (if the source file uses it).

A preprocessor that supports #line may wrap the original ISourceFile in one of these, even when the source file doesn't use #line.

Call Remaps.AddRemap() and, optionally, Remaps.EndRemap(), to add each mapping.

ISourceFile includes IIndexPositionMapper which allows reverse-mapping from line/position back to index. However, a position derived from #line information may be ambiguous (does not always have a unique reverse mapping), and I'd rather avoid the work of reverse mapping anyway. So this class does not perform reverse mapping, but forward mappings return SourcePosAndIndex which are automatically recognized by LineToIndex which thereby recovers the original index.

Properties

LineRemapper Remaps [get, set]
 
ICharSource Text [get]
 
string FileName [get]
 
- Properties inherited from Loyc.Syntax.ISourceFile
ICharSource Text [get]
 
string FileName [get]
 

Public Member Functions

 SourceFileWithLineRemaps (ISourceFile original)
 
int LineToIndex (int lineNo)
 Returns the index in a source file of the beginning of the specified line, where the first line is number 1, not 0. More...
 
int LineToIndex (LineAndCol pos)
 
SourcePos IndexToLine (int index)
 Returns the position in a source file of the specified index. More...
 
- Public Member Functions inherited from Loyc.WrapperBase< T >
override bool Equals (object obj)
 Returns true iff the parameter 'obj' is a wrapper around the same object that this object wraps. More...
 
override int GetHashCode ()
 Returns the hashcode of the wrapped object. More...
 
override string ToString ()
 Returns ToString() of the wrapped object. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Loyc.WrapperBase< T >
 WrapperBase (T wrappedObject)
 
- Protected fields inherited from Loyc.WrapperBase< T >
_obj
 
- Protected static fields inherited from Loyc.WrapperBase< T >
static readonly
EqualityComparer< T > 
TComp = EqualityComparer<T>.Default
 

Member Function Documentation

SourcePos Loyc.Syntax.SourceFileWithLineRemaps.IndexToLine ( int  index)
inline

Returns the position in a source file of the specified index.

If index is negative, this should return a SourcePos where Line and PosInLine are zero (signifying an unknown location). If index is beyond the end of the file, this should retun the final position in the file.

Implements Loyc.Syntax.IIndexToLine.

int Loyc.Syntax.SourceFileWithLineRemaps.LineToIndex ( int  lineNo)
inline

Returns the index in a source file of the beginning of the specified line, where the first line is number 1, not 0.

If lineNo is zero, this method should return -1 (signifying an unknown location). If lineNo is larger than the largest line number, this method should return the index of end-of-file.

Implements Loyc.Syntax.IIndexPositionMapper.