1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
////////////////////////////////////////////////////////////////////////////////
// This file is part of "Ad Astra", an embeddable scripting programming //
// language platform. //
// //
// This work is proprietary software with source-available code. //
// //
// To copy, use, distribute, or contribute to this work, you must agree to //
// the terms of the General License Agreement: //
// //
// https://github.com/Eliah-Lakhin/ad-astra/blob/master/EULA.md //
// //
// The agreement grants a Basic Commercial License, allowing you to use //
// this work in non-commercial and limited commercial products with a total //
// gross revenue cap. To remove this commercial limit for one of your //
// products, you must acquire a Full Commercial License. //
// //
// If you contribute to the source code, documentation, or related materials, //
// you must grant me an exclusive license to these contributions. //
// Contributions are governed by the "Contributions" section of the General //
// License Agreement. //
// //
// Copying the work in parts is strictly forbidden, except as permitted //
// under the General License Agreement. //
// //
// If you do not or cannot agree to the terms of this Agreement, //
// do not use this work. //
// //
// This work is provided "as is", without any warranties, express or implied, //
// except where such disclaimers are legally invalid. //
// //
// Copyright (c) 2024 Ilya Lakhin (Илья Александрович Лахин). //
// All rights reserved. //
////////////////////////////////////////////////////////////////////////////////
use ;
use RandomState;
use ;
use crate::;
/// A view into the [ScriptModule](crate::analysis::ScriptModule) source code
/// text and lexis.
///
/// Created by the [ModuleRead::text](crate::analysis::ModuleRead::text)
/// function.
///
/// To fetch the raw text of the source code or a substring, use the
/// [ModuleText::substring](lady_deirdre::lexis::SourceCode::substring)
/// function.
///
/// To print a snippet of the source code text with syntax highlighting
/// and annotation messages to the terminal, use the [ModuleText::snippet]
/// function. The [Display] implementation of this object also prints
/// a highlighted snippet with default settings.
/// An interface that provides access to script module texts by module [Id].
///
/// When displaying runtime errors (through the
/// [RuntimeError::display](crate::runtime::RuntimeError::display) function),
/// the inner algorithm needs access to the script module text of the modules
/// mentioned in the error's description. You can implement this trait on
/// your custom multi-module compiler to provide access to the module texts.
///
/// If your compiler consists of runtime-independent script modules, you can
/// use a normal [ModuleText], which implements ModuleTextResolver out of the
/// box.