Enhanced C#
Loyc library documentation
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events Pages
Public fields | Public static fields | Properties | Public Member Functions | Static Public Member Functions | List of all members
Loyc.Syntax.SourceRange Struct Reference

Holds a reference to a source file (ISourceFile<char>) and the beginning and end indices of a range in that file. More...


Source file:
Inheritance diagram for Loyc.Syntax.SourceRange:
Loyc.Syntax.ISourceRange Loyc.Syntax.IIndexRange

Remarks

Holds a reference to a source file (ISourceFile<char>) and the beginning and end indices of a range in that file.

Public fields

UString SourceText => SourceRangeExt.SourceText(this)
 
ILineColumnFile Start => SourceRangeExt.Start(this)
 
ILineColumnFile End => SourceRangeExt.End(this)
 

Public static fields

static readonly SourceRange Nowhere = new SourceRange(EmptySourceFile.Synthetic, -1, 0)
 
static readonly SourceRange Synthetic = new SourceRange(EmptySourceFile.Synthetic, -1, 0)
 

Properties

ISourceFile Source [get]
 Returns the source file of which this range is a part. If this SourceRange represents a "synthetic" syntax tree (created programmatically), the source file may be an empty "dummy" object such as EmptySourceFile. In this case, the Length should be zero. More...
 
int StartIndex [get]
 
int EndIndex [get]
 
int Length [get]
 
char this[int subIndex] [get]
 
- Properties inherited from Loyc.Syntax.ISourceRange
ISourceFile Source [get]
 
- Properties inherited from Loyc.Syntax.IIndexRange
int StartIndex [get]
 
int EndIndex [get]
 
int Length [get]
 

Public Member Functions

 SourceRange (ISourceFile source, int beginIndex=-1, int length=0)
 
 SourceRange (ISourceRange range)
 
SourceRange Normalized ()
 If the Length is negative so StartIndex > EndIndex, this returns a copy of the range with StartIndex and EndIndex swapped; otherwise the same range is returned. More...
 
bool Equals (SourceRange other)
 
override bool Equals (object?obj)
 
override int GetHashCode ()
 
override string ToString ()
 
SourceRange GetRangeOfOverlap (SourceRange other)
 Assuming both ranges are normalized, returns the range of overlap between them. If the ranges are in different files or do not overlap, null is returned. If the two ranges share a border, this method returns a zero-Length range. More...
 
bool Overlaps (SourceRange other)
 Returns true if, assuming both ranges are normalized, the two regions share at least one common character. More...
 
bool Contains (SourceRange inner)
 

Static Public Member Functions

static SourceRange New< IndexRange > (ISourceFile source, IndexRange range)
 
static implicit operator IndexRange (SourceRange r)
 
static bool operator== (SourceRange a, SourceRange b)
 
static bool operator!= (SourceRange a, SourceRange b)
 

Member Function Documentation

SourceRange Loyc.Syntax.SourceRange.GetRangeOfOverlap ( SourceRange  other)
inline

Assuming both ranges are normalized, returns the range of overlap between them. If the ranges are in different files or do not overlap, null is returned. If the two ranges share a border, this method returns a zero-Length range.

References Loyc.Syntax.SourceRange.Source.

SourceRange Loyc.Syntax.SourceRange.Normalized ( )
inline

If the Length is negative so StartIndex > EndIndex, this returns a copy of the range with StartIndex and EndIndex swapped; otherwise the same range is returned.

Exceptions
OverflowExceptionAn integer overflow occurred.
bool Loyc.Syntax.SourceRange.Overlaps ( SourceRange  other)
inline

Returns true if, assuming both ranges are normalized, the two regions share at least one common character.

Note: this returns false if either of the ranges has a Length of zero and is at the boundary of the other range.

Property Documentation

ISourceFile Loyc.Syntax.SourceRange.Source
get

Returns the source file of which this range is a part. If this SourceRange represents a "synthetic" syntax tree (created programmatically), the source file may be an empty "dummy" object such as EmptySourceFile. In this case, the Length should be zero.

Referenced by Loyc.Syntax.SourceRange.GetRangeOfOverlap(), and Loyc.Syntax.LNode.MergeBinary().