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(
37 fileName,
39 index,
40 length
41 ) { }
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 164 of file BadSourcePosition.cs.
165 {
167 {
168 throw new InvalidOperationException("Cannot combine positions from different sources");
169 }
170
171 return Index < other.Index
174 }
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 76 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 88 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 100 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 123 of file BadSourcePosition.cs.
124 {
125 int start = Math.Max(0,
Index - left);
127
128 return Source.Substring(start, end - start);
129 }
◆ 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 111 of file BadSourcePosition.cs.
112 {
114 }
string GetExcerpt(int len=10)
Returns the excerpt of the source code.
◆ GetPositionInfo()
string BadScript2.Common.BadSourcePosition.GetPositionInfo |
( |
| ) |
|
Returns position info. Format: file://[FileName] : Line [Line].
- Returns
- String Representation
Definition at line 136 of file BadSourcePosition.cs.
137 {
139 {
141 }
142
143 int line = 1;
144
145 for (
int i = 0; i <
Index; i++)
146 {
148 {
149 line++;
150 }
151 }
152
154
156 }
◆ 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: