xmlui 0.9.92 → 0.9.93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/{index-C5eOg7bB.mjs → index-C4FeLQEv.mjs} +7972 -7779
- package/dist/lib/index.css +1 -1
- package/dist/lib/{initMock-DLD4GmW7.mjs → initMock-DwQKZ8T4.mjs} +1 -1
- package/dist/lib/language-server-web-worker.mjs +1 -1
- package/dist/lib/language-server.mjs +1 -1
- package/dist/lib/{metadata-utils-BE5_Lmoa.mjs → metadata-utils-PjrGUxZN.mjs} +1 -1
- package/dist/lib/{server-common-xCK0Af2K.mjs → server-common-BbjTO8TH.mjs} +2 -2
- package/dist/lib/{transform-bUuxPyao.mjs → transform-CDSgqN5L.mjs} +1240 -1202
- package/dist/lib/xmlui-parser.d.ts +3 -1
- package/dist/lib/xmlui-parser.mjs +2 -2
- package/dist/lib/{xmlui-serializer-BLFl30t9.mjs → xmlui-serializer-D6rtRMNI.mjs} +1 -1
- package/dist/lib/xmlui.d.ts +17 -12
- package/dist/lib/xmlui.mjs +2 -2
- package/dist/metadata/{collectedComponentMetadata-iKGyD6r3.mjs → collectedComponentMetadata-CTFECKPI.mjs} +8860 -8630
- package/dist/metadata/{initMock-CZGAyfXr.mjs → initMock-DUtrSCpH.mjs} +1 -1
- package/dist/metadata/style.css +1 -1
- package/dist/metadata/xmlui-metadata.mjs +1 -1
- package/dist/metadata/xmlui-metadata.umd.js +102 -98
- package/dist/scripts/package.json +2 -1
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +5 -2
- package/dist/scripts/src/components/AutoComplete/AutoCompleteContext.js +1 -2
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +9 -12
- package/dist/scripts/src/components/Bookmark/Bookmark.js +1 -1
- package/dist/scripts/src/components/Option/Option.js +11 -11
- package/dist/scripts/src/components/Select/HiddenOption.js +2 -2
- package/dist/scripts/src/components/Select/Select.js +5 -9
- package/dist/scripts/src/components/Select/SelectNative.js +95 -45
- package/dist/scripts/src/components/SlotItem.js +1 -0
- package/dist/scripts/src/components/Spinner/SpinnerNative.js +3 -4
- package/dist/scripts/src/components/Tabs/TabItem.js +12 -1
- package/dist/scripts/src/components/Tabs/TabItemNative.js +4 -3
- package/dist/scripts/src/components/Tabs/Tabs.js +1 -1
- package/dist/scripts/src/components/Tabs/TabsNative.js +22 -43
- package/dist/scripts/src/components/TextArea/TextArea.js +1 -2
- package/dist/scripts/src/components/Toggle/Toggle.js +34 -10
- package/dist/scripts/src/components/container-helpers.js +2 -1
- package/dist/scripts/src/components-core/rendering/ComponentWrapper.js +2 -1
- package/dist/scripts/src/components-core/xmlui-parser.js +365 -196
- package/dist/scripts/src/parsers/xmlui-parser/diagnostics.js +1 -1
- package/dist/scripts/src/parsers/xmlui-parser/parser.js +69 -1
- package/dist/standalone/xmlui-standalone.es.d.ts +18 -12
- package/dist/standalone/xmlui-standalone.umd.js +252 -248
- package/package.json +2 -1
- package/dist/scripts/src/abstractions/scripting/modules.js +0 -2
|
@@ -19,9 +19,9 @@ function xmlUiMarkupToComponent(source, fileId = 0) {
|
|
|
19
19
|
newlinePositions.push(i);
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
|
-
const
|
|
22
|
+
const errorsForDisplay = addDisplayFieldsToErrors(errors, source, newlinePositions);
|
|
23
23
|
const erroneousCompoundComponentName = getCompoundCompName(node, getText);
|
|
24
|
-
return { component: null, errors:
|
|
24
|
+
return { component: null, errors: errorsForDisplay, erroneousCompoundComponentName };
|
|
25
25
|
}
|
|
26
26
|
try {
|
|
27
27
|
const component = (0, transform_1.nodeToComponentDef)(node, getText, fileId);
|
|
@@ -32,12 +32,16 @@ function xmlUiMarkupToComponent(source, fileId = 0) {
|
|
|
32
32
|
const erroneousCompoundComponentName = getCompoundCompName(node, getText);
|
|
33
33
|
const singleErr = {
|
|
34
34
|
message: e.message,
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
errPosCol: 0,
|
|
36
|
+
errPosLine: 0,
|
|
37
37
|
code: diagnostics_1.ErrCodes.expEq,
|
|
38
38
|
category: diagnostics_1.DiagnosticCategory.Error,
|
|
39
39
|
pos: 0,
|
|
40
40
|
end: 0,
|
|
41
|
+
contextPos: 0,
|
|
42
|
+
contextEnd: 0,
|
|
43
|
+
contextSource: "",
|
|
44
|
+
contextStartLine: 0,
|
|
41
45
|
};
|
|
42
46
|
return {
|
|
43
47
|
component: null,
|
|
@@ -49,53 +53,289 @@ function xmlUiMarkupToComponent(source, fileId = 0) {
|
|
|
49
53
|
/** returns a component definition containing the errors.
|
|
50
54
|
* It is a component and a compound component definition at the same time,
|
|
51
55
|
* so that it can be used to render the errors for a compound component as well*/
|
|
56
|
+
function createErrorMessageComponent(message) {
|
|
57
|
+
const comp = {
|
|
58
|
+
type: "VStack",
|
|
59
|
+
props: { padding: "$padding-normal", gap: 0 },
|
|
60
|
+
children: [
|
|
61
|
+
{
|
|
62
|
+
type: "H1",
|
|
63
|
+
props: {
|
|
64
|
+
value: message,
|
|
65
|
+
padding: "$padding-normal",
|
|
66
|
+
backgroundColor: "$color-error",
|
|
67
|
+
color: "white",
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
};
|
|
72
|
+
return comp;
|
|
73
|
+
}
|
|
52
74
|
function errReportMessage(message) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
75
|
+
const comp = createErrorMessageComponent(message);
|
|
76
|
+
comp.component = createErrorMessageComponent(message);
|
|
77
|
+
return comp;
|
|
78
|
+
}
|
|
79
|
+
/** returns a component definition containing the errors.
|
|
80
|
+
* It is a component and a compound component definition at the same time,
|
|
81
|
+
* so that it can be used to render the errors for a compound component as well*/
|
|
82
|
+
function createErrorReportComponent(errors, fileName) {
|
|
83
|
+
const errList = errors
|
|
84
|
+
.sort((a, b) => {
|
|
85
|
+
if (a.pos === undefined && b.pos === undefined) {
|
|
86
|
+
return 0;
|
|
87
|
+
}
|
|
88
|
+
else if (a.pos === undefined) {
|
|
89
|
+
return 1;
|
|
90
|
+
}
|
|
91
|
+
else if (b.pos === undefined) {
|
|
92
|
+
return -1;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
return a.pos - b.pos;
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
.map((e, idx) => {
|
|
99
|
+
// Calculate relative positions within context
|
|
100
|
+
const errorStartInContext = e.pos - e.contextPos;
|
|
101
|
+
const errorEndInContext = e.end - e.contextPos;
|
|
102
|
+
// Split context source into lines and process each line
|
|
103
|
+
const contextLines = e.contextSource.split("\n");
|
|
104
|
+
let currentPos = 0;
|
|
105
|
+
// Calculate padding for line numbers to maintain alignment
|
|
106
|
+
const lastLineNumber = e.contextStartLine + contextLines.length - 1;
|
|
107
|
+
const maxDigits = lastLineNumber.toString().length;
|
|
108
|
+
const contextChildren = [];
|
|
109
|
+
for (let lineIdx = 0; lineIdx < contextLines.length; lineIdx++) {
|
|
110
|
+
const line = contextLines[lineIdx];
|
|
111
|
+
const lineNumber = e.contextStartLine + lineIdx;
|
|
112
|
+
const paddedLineNumber = lineNumber.toString().padStart(maxDigits, "0");
|
|
113
|
+
const linePrefix = `${paddedLineNumber} | `;
|
|
114
|
+
// Check if error spans this line
|
|
115
|
+
const lineStart = currentPos;
|
|
116
|
+
const lineEnd = currentPos + line.length;
|
|
117
|
+
const lineChildren = [
|
|
118
|
+
{
|
|
119
|
+
type: "Text",
|
|
120
|
+
props: {
|
|
121
|
+
value: linePrefix,
|
|
122
|
+
fontFamily: "monospace",
|
|
123
|
+
color: "$color-info",
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
if (errorStartInContext >= lineStart && errorStartInContext < lineEnd) {
|
|
128
|
+
// Error starts on this line
|
|
129
|
+
const beforeError = line.substring(0, errorStartInContext - lineStart);
|
|
130
|
+
const errorInLine = line.substring(errorStartInContext - lineStart, Math.min(errorEndInContext - lineStart, line.length));
|
|
131
|
+
const afterError = line.substring(Math.min(errorEndInContext - lineStart, line.length));
|
|
132
|
+
if (beforeError) {
|
|
133
|
+
lineChildren.push({
|
|
134
|
+
type: "Text",
|
|
135
|
+
props: {
|
|
136
|
+
value: beforeError,
|
|
137
|
+
fontFamily: "monospace",
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
if (errorInLine) {
|
|
142
|
+
lineChildren.push({
|
|
143
|
+
type: "Text",
|
|
144
|
+
props: {
|
|
145
|
+
value: errorInLine,
|
|
146
|
+
fontFamily: "monospace",
|
|
147
|
+
textDecorationLine: "underline",
|
|
148
|
+
textDecorationColor: "$color-error",
|
|
149
|
+
backgroundColor: "rgb(from $color-error r g b / 0.1)",
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
if (afterError) {
|
|
154
|
+
lineChildren.push({
|
|
155
|
+
type: "Text",
|
|
156
|
+
props: {
|
|
157
|
+
value: afterError,
|
|
158
|
+
fontFamily: "monospace",
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else if (errorStartInContext < lineStart && errorEndInContext > lineEnd) {
|
|
164
|
+
// Entire line is within error span
|
|
165
|
+
lineChildren.push({
|
|
166
|
+
type: "Text",
|
|
167
|
+
props: {
|
|
168
|
+
value: line,
|
|
169
|
+
fontFamily: "monospace",
|
|
170
|
+
textDecorationLine: "underline",
|
|
171
|
+
textDecorationColor: "$color-error",
|
|
172
|
+
backgroundColor: "rgb(from $color-error r g b / 0.1)",
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
else if (errorStartInContext < lineStart &&
|
|
177
|
+
errorEndInContext >= lineStart &&
|
|
178
|
+
errorEndInContext < lineEnd) {
|
|
179
|
+
// Error ends on this line
|
|
180
|
+
const errorInLine = line.substring(0, errorEndInContext - lineStart);
|
|
181
|
+
const afterError = line.substring(errorEndInContext - lineStart);
|
|
182
|
+
if (errorInLine) {
|
|
183
|
+
lineChildren.push({
|
|
184
|
+
type: "Text",
|
|
185
|
+
props: {
|
|
186
|
+
value: errorInLine,
|
|
187
|
+
fontFamily: "monospace",
|
|
188
|
+
textDecorationLine: "underline",
|
|
189
|
+
textDecorationColor: "$color-error",
|
|
190
|
+
backgroundColor: "rgb(from $color-error r g b / 0.1)",
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
if (afterError) {
|
|
195
|
+
lineChildren.push({
|
|
196
|
+
type: "Text",
|
|
197
|
+
props: {
|
|
198
|
+
value: afterError,
|
|
199
|
+
fontFamily: "monospace",
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else if (lineEnd === errorStartInContext && errorStartInContext === errorEndInContext) {
|
|
205
|
+
// Zero-length error span - insert visible vertical bar
|
|
206
|
+
lineChildren.push({
|
|
207
|
+
type: "Text",
|
|
208
|
+
props: {
|
|
209
|
+
value: line,
|
|
210
|
+
fontFamily: "monospace",
|
|
211
|
+
},
|
|
212
|
+
});
|
|
213
|
+
lineChildren.push({
|
|
214
|
+
type: "Text",
|
|
215
|
+
props: {
|
|
216
|
+
value: " ",
|
|
217
|
+
preserveLinebreaks: true,
|
|
218
|
+
textDecorationLine: "underline",
|
|
219
|
+
fontFamily: "monospace",
|
|
220
|
+
fontWeight: "bold",
|
|
221
|
+
backgroundColor: "rgb(from $color-error r g b / 0.1)",
|
|
222
|
+
color: "$color-error",
|
|
223
|
+
},
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
// No error on this line
|
|
228
|
+
lineChildren.push({
|
|
229
|
+
type: "Text",
|
|
230
|
+
props: {
|
|
231
|
+
value: line,
|
|
232
|
+
fontFamily: "monospace",
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
contextChildren.push({
|
|
237
|
+
type: "HStack",
|
|
238
|
+
props: { gap: "0" },
|
|
239
|
+
children: lineChildren,
|
|
240
|
+
});
|
|
241
|
+
currentPos = lineEnd + 1; // +1 for newline character
|
|
242
|
+
}
|
|
243
|
+
const errMsgComponenet = {
|
|
244
|
+
type: "HStack",
|
|
245
|
+
props: { gap: "0" },
|
|
57
246
|
children: [
|
|
58
247
|
{
|
|
59
|
-
type: "
|
|
248
|
+
type: "Text",
|
|
60
249
|
props: {
|
|
61
|
-
value:
|
|
62
|
-
|
|
63
|
-
backgroundColor: "$color-error",
|
|
64
|
-
color: "white",
|
|
250
|
+
value: `#${idx + 1}: ${fileName} (${e.errPosLine}:${e.errPosCol}):\xa0`,
|
|
251
|
+
color: "$color-info",
|
|
65
252
|
},
|
|
66
253
|
},
|
|
254
|
+
{
|
|
255
|
+
type: "Text",
|
|
256
|
+
props: { value: ` ${e.message}`, fontWeight: "bold" },
|
|
257
|
+
},
|
|
67
258
|
],
|
|
68
259
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
260
|
+
const context = {
|
|
261
|
+
type: "VStack",
|
|
262
|
+
props: {
|
|
263
|
+
gap: "0",
|
|
264
|
+
padding: "$padding-normal",
|
|
265
|
+
backgroundColor: "$color-surface-variant",
|
|
266
|
+
},
|
|
267
|
+
children: contextChildren,
|
|
268
|
+
};
|
|
269
|
+
const errComponenet = {
|
|
270
|
+
type: "VStack",
|
|
271
|
+
props: {
|
|
272
|
+
gap: "$gap-none",
|
|
273
|
+
borderLeft: "1px solid black",
|
|
274
|
+
borderTop: "1px solid black",
|
|
275
|
+
width: "fit-content",
|
|
276
|
+
padding: "4px",
|
|
277
|
+
},
|
|
278
|
+
children: [errMsgComponenet],
|
|
279
|
+
};
|
|
280
|
+
if (!(e.contextSource === "" && e.pos === 0 && e.end === 0)) {
|
|
281
|
+
errComponenet.children.push(context);
|
|
282
|
+
}
|
|
283
|
+
return errComponenet;
|
|
284
|
+
});
|
|
285
|
+
const comp = {
|
|
286
|
+
type: "VStack",
|
|
287
|
+
props: { padding: "$padding-normal", gap: 0 },
|
|
288
|
+
children: [
|
|
289
|
+
{
|
|
290
|
+
type: "H1",
|
|
291
|
+
props: {
|
|
292
|
+
value: `${errList.length} ${errList.length > 1 ? "Errors" : "Error"} found while processing XMLUI markup`,
|
|
293
|
+
padding: "$padding-normal",
|
|
294
|
+
backgroundColor: "$color-error",
|
|
295
|
+
color: "white",
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
type: "VStack",
|
|
300
|
+
props: {
|
|
301
|
+
gap: "$gap-tight",
|
|
302
|
+
padding: "$padding-normal",
|
|
303
|
+
},
|
|
304
|
+
children: errList,
|
|
305
|
+
},
|
|
306
|
+
],
|
|
307
|
+
};
|
|
308
|
+
return comp;
|
|
309
|
+
}
|
|
310
|
+
function errReportComponent(errors, fileName, compoundCompName) {
|
|
311
|
+
const comp = createErrorReportComponent(errors, fileName);
|
|
312
|
+
comp.name = compoundCompName;
|
|
313
|
+
comp.component = createErrorReportComponent(errors, fileName);
|
|
73
314
|
return comp;
|
|
74
315
|
}
|
|
75
316
|
/** returns a component definition containing the errors.
|
|
76
317
|
* It is a component and a compound component definition at the same time,
|
|
77
318
|
* so that it can be used to render the errors for a compound component as well*/
|
|
78
|
-
function
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
})
|
|
95
|
-
.map((e, idx) => {
|
|
96
|
-
return {
|
|
319
|
+
function createScriptErrorComponent(error, fileName) {
|
|
320
|
+
const comp = {
|
|
321
|
+
type: "VStack",
|
|
322
|
+
props: { padding: "$padding-normal", gap: 0 },
|
|
323
|
+
children: [
|
|
324
|
+
{
|
|
325
|
+
type: "H1",
|
|
326
|
+
props: {
|
|
327
|
+
value: `An error found while processing XMLUI code-behind script`,
|
|
328
|
+
padding: "$padding-normal",
|
|
329
|
+
backgroundColor: "$color-error",
|
|
330
|
+
color: "white",
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
{
|
|
97
334
|
type: "VStack",
|
|
98
|
-
props: {
|
|
335
|
+
props: {
|
|
336
|
+
gap: "$gap-tight",
|
|
337
|
+
padding: "$padding-normal",
|
|
338
|
+
},
|
|
99
339
|
children: [
|
|
100
340
|
{
|
|
101
341
|
type: "HStack",
|
|
@@ -104,191 +344,111 @@ function errReportComponent(errors, fileName, compoundCompName) {
|
|
|
104
344
|
{
|
|
105
345
|
type: "Text",
|
|
106
346
|
props: {
|
|
107
|
-
value:
|
|
347
|
+
value: `${fileName} (${error.line}:${error.column}):\xa0`,
|
|
108
348
|
color: "$color-info",
|
|
109
349
|
},
|
|
110
350
|
},
|
|
111
351
|
{
|
|
112
352
|
type: "Text",
|
|
113
|
-
props: { value: ` ${
|
|
353
|
+
props: { value: ` ${error.text}`, fontWeight: "bold" },
|
|
114
354
|
},
|
|
115
355
|
],
|
|
116
356
|
},
|
|
117
357
|
],
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
type: "VStack",
|
|
122
|
-
props: { padding: "$padding-normal", gap: 0 },
|
|
123
|
-
children: [
|
|
124
|
-
{
|
|
125
|
-
type: "H1",
|
|
126
|
-
props: {
|
|
127
|
-
value: `${errList.length} ${errList.length > 1 ? "Errors" : "Error"} found while processing XMLUI markup`,
|
|
128
|
-
padding: "$padding-normal",
|
|
129
|
-
backgroundColor: "$color-error",
|
|
130
|
-
color: "white",
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
{
|
|
134
|
-
type: "VStack",
|
|
135
|
-
props: {
|
|
136
|
-
gap: "$gap-tight",
|
|
137
|
-
padding: "$padding-normal",
|
|
138
|
-
},
|
|
139
|
-
children: errList,
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
};
|
|
143
|
-
return comp;
|
|
144
|
-
}
|
|
145
|
-
const comp = makeComponent();
|
|
146
|
-
comp.name = compoundCompName;
|
|
147
|
-
comp.component = makeComponent();
|
|
358
|
+
},
|
|
359
|
+
],
|
|
360
|
+
};
|
|
148
361
|
return comp;
|
|
149
362
|
}
|
|
150
|
-
/** returns a component definition containing the errors.
|
|
151
|
-
* It is a component and a compound component definition at the same time,
|
|
152
|
-
* so that it can be used to render the errors for a compound component as well*/
|
|
153
363
|
function errReportScriptError(error, fileName) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
type: "VStack",
|
|
157
|
-
props: { padding: "$padding-normal", gap: 0 },
|
|
158
|
-
children: [
|
|
159
|
-
{
|
|
160
|
-
type: "H1",
|
|
161
|
-
props: {
|
|
162
|
-
value: `An error found while processing XMLUI code-behind script`,
|
|
163
|
-
padding: "$padding-normal",
|
|
164
|
-
backgroundColor: "$color-error",
|
|
165
|
-
color: "white",
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
{
|
|
169
|
-
type: "VStack",
|
|
170
|
-
props: {
|
|
171
|
-
gap: "$gap-tight",
|
|
172
|
-
padding: "$padding-normal",
|
|
173
|
-
},
|
|
174
|
-
children: [
|
|
175
|
-
{
|
|
176
|
-
type: "HStack",
|
|
177
|
-
props: { gap: "0" },
|
|
178
|
-
children: [
|
|
179
|
-
{
|
|
180
|
-
type: "Text",
|
|
181
|
-
props: {
|
|
182
|
-
value: `${fileName} (${error.line}:${error.column}):\xa0`,
|
|
183
|
-
color: "$color-info",
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
type: "Text",
|
|
188
|
-
props: { value: ` ${error.text}`, fontWeight: "bold" },
|
|
189
|
-
},
|
|
190
|
-
],
|
|
191
|
-
},
|
|
192
|
-
],
|
|
193
|
-
},
|
|
194
|
-
],
|
|
195
|
-
};
|
|
196
|
-
return comp;
|
|
197
|
-
}
|
|
198
|
-
const comp = makeComponent();
|
|
199
|
-
comp.component = makeComponent();
|
|
364
|
+
const comp = createScriptErrorComponent(error, fileName);
|
|
365
|
+
comp.component = createScriptErrorComponent(error, fileName);
|
|
200
366
|
return comp;
|
|
201
367
|
}
|
|
202
368
|
/** returns a component definition containing the errors.
|
|
203
369
|
* It is a component and a compound component definition at the same time,
|
|
204
370
|
* so that it can be used to render the errors for a compound component as well*/
|
|
205
|
-
function
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
color: "$color-info",
|
|
225
|
-
},
|
|
226
|
-
},
|
|
227
|
-
{
|
|
228
|
-
type: "Text",
|
|
229
|
-
props: { value: ` ${err.text}`, fontWeight: "bold" },
|
|
371
|
+
function createModuleErrorsComponent(errors, fileName) {
|
|
372
|
+
const errList = [];
|
|
373
|
+
let idx = 1;
|
|
374
|
+
Object.keys(errors).map((key) => {
|
|
375
|
+
const e = errors[key];
|
|
376
|
+
for (let err of e) {
|
|
377
|
+
errList.push({
|
|
378
|
+
type: "VStack",
|
|
379
|
+
props: { gap: "0px" },
|
|
380
|
+
children: [
|
|
381
|
+
{
|
|
382
|
+
type: "HStack",
|
|
383
|
+
props: { gap: "0" },
|
|
384
|
+
children: [
|
|
385
|
+
{
|
|
386
|
+
type: "Text",
|
|
387
|
+
props: {
|
|
388
|
+
value: `#${idx++}: ${fileName} (${err.line}:${err.column}):\xa0`,
|
|
389
|
+
color: "$color-info",
|
|
230
390
|
},
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
const comp = {
|
|
238
|
-
type: "VStack",
|
|
239
|
-
props: { padding: "$padding-normal", gap: 0 },
|
|
240
|
-
children: [
|
|
241
|
-
{
|
|
242
|
-
type: "H1",
|
|
243
|
-
props: {
|
|
244
|
-
value: `${errList.length} ${errList.length > 1 ? "Errors" : "Error"} found while processing XMLUI code-behind script`,
|
|
245
|
-
padding: "$padding-normal",
|
|
246
|
-
backgroundColor: "$color-error",
|
|
247
|
-
color: "white",
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
type: "Text",
|
|
394
|
+
props: { value: ` ${err.text}`, fontWeight: "bold" },
|
|
395
|
+
},
|
|
396
|
+
],
|
|
248
397
|
},
|
|
398
|
+
],
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
const comp = {
|
|
403
|
+
type: "VStack",
|
|
404
|
+
props: { padding: "$padding-normal", gap: 0 },
|
|
405
|
+
children: [
|
|
406
|
+
{
|
|
407
|
+
type: "H1",
|
|
408
|
+
props: {
|
|
409
|
+
value: `${errList.length} ${errList.length > 1 ? "Errors" : "Error"} found while processing XMLUI code-behind script`,
|
|
410
|
+
padding: "$padding-normal",
|
|
411
|
+
backgroundColor: "$color-error",
|
|
412
|
+
color: "white",
|
|
249
413
|
},
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
children: errList,
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
type: "VStack",
|
|
417
|
+
props: {
|
|
418
|
+
gap: "$gap-tight",
|
|
419
|
+
padding: "$padding-normal",
|
|
257
420
|
},
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
}
|
|
262
|
-
const comp = makeComponent();
|
|
263
|
-
comp.component = makeComponent();
|
|
421
|
+
children: errList,
|
|
422
|
+
},
|
|
423
|
+
],
|
|
424
|
+
};
|
|
264
425
|
return comp;
|
|
265
426
|
}
|
|
266
|
-
function
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
}
|
|
427
|
+
function errReportModuleErrors(errors, fileName) {
|
|
428
|
+
const comp = createModuleErrorsComponent(errors, fileName);
|
|
429
|
+
comp.component = createModuleErrorsComponent(errors, fileName);
|
|
430
|
+
return comp;
|
|
431
|
+
}
|
|
432
|
+
/**
|
|
433
|
+
* Converts a position in a string to a line and column number.
|
|
434
|
+
* @param offset the offset of the position in the string
|
|
435
|
+
* @param newlinePositions the offsets of the newlines in the string in ascending order
|
|
436
|
+
*/
|
|
437
|
+
function offsetToPosition(offset, newlinePositions) {
|
|
438
|
+
let left = 0;
|
|
439
|
+
let right = newlinePositions.length;
|
|
440
|
+
while (left < right) {
|
|
441
|
+
const mid = Math.floor((left + right) / 2);
|
|
442
|
+
if (newlinePositions[mid] < offset) {
|
|
443
|
+
left = mid + 1;
|
|
284
444
|
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
err.line = newlinePositions.length + 1;
|
|
288
|
-
err.col = err.pos - lastNewlinePos + 0;
|
|
445
|
+
else {
|
|
446
|
+
right = mid;
|
|
289
447
|
}
|
|
290
448
|
}
|
|
291
|
-
|
|
449
|
+
let line = left + 1;
|
|
450
|
+
let col = left === 0 ? offset + 1 : offset - newlinePositions[left - 1];
|
|
451
|
+
return { line, col };
|
|
292
452
|
}
|
|
293
453
|
function getCompoundCompName(node, getText) {
|
|
294
454
|
var _a, _b, _c, _d, _e, _f;
|
|
@@ -307,3 +467,12 @@ function getCompoundCompName(node, getText) {
|
|
|
307
467
|
}
|
|
308
468
|
return undefined;
|
|
309
469
|
}
|
|
470
|
+
function addDisplayFieldsToErrors(errors, source, newlinePositions) {
|
|
471
|
+
return errors.map((err) => {
|
|
472
|
+
const { line: errPosLine, col: errPosCol } = offsetToPosition(err.pos, newlinePositions);
|
|
473
|
+
const { line: contextStartLine } = offsetToPosition(err.contextPos, newlinePositions);
|
|
474
|
+
return Object.assign(Object.assign({}, err), { errPosLine,
|
|
475
|
+
errPosCol,
|
|
476
|
+
contextStartLine, contextSource: source.substring(err.contextPos, err.contextEnd) });
|
|
477
|
+
});
|
|
478
|
+
}
|
|
@@ -39,7 +39,7 @@ exports.DIAGS = {
|
|
|
39
39
|
unexpectedCloseTag: {
|
|
40
40
|
category: DiagnosticCategory.Error,
|
|
41
41
|
code: ErrCodes.unexpectedCloseTag,
|
|
42
|
-
message: "Read '</', but there's no opening tag to close.
|
|
42
|
+
message: "Read '</', but there's no opening tag to close.",
|
|
43
43
|
},
|
|
44
44
|
expCloseStartWithName: function (openTagName) {
|
|
45
45
|
return {
|