Skip to main content

Struct SourceSpan

Namespace: OceanApocalypse.RSML.Toolchain.Abstractions.Sources
Assembly: RSML.Toolchain.Abstractions.dll

Represents a span taken from a source.

public readonly struct SourceSpan : IFormattable, IEquatable<SourceSpan>

Implements

IFormattable, IEquatable<SourceSpan>

Inherited Members

Object.Equals(Object?), Object.Equals(Object?, Object?), Object.GetHashCode(), Object.GetType(), Object.ReferenceEquals(Object?, Object?), Object.ToString()

Constructors

SourceSpan(SourceLocation, SourceLocation)

Initializes a new span given a starting and an end indexes.

public SourceSpan(SourceLocation start, SourceLocation end)

Parameters

start SourceLocation

The start index.

end SourceLocation

The end index.

Exceptions

ArgumentException

The starting index is greater or equal to the end index.

Fields

Empty

An empty span.

public static readonly SourceSpan Empty

Field Value

SourceSpan

Properties

End

The end of the span.

public SourceLocation End { get; }

Property Value

SourceLocation

IsSingleLine

The span is located in a single line.

public Boolean IsSingleLine { get; }

Property Value

Boolean

Length

The length of the span.

public Int32 Length { get; }

Property Value

Int32

Start

The start of the span.

public SourceLocation Start { get; }

Property Value

SourceLocation

Methods

Equals(Object?)

Indicates whether this instance and a specified object are equal.

public override Boolean Equals(Object? obj)

Parameters

obj Object?

The object to compare with the current instance.

Returns

Boolean

true if obj and this instance are the same type and represent the same value; otherwise, false.

Equals(SourceSpan)

Checks whether two SourceSpans are equals.

public Boolean Equals(SourceSpan other)

Parameters

other SourceSpan

The span to check against

Returns

Boolean

True if equals

GetHashCode()

Returns the hash code for this instance.

public override Int32 GetHashCode()

Returns

Int32

A 32-bit signed integer that is the hash code for this instance.

ToString()

Returns a generic string representation of the current instance.

public override String ToString()

Returns

String

The string representation.

ToString(String?, IFormatProvider?)

Given a format, tries to return a string that uses said format as a basis for the representation. If it fails, it defaults to ToString.

public String ToString(String? format, IFormatProvider? formatProvider)

Parameters

format String?

The format. Available formats are: CTOR (constructor-like string) and JSON (struct as JSON).

formatProvider IFormatProvider?

Unused. Don't bother assigning it anything.

Returns

String

The string representation.

Operators

operator ==(SourceSpan, SourceSpan)

Checks whether two SourceSpans are equals.

public static Boolean operator ==(SourceSpan left, SourceSpan right)

Parameters

left SourceSpan

right SourceSpan

Returns

Boolean

True if equals

operator !=(SourceSpan, SourceSpan)

Checks whether two SourceSpans are different from each other.

public static Boolean operator !=(SourceSpan left, SourceSpan right)

Parameters

left SourceSpan

right SourceSpan

Returns

Boolean

True if different