Describes a specific position inside a source file.
More...
|
string? | FileName [get] |
| The Filename of the Source Code.
|
|
string | Source [get] |
| The Source Code.
|
|
int | Index [get] |
| The Start Index of the Position.
|
|
int | Length [get] |
| The Length of the Position.
|
|
string | Text [get] |
| Returns the Position as a string.
|
|
|
| BadSourcePosition (string fileName, int index, int length) |
| Constructor for a Source Position.
|
|
Describes a specific position inside a source file.
Definition at line 8 of file BadSourcePosition.cs.
◆ BadSourcePosition() [1/2]
BadScript2.Common.BadSourcePosition.BadSourcePosition |
( |
string? |
fileName, |
|
|
string |
source, |
|
|
int |
index, |
|
|
int |
length |
|
) |
| |
Constructor for a Source Position.
- Parameters
-
fileName | The (optional but recommended) filename |
source | The source code. |
index | The Start Index |
length | The Length |
Definition at line 21 of file BadSourcePosition.cs.
22 {
23 FileName = fileName?.Replace(
'\\',
'/');
27 }
int Index
The Start Index of the Position.
string Source
The Source Code.
string? FileName
The Filename of the Source Code.
int Length
The Length of the Position.
◆ BadSourcePosition() [2/2]
BadScript2.Common.BadSourcePosition.BadSourcePosition |
( |
string |
fileName, |
|
|
int |
index, |
|
|
int |
length |
|
) |
| |
|
private |
Constructor for a Source Position.
- Parameters
-
fileName | The filename |
index | The Start Index |
length | The Length |
Definition at line 36 of file BadSourcePosition.cs.
36 : this(fileName,
38 index,
39 length
40 ) { }
Public interface for the filesystem abstraction of the BadScript Engine.
static string ReadAllText(this IFileSystem fileSystem, string path)
◆ Combine()
Combines two Source Positions.
- Parameters
-
- Returns
- Combined Source Position
- Exceptions
-
InvalidOperationException | Gets raised if the filenames do not match |
Definition at line 170 of file BadSourcePosition.cs.
171 {
173 {
174 throw new InvalidOperationException("Cannot combine positions from different sources");
175 }
176
177 return Index < other.Index
180 }
BadSourcePosition(string? fileName, string source, int index, int length)
Constructor for a Source Position.
◆ Create()
static BadSourcePosition BadScript2.Common.BadSourcePosition.Create |
( |
string |
fileName, |
|
|
string |
source, |
|
|
int |
index, |
|
|
int |
length |
|
) |
| |
|
static |
Creates a new Source Position.
- Parameters
-
fileName | The (optional but recommended) filename |
source | The source code. |
index | The Start Index |
length | The Length |
- Returns
- Created SourcePosition
Definition at line 75 of file BadSourcePosition.cs.
◆ FromFile()
static BadSourcePosition BadScript2.Common.BadSourcePosition.FromFile |
( |
string |
fileName, |
|
|
int |
index, |
|
|
int |
length |
|
) |
| |
|
static |
Creates a new Source Position.
- Parameters
-
fileName | The filename |
index | The Start Index |
length | The Length |
- Returns
- Created SourcePosition
Definition at line 87 of file BadSourcePosition.cs.
◆ FromSource()
static BadSourcePosition BadScript2.Common.BadSourcePosition.FromSource |
( |
string |
source, |
|
|
int |
index, |
|
|
int |
length |
|
) |
| |
|
static |
Creates a new Source Position.
- Parameters
-
source | The source code. |
index | The Start Index |
length | The Length |
- Returns
- Created SourcePosition
Definition at line 99 of file BadSourcePosition.cs.
◆ GetExcerpt() [1/2]
string BadScript2.Common.BadSourcePosition.GetExcerpt |
( |
int |
left, |
|
|
int |
right |
|
) |
| |
Returns the excerpt of the source code.
- Parameters
-
left | The additional Characters before the excerpt |
right | The additional Characters after the excerpt |
- Returns
- String Excerpt
Definition at line 122 of file BadSourcePosition.cs.
123 {
124 int start = Math.Max(0,
Index - left);
126
127 return Source.Substring(start, end - start);
128 }
◆ GetExcerpt() [2/2]
string BadScript2.Common.BadSourcePosition.GetExcerpt |
( |
int |
len = 10 | ) |
|
Returns the excerpt of the source code.
- Parameters
-
len | The additional Characters before and after the excerpt |
- Returns
- String Excerpt
Definition at line 110 of file BadSourcePosition.cs.
111 {
113 }
string GetExcerpt(int len=10)
Returns the excerpt of the source code.
◆ GetLine()
int BadScript2.Common.BadSourcePosition.GetLine |
( |
| ) |
|
Definition at line 130 of file BadSourcePosition.cs.
131 {
132 int line = 1;
133
134 for (
int i = 0; i <
Index; i++)
135 {
137 {
138 line++;
139 }
140 }
141
142 return line;
143 }
◆ GetPositionInfo()
string BadScript2.Common.BadSourcePosition.GetPositionInfo |
( |
| ) |
|
Returns position info. Format: file://[FileName] : Line [Line].
- Returns
- String Representation
Definition at line 150 of file BadSourcePosition.cs.
151 {
153 {
155 }
156
158
160
162 }
◆ m_PositionInfo
string? BadScript2.Common.BadSourcePosition.m_PositionInfo |
|
private |
◆ m_Text
string? BadScript2.Common.BadSourcePosition.m_Text |
|
private |
◆ FileName
string? BadScript2.Common.BadSourcePosition.FileName |
|
get |
◆ Index
int BadScript2.Common.BadSourcePosition.Index |
|
get |
◆ Length
int BadScript2.Common.BadSourcePosition.Length |
|
get |
◆ Source
string BadScript2.Common.BadSourcePosition.Source |
|
get |
◆ Text
string BadScript2.Common.BadSourcePosition.Text |
|
get |
The documentation for this class was generated from the following file: