xmlui 0.9.50 → 0.9.52
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/{apiInterceptorWorker-B6XqwxPF.mjs → apiInterceptorWorker-OagsYDXz.mjs} +3 -3
- package/dist/lib/{index-BpQ3DEFQ.mjs → index-BnpxPPve.mjs} +14387 -13003
- package/dist/lib/index.css +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-QekhOD-W.mjs → metadata-utils-4EQ6kQIM.mjs} +7 -7
- package/dist/lib/{server-common-D4BcRpEl.mjs → server-common-C0cF2UTg.mjs} +4542 -4326
- package/dist/lib/{transform-DXcw0gGl.mjs → transform-CgRMkbb0.mjs} +1472 -1440
- package/dist/lib/xmlui-parser.d.ts +84 -62
- package/dist/lib/xmlui-parser.mjs +41 -49
- package/dist/lib/{xmlui-serializer-CAZCkpXP.mjs → xmlui-serializer-EDw51UFN.mjs} +10 -10
- package/dist/lib/xmlui.d.ts +17 -7
- package/dist/lib/xmlui.mjs +19 -18
- package/dist/metadata/apiInterceptorWorker-BOuioN57.mjs +15414 -0
- package/dist/metadata/collectedComponentMetadata-DbptBvJk.mjs +41019 -0
- package/dist/metadata/core-D3puiNN6.mjs +5771 -0
- package/dist/metadata/style.css +1 -1
- package/dist/metadata/wasm-DQxwEHae.mjs +7 -0
- package/dist/metadata/xmlui-metadata.mjs +3 -18371
- package/dist/metadata/xmlui-metadata.umd.js +547 -10
- package/dist/scripts/package.json +5 -7
- package/dist/scripts/src/components/APICall/APICall.js +13 -12
- package/dist/scripts/src/components/APICall/APICallNative.js +5 -0
- package/dist/scripts/src/components/Accordion/Accordion.js +4 -2
- package/dist/scripts/src/components/Accordion/AccordionItem.js +2 -2
- package/dist/scripts/src/components/Accordion/AccordionItemNative.js +6 -2
- package/dist/scripts/src/components/App/App.js +25 -10
- package/dist/scripts/src/components/App/AppNative.js +9 -1
- package/dist/scripts/src/components/AppHeader/AppHeader.js +2 -2
- package/dist/scripts/src/components/AppHeader/AppHeaderNative.js +5 -2
- package/dist/scripts/src/components/AppState/AppState.js +2 -2
- package/dist/scripts/src/components/AppState/AppStateNative.js +5 -1
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +8 -8
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +16 -2
- package/dist/scripts/src/components/Avatar/Avatar.js +4 -2
- package/dist/scripts/src/components/Backdrop/Backdrop.js +2 -2
- package/dist/scripts/src/components/Badge/Badge.js +7 -5
- package/dist/scripts/src/components/Bookmark/Bookmark.js +5 -4
- package/dist/scripts/src/components/Card/Card.js +6 -4
- package/dist/scripts/src/components/ChangeListener/ChangeListener.js +2 -1
- package/dist/scripts/src/components/Charts/BarChart/BarChart.js +76 -0
- package/dist/scripts/src/components/Charts/BarChart/BarChartNative.js +108 -0
- package/dist/scripts/src/components/Charts/DonutChart/DonutChart.js +59 -0
- package/dist/scripts/src/components/Charts/LabelList/LabelList.js +38 -0
- package/dist/scripts/src/components/Charts/LabelList/LabelListNative.js +24 -0
- package/dist/scripts/src/components/Charts/Legend/Legend.js +30 -0
- package/dist/scripts/src/components/Charts/Legend/LegendNative.js +64 -0
- package/dist/scripts/src/components/Charts/LineChart/LineChart.js +53 -0
- package/dist/scripts/src/components/Charts/LineChart/LineChartNative.js +103 -0
- package/dist/scripts/src/components/Charts/PieChart/PieChart.js +58 -0
- package/dist/scripts/src/components/Charts/PieChart/PieChartNative.js +127 -0
- package/dist/scripts/src/components/Charts/Tooltip/TooltipContent.js +27 -0
- package/dist/scripts/src/components/Charts/utils/ChartProvider.js +65 -0
- package/dist/scripts/src/components/Charts/utils/abstractions.js +26 -0
- package/dist/scripts/src/components/CodeBlock/CodeBlock.js +4 -4
- package/dist/scripts/src/components/CodeBlock/CodeBlockNative.js +5 -1
- package/dist/scripts/src/components/Column/Column.js +15 -9
- package/dist/scripts/src/components/Column/ColumnNative.js +5 -0
- package/dist/scripts/src/components/ComponentProvider.js +12 -6
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.js +4 -3
- package/dist/scripts/src/components/DatePicker/DatePicker.js +5 -3
- package/dist/scripts/src/components/EmojiSelector/EmojiSelector.js +1 -1
- package/dist/scripts/src/components/EmojiSelector/EmojiSelectorNative.js +7 -2
- package/dist/scripts/src/components/FileInput/FileInput.js +8 -9
- package/dist/scripts/src/components/FileInput/FileInputNative.js +14 -2
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.js +2 -2
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZoneNative.js +9 -2
- package/dist/scripts/src/components/Footer/Footer.js +1 -0
- package/dist/scripts/src/components/Footer/FooterNative.js +4 -1
- package/dist/scripts/src/components/Form/Form.js +9 -5
- package/dist/scripts/src/components/Form/FormNative.js +2 -1
- package/dist/scripts/src/components/FormItem/FormItem.js +25 -15
- package/dist/scripts/src/components/FormItem/FormItemNative.js +1 -0
- package/dist/scripts/src/components/FormItem/Validations.js +49 -33
- package/dist/scripts/src/components/Heading/Heading.js +5 -4
- package/dist/scripts/src/components/Heading/HeadingNative.js +1 -0
- package/dist/scripts/src/components/Icon/Icon.js +7 -5
- package/dist/scripts/src/components/Image/Image.js +19 -9
- package/dist/scripts/src/components/Image/ImageNative.js +7 -2
- package/dist/scripts/src/components/Items/Items.js +2 -0
- package/dist/scripts/src/components/Items/ItemsNative.js +5 -1
- package/dist/scripts/src/components/Link/Link.js +3 -4
- package/dist/scripts/src/components/Link/LinkNative.js +6 -2
- package/dist/scripts/src/components/List/List.js +12 -11
- package/dist/scripts/src/components/List/ListNative.js +10 -2
- package/dist/scripts/src/components/Logo/Logo.js +7 -0
- package/dist/scripts/src/components/Logo/LogoNative.js +6 -2
- package/dist/scripts/src/components/Markdown/Markdown.js +5 -3
- package/dist/scripts/src/components/Markdown/MarkdownNative.js +24 -76
- package/dist/scripts/src/components/Markdown/utils.js +23 -1
- package/dist/scripts/src/components/ModalDialog/ModalDialog.js +2 -2
- package/dist/scripts/src/components/ModalDialog/ModalDialogNative.js +7 -2
- package/dist/scripts/src/components/NavGroup/NavGroup.js +2 -1
- package/dist/scripts/src/components/NavLink/NavLink.js +5 -7
- package/dist/scripts/src/components/NavLink/NavLinkNative.js +7 -2
- package/dist/scripts/src/components/NavPanel/NavPanel.js +7 -0
- package/dist/scripts/src/components/NavPanel/NavPanelNative.js +6 -3
- package/dist/scripts/src/components/NestedApp/NestedApp.js +16 -4
- package/dist/scripts/src/components/NestedApp/NestedAppNative.js +37 -34
- package/dist/scripts/src/components/NestedApp/defaultProps.js +10 -0
- package/dist/scripts/src/components/NoResult/NoResult.js +6 -2
- package/dist/scripts/src/components/NoResult/NoResultNative.js +8 -3
- package/dist/scripts/src/components/NumberBox/NumberBox.js +8 -6
- package/dist/scripts/src/components/NumberBox/NumberBox2.js +6 -6
- package/dist/scripts/src/components/NumberBox/NumberBox2Native.js +15 -2
- package/dist/scripts/src/components/NumberBox/NumberBoxNative.js +16 -2
- package/dist/scripts/src/components/Option/Option.js +10 -15
- package/dist/scripts/src/components/Option/OptionNative.js +18 -0
- package/dist/scripts/src/components/PageMetaTitle/PageMetaTilteNative.js +6 -2
- package/dist/scripts/src/components/PageMetaTitle/PageMetaTitle.js +4 -1
- package/dist/scripts/src/components/Pages/Pages.js +7 -3
- package/dist/scripts/src/components/Pages/PagesNative.js +5 -0
- package/dist/scripts/src/components/ProgressBar/ProgressBar.js +1 -1
- package/dist/scripts/src/components/ProgressBar/ProgressBarNative.js +5 -2
- package/dist/scripts/src/components/Queue/Queue.js +11 -6
- package/dist/scripts/src/components/Queue/QueueNative.js +7 -1
- package/dist/scripts/src/components/RadioGroup/RadioGroup.js +5 -5
- package/dist/scripts/src/components/RadioGroup/RadioGroupNative.js +9 -2
- package/dist/scripts/src/components/RadioGroup/RadioItem.js +8 -2
- package/dist/scripts/src/components/RadioGroup/RadioItemNative.js +6 -2
- package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapter.js +4 -1
- package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapterNative.js +4 -0
- package/dist/scripts/src/components/Redirect/Redirect.js +8 -2
- package/dist/scripts/src/components/Select/Select.js +21 -12
- package/dist/scripts/src/components/Select/SelectNative.js +15 -2
- package/dist/scripts/src/components/SelectionStore/SelectionStore.js +6 -3
- package/dist/scripts/src/components/SelectionStore/SelectionStoreNative.js +6 -2
- package/dist/scripts/src/components/Slider/Slider.js +28 -9
- package/dist/scripts/src/components/Slider/SliderNative.js +14 -3
- package/dist/scripts/src/components/Spinner/Spinner.js +2 -2
- package/dist/scripts/src/components/Spinner/SpinnerNative.js +6 -2
- package/dist/scripts/src/components/Splitter/Splitter.js +6 -6
- package/dist/scripts/src/components/Splitter/SplitterNative.js +10 -2
- package/dist/scripts/src/components/Stack/Stack.js +4 -4
- package/dist/scripts/src/components/Stack/StackNative.js +8 -2
- package/dist/scripts/src/components/StickyBox/StickyBox.js +1 -1
- package/dist/scripts/src/components/StickyBox/StickyBoxNative.js +7 -1
- package/dist/scripts/src/components/Table/Table.js +15 -14
- package/dist/scripts/src/components/Table/TableNative.js +25 -9
- package/dist/scripts/src/components/TableOfContents/TableOfContents.js +12 -3
- package/dist/scripts/src/components/TableOfContents/TableOfContentsNative.js +6 -2
- package/dist/scripts/src/components/Tabs/Tabs.js +2 -2
- package/dist/scripts/src/components/Tabs/TabsNative.js +7 -2
- package/dist/scripts/src/components/Text/Text.js +14 -12
- package/dist/scripts/src/components/Text/TextNative.js +7 -2
- package/dist/scripts/src/components/TextArea/TextArea.js +8 -5
- package/dist/scripts/src/components/TextArea/TextAreaNative.js +19 -2
- package/dist/scripts/src/components/TextBox/TextBox.js +5 -4
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +14 -2
- package/dist/scripts/src/components/Theme/Theme.js +1 -1
- package/dist/scripts/src/components/Theme/ThemeNative.js +10 -14
- package/dist/scripts/src/components/ToneChangerButton/ToneChangerButton.js +18 -8
- package/dist/scripts/src/components/TreeDisplay/TreeDisplay.js +1 -1
- package/dist/scripts/src/components/TreeDisplay/TreeDisplayNative.js +2 -1
- package/dist/scripts/src/components/ValidationSummary/ValidationSummary.js +3 -57
- package/dist/scripts/src/components/ValidationSummary/ValidationSummaryNative.js +64 -0
- package/dist/scripts/src/components/metadata-helpers.js +11 -8
- package/dist/scripts/src/components-core/InspectorContext.js +0 -4
- package/dist/scripts/src/components-core/interception/ApiInterceptor.js +1 -1
- package/dist/scripts/src/components-core/interception/ApiInterceptorProvider.js +6 -2
- package/dist/scripts/src/components-core/loader/DataLoader.js +1 -1
- package/dist/scripts/src/components-core/loader/Loader.js +7 -3
- package/dist/scripts/src/components-core/theming/themes/palette.js +5 -4
- package/dist/scripts/src/components-core/theming/themes/root.js +5 -4
- package/dist/scripts/src/components-core/theming/transformThemeVars.js +1 -17
- package/dist/scripts/src/parsers/xmlui-parser/diagnostics.js +92 -48
- package/dist/scripts/src/parsers/xmlui-parser/parser.js +179 -189
- package/dist/standalone/xmlui-standalone.es.d.ts +0 -2580
- package/dist/standalone/xmlui-standalone.umd.js +275 -305
- package/package.json +5 -7
|
@@ -7,42 +7,11 @@ const scanner_1 = require("./scanner");
|
|
|
7
7
|
const syntax_kind_1 = require("./syntax-kind");
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
9
|
const diagnostics_1 = require("./diagnostics");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
message: `Attribute name '${attrName}' cannot start with an uppercase letter.`,
|
|
16
|
-
};
|
|
17
|
-
},
|
|
18
|
-
duplAttr: function (attrName) {
|
|
19
|
-
return {
|
|
20
|
-
category: diagnostics_1.DiagnosticCategory.Error,
|
|
21
|
-
code: diagnostics_1.ErrCodes.duplAttr,
|
|
22
|
-
message: `Duplicated attribute: '${attrName}'.`,
|
|
23
|
-
};
|
|
24
|
-
},
|
|
25
|
-
tagNameMismatch: function (openTagName, closeTagName) {
|
|
26
|
-
return {
|
|
27
|
-
category: diagnostics_1.DiagnosticCategory.Error,
|
|
28
|
-
code: diagnostics_1.ErrCodes.tagNameMismatch,
|
|
29
|
-
message: `Opening and closing tag names should match. Opening tag has a name '${openTagName}', but the closing tag name is '${closeTagName}'.`,
|
|
30
|
-
};
|
|
31
|
-
},
|
|
32
|
-
invalidChar: function (char) {
|
|
33
|
-
return {
|
|
34
|
-
category: diagnostics_1.DiagnosticCategory.Error,
|
|
35
|
-
code: diagnostics_1.ErrCodes.invalidChar,
|
|
36
|
-
message: `Invalid character '${char}'.`,
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
const firstSetTagLike = [syntax_kind_1.SyntaxKind.CData, syntax_kind_1.SyntaxKind.Script, syntax_kind_1.SyntaxKind.OpenNodeStart];
|
|
41
|
-
// todo
|
|
42
|
-
// const firstSetContent = firstSetTagLike.concat ([
|
|
43
|
-
// SyntaxKind.Identifier,
|
|
44
|
-
// SyntaxKind.StringLiteral,
|
|
45
|
-
// ])
|
|
10
|
+
const RECOVER_FILE = [syntax_kind_1.SyntaxKind.CData, syntax_kind_1.SyntaxKind.Script, syntax_kind_1.SyntaxKind.OpenNodeStart];
|
|
11
|
+
const RECOVER_OPEN_TAG = [syntax_kind_1.SyntaxKind.OpenNodeStart, syntax_kind_1.SyntaxKind.NodeEnd, syntax_kind_1.SyntaxKind.NodeClose, syntax_kind_1.SyntaxKind.CloseNodeStart, syntax_kind_1.SyntaxKind.CData, syntax_kind_1.SyntaxKind.Script];
|
|
12
|
+
const RECOVER_ATTR = [syntax_kind_1.SyntaxKind.Identifier, ...RECOVER_OPEN_TAG];
|
|
13
|
+
const RECOVER_CONTENT_LIST = [syntax_kind_1.SyntaxKind.TextNode, syntax_kind_1.SyntaxKind.StringLiteral, syntax_kind_1.SyntaxKind.CData, syntax_kind_1.SyntaxKind.Script, syntax_kind_1.SyntaxKind.OpenNodeStart, syntax_kind_1.SyntaxKind.CloseNodeStart];
|
|
14
|
+
const RECOVER_CLOSE_TAG = [syntax_kind_1.SyntaxKind.NodeEnd, syntax_kind_1.SyntaxKind.OpenNodeStart, syntax_kind_1.SyntaxKind.CloseNodeStart, syntax_kind_1.SyntaxKind.CData, syntax_kind_1.SyntaxKind.Script];
|
|
46
15
|
function createXmlUiParser(source) {
|
|
47
16
|
return {
|
|
48
17
|
parse: () => parseXmlUiMarkup(source),
|
|
@@ -62,24 +31,52 @@ function parseXmlUiMarkup(text) {
|
|
|
62
31
|
};
|
|
63
32
|
};
|
|
64
33
|
const scanner = (0, scanner_1.createScanner)(false, text, onScannerErr);
|
|
34
|
+
const fileContentListNode = parseFile();
|
|
35
|
+
return { node: fileContentListNode, errors };
|
|
65
36
|
function getText(n, ignoreTrivia = true) {
|
|
66
37
|
return text.substring(ignoreTrivia ? n.pos : n.start, n.end);
|
|
67
38
|
}
|
|
68
|
-
function
|
|
39
|
+
function parseFile() {
|
|
40
|
+
while (true) {
|
|
41
|
+
const token = peekInContent();
|
|
42
|
+
switch (token.kind) {
|
|
43
|
+
case syntax_kind_1.SyntaxKind.EndOfFileToken:
|
|
44
|
+
bumpAny();
|
|
45
|
+
return createNode(syntax_kind_1.SyntaxKind.ContentListNode, node.children);
|
|
46
|
+
case syntax_kind_1.SyntaxKind.CData:
|
|
47
|
+
case syntax_kind_1.SyntaxKind.Script:
|
|
48
|
+
bumpAny();
|
|
49
|
+
break;
|
|
50
|
+
case syntax_kind_1.SyntaxKind.OpenNodeStart:
|
|
51
|
+
parseOpeningTag();
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
const errNode = errNodeUntil(RECOVER_FILE);
|
|
55
|
+
errorAt(diagnostics_1.DIAGS.expTagOpen, errNode.pos, errNode.end);
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function parseContentList() {
|
|
69
61
|
startNode();
|
|
70
62
|
loop: while (true) {
|
|
71
63
|
const token = peekInContent();
|
|
72
64
|
switch (token.kind) {
|
|
73
65
|
case syntax_kind_1.SyntaxKind.TextNode:
|
|
74
66
|
case syntax_kind_1.SyntaxKind.StringLiteral:
|
|
75
|
-
|
|
67
|
+
case syntax_kind_1.SyntaxKind.CData:
|
|
68
|
+
case syntax_kind_1.SyntaxKind.Script:
|
|
69
|
+
bumpAny();
|
|
70
|
+
break;
|
|
71
|
+
case syntax_kind_1.SyntaxKind.OpenNodeStart:
|
|
72
|
+
parseOpeningTag();
|
|
76
73
|
break;
|
|
77
74
|
case syntax_kind_1.SyntaxKind.CloseNodeStart:
|
|
78
|
-
break loop;
|
|
79
75
|
case syntax_kind_1.SyntaxKind.EndOfFileToken:
|
|
80
76
|
break loop;
|
|
81
77
|
default:
|
|
82
|
-
|
|
78
|
+
const errNode = errNodeUntil(RECOVER_CONTENT_LIST);
|
|
79
|
+
errorAt(diagnostics_1.DIAGS.expTagOpen, errNode.pos, errNode.end);
|
|
83
80
|
break;
|
|
84
81
|
}
|
|
85
82
|
}
|
|
@@ -90,45 +87,23 @@ function parseXmlUiMarkup(text) {
|
|
|
90
87
|
abandonNode();
|
|
91
88
|
}
|
|
92
89
|
}
|
|
93
|
-
function
|
|
94
|
-
while (true) {
|
|
95
|
-
const token = peekInContent();
|
|
96
|
-
switch (token.kind) {
|
|
97
|
-
case syntax_kind_1.SyntaxKind.EndOfFileToken:
|
|
98
|
-
bumpAny();
|
|
99
|
-
return;
|
|
100
|
-
default:
|
|
101
|
-
parseTagLike();
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function parseTagLike() {
|
|
107
|
-
if (!eat(syntax_kind_1.SyntaxKind.CData) && !eat(syntax_kind_1.SyntaxKind.Script)) {
|
|
108
|
-
if (at(syntax_kind_1.SyntaxKind.OpenNodeStart)) {
|
|
109
|
-
parseTag();
|
|
110
|
-
}
|
|
111
|
-
else {
|
|
112
|
-
errorAndBump(diagnostics_1.Diag_OpenNodeStart_Token_Expected);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function parseTag() {
|
|
90
|
+
function parseOpeningTag() {
|
|
117
91
|
startNode();
|
|
118
92
|
bump(syntax_kind_1.SyntaxKind.OpenNodeStart);
|
|
119
|
-
let errInName =
|
|
120
|
-
let openTagName =
|
|
93
|
+
let errInName = true;
|
|
94
|
+
let openTagName = null;
|
|
121
95
|
if (at(syntax_kind_1.SyntaxKind.Identifier)) {
|
|
122
|
-
|
|
96
|
+
const tagNameParseRes = parseOpeningTagName();
|
|
97
|
+
errInName = tagNameParseRes.errInName;
|
|
98
|
+
openTagName = tagNameParseRes.node;
|
|
123
99
|
}
|
|
124
100
|
else {
|
|
125
|
-
|
|
126
|
-
const errNode = errNodeUntil([syntax_kind_1.SyntaxKind.OpenNodeStart, syntax_kind_1.SyntaxKind.NodeEnd, syntax_kind_1.SyntaxKind.NodeClose, syntax_kind_1.SyntaxKind.CloseNodeStart, syntax_kind_1.SyntaxKind.CData, syntax_kind_1.SyntaxKind.Script]);
|
|
101
|
+
const errNode = errNodeUntil(RECOVER_OPEN_TAG);
|
|
127
102
|
if (errNode) {
|
|
128
|
-
errorAt(diagnostics_1.
|
|
103
|
+
errorAt(diagnostics_1.DIAGS.expTagName, errNode.pos, errNode.end);
|
|
129
104
|
}
|
|
130
105
|
else {
|
|
131
|
-
error(diagnostics_1.
|
|
106
|
+
error(diagnostics_1.DIAGS.expTagName);
|
|
132
107
|
}
|
|
133
108
|
}
|
|
134
109
|
if (!errInName) {
|
|
@@ -142,73 +117,48 @@ function parseXmlUiMarkup(text) {
|
|
|
142
117
|
}
|
|
143
118
|
case syntax_kind_1.SyntaxKind.NodeEnd: {
|
|
144
119
|
bumpAny();
|
|
145
|
-
|
|
146
|
-
parseClosingTag(openTagName);
|
|
120
|
+
parseContentList();
|
|
121
|
+
parseClosingTag(openTagName, errInName);
|
|
147
122
|
completeNode(syntax_kind_1.SyntaxKind.ElementNode);
|
|
148
123
|
return;
|
|
149
124
|
}
|
|
150
|
-
|
|
151
|
-
case syntax_kind_1.SyntaxKind.Script:
|
|
152
|
-
case syntax_kind_1.SyntaxKind.CData: {
|
|
153
|
-
completeNode(syntax_kind_1.SyntaxKind.ElementNode);
|
|
154
|
-
error(diagnostics_1.Diag_End_Or_Close_Token_Expected);
|
|
155
|
-
return;
|
|
156
|
-
}
|
|
157
|
-
case syntax_kind_1.SyntaxKind.CloseNodeStart: {
|
|
158
|
-
error(diagnostics_1.Diag_End_Or_Close_Token_Expected);
|
|
159
|
-
parseClosingTag(openTagName);
|
|
125
|
+
default: {
|
|
160
126
|
completeNode(syntax_kind_1.SyntaxKind.ElementNode);
|
|
127
|
+
error(diagnostics_1.DIAGS.expEndOrClose);
|
|
161
128
|
return;
|
|
162
129
|
}
|
|
163
|
-
default: {
|
|
164
|
-
error(diagnostics_1.Diag_End_Or_Close_Token_Expected);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
function parseClosingTag(openTagName) {
|
|
169
|
-
if (eat(syntax_kind_1.SyntaxKind.CloseNodeStart)) {
|
|
170
|
-
if (at(syntax_kind_1.SyntaxKind.Identifier)) {
|
|
171
|
-
const closeTagName = parseTagName();
|
|
172
|
-
const namesMismatch = openTagName !== undefined && !(0, utils_1.tagNameNodesWithoutErrorsMatch)(openTagName, closeTagName, getText);
|
|
173
|
-
if (namesMismatch) {
|
|
174
|
-
error(MakeErr.tagNameMismatch(getText(openTagName), getText(closeTagName)));
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
errRecover(diagnostics_1.Diag_Tag_Identifier_Expected, [syntax_kind_1.SyntaxKind.NodeEnd]);
|
|
179
|
-
}
|
|
180
|
-
if (!eat(syntax_kind_1.SyntaxKind.NodeEnd)) {
|
|
181
|
-
error(diagnostics_1.Diag_End_Token_Expected);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
error(diagnostics_1.Diag_CloseNodeStart_Token_Expected);
|
|
186
130
|
}
|
|
187
131
|
}
|
|
188
|
-
function
|
|
132
|
+
function parseOpeningTagName() {
|
|
189
133
|
startNode();
|
|
190
134
|
bump(syntax_kind_1.SyntaxKind.Identifier);
|
|
191
|
-
if (eat(syntax_kind_1.SyntaxKind.Colon)) {
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
135
|
+
if (eat(syntax_kind_1.SyntaxKind.Colon) && !eat(syntax_kind_1.SyntaxKind.Identifier)) {
|
|
136
|
+
const nameNodeWithColon = completeNode(syntax_kind_1.SyntaxKind.TagNameNode);
|
|
137
|
+
errorAt(diagnostics_1.DIAGS.expTagNameAfterNamespace, nameNodeWithColon.pos, nameNodeWithColon.end);
|
|
138
|
+
errNodeUntil([syntax_kind_1.SyntaxKind.Identifier, ...RECOVER_OPEN_TAG]);
|
|
139
|
+
return { node: nameNodeWithColon, errInName: true };
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
return { node: completeNode(syntax_kind_1.SyntaxKind.TagNameNode), errInName: false };
|
|
195
143
|
}
|
|
196
|
-
return completeNode(syntax_kind_1.SyntaxKind.TagNameNode);
|
|
197
144
|
}
|
|
198
145
|
function parseAttrList() {
|
|
199
146
|
startNode();
|
|
200
147
|
const attrNames = [];
|
|
201
|
-
while (
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
148
|
+
loop: while (true) {
|
|
149
|
+
switch (peek().kind) {
|
|
150
|
+
case syntax_kind_1.SyntaxKind.EndOfFileToken:
|
|
151
|
+
// same as RECOVER_OPEN_TAG
|
|
152
|
+
case syntax_kind_1.SyntaxKind.OpenNodeStart:
|
|
153
|
+
case syntax_kind_1.SyntaxKind.NodeEnd:
|
|
154
|
+
case syntax_kind_1.SyntaxKind.NodeClose:
|
|
155
|
+
case syntax_kind_1.SyntaxKind.CloseNodeStart:
|
|
156
|
+
case syntax_kind_1.SyntaxKind.CData:
|
|
157
|
+
case syntax_kind_1.SyntaxKind.Script:
|
|
158
|
+
break loop;
|
|
159
|
+
default:
|
|
160
|
+
parseAttr(attrNames);
|
|
161
|
+
}
|
|
212
162
|
}
|
|
213
163
|
if (node.children.length === 0) {
|
|
214
164
|
abandonNode();
|
|
@@ -223,101 +173,118 @@ function parseXmlUiMarkup(text) {
|
|
|
223
173
|
parseAttrName(attrNames);
|
|
224
174
|
}
|
|
225
175
|
else {
|
|
226
|
-
const
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
176
|
+
const errNode = errNodeUntil(RECOVER_ATTR);
|
|
177
|
+
if (errNode) {
|
|
178
|
+
errorAt(diagnostics_1.DIAGS.expAttrName, errNode.pos, errNode.end);
|
|
179
|
+
completeNode(syntax_kind_1.SyntaxKind.AttributeNode);
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
abandonNode();
|
|
183
|
+
error(diagnostics_1.DIAGS.expAttrName);
|
|
230
184
|
}
|
|
185
|
+
return;
|
|
231
186
|
}
|
|
232
187
|
if (eat(syntax_kind_1.SyntaxKind.Equal)) {
|
|
233
188
|
if (!eat(syntax_kind_1.SyntaxKind.StringLiteral)) {
|
|
234
|
-
const
|
|
235
|
-
|
|
189
|
+
const errNode = errNodeUntil(RECOVER_ATTR);
|
|
190
|
+
if (errNode) {
|
|
191
|
+
errorAt(diagnostics_1.DIAGS.expAttrStr, errNode.pos, errNode.end);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
error(diagnostics_1.DIAGS.expAttrStr);
|
|
195
|
+
}
|
|
236
196
|
}
|
|
237
197
|
}
|
|
238
198
|
completeNode(syntax_kind_1.SyntaxKind.AttributeNode);
|
|
239
199
|
}
|
|
240
200
|
function parseAttrName(attrNames) {
|
|
241
|
-
|
|
201
|
+
let nameIdent = peek();
|
|
242
202
|
let nsIdent = undefined;
|
|
243
203
|
startNode();
|
|
244
204
|
bump(syntax_kind_1.SyntaxKind.Identifier);
|
|
245
205
|
if (eat(syntax_kind_1.SyntaxKind.Colon)) {
|
|
246
206
|
if (at(syntax_kind_1.SyntaxKind.Identifier)) {
|
|
247
|
-
nsIdent =
|
|
207
|
+
nsIdent = nameIdent;
|
|
208
|
+
nameIdent = bump(syntax_kind_1.SyntaxKind.Identifier);
|
|
248
209
|
}
|
|
249
210
|
else {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
211
|
+
const errNode = errNodeUntil([syntax_kind_1.SyntaxKind.Equal, syntax_kind_1.SyntaxKind.Identifier, ...RECOVER_OPEN_TAG]);
|
|
212
|
+
if (errNode) {
|
|
213
|
+
errorAt(diagnostics_1.DIAGS.expAttrNameAfterNamespace, errNode.pos, errNode.end);
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
error(diagnostics_1.DIAGS.expAttrNameAfterNamespace);
|
|
217
|
+
}
|
|
255
218
|
}
|
|
256
219
|
}
|
|
257
220
|
checkAttrName(attrNames, { nsIdent, nameIdent });
|
|
258
221
|
completeNode(syntax_kind_1.SyntaxKind.AttributeKeyNode);
|
|
259
222
|
}
|
|
223
|
+
function parseClosingTag(openTagName, skipNameMatching) {
|
|
224
|
+
if (eat(syntax_kind_1.SyntaxKind.CloseNodeStart)) {
|
|
225
|
+
if (at(syntax_kind_1.SyntaxKind.Identifier)) {
|
|
226
|
+
const closeTagName = parseClosingTagName();
|
|
227
|
+
if (!skipNameMatching) {
|
|
228
|
+
const namesMismatch = openTagName !== null && !(0, utils_1.tagNameNodesWithoutErrorsMatch)(openTagName, closeTagName, getText);
|
|
229
|
+
if (namesMismatch) {
|
|
230
|
+
const msg = diagnostics_1.DIAGS.tagNameMismatch(getText(openTagName), getText(closeTagName));
|
|
231
|
+
errorAt(msg, closeTagName.pos, closeTagName.end);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
const errNode = errNodeUntil(RECOVER_CLOSE_TAG);
|
|
237
|
+
if (errNode) {
|
|
238
|
+
errorAt(diagnostics_1.DIAGS.expTagName, errNode.pos, errNode.end);
|
|
239
|
+
}
|
|
240
|
+
else {
|
|
241
|
+
error(diagnostics_1.DIAGS.expTagName);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
if (!eat(syntax_kind_1.SyntaxKind.NodeEnd)) {
|
|
245
|
+
error(diagnostics_1.DIAGS.expEnd);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
if (openTagName) {
|
|
250
|
+
errorAt(diagnostics_1.DIAGS.expCloseStartWithName(getText(openTagName)), openTagName.pos, openTagName.end);
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
error(diagnostics_1.DIAGS.expCloseStart);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
function parseClosingTagName() {
|
|
258
|
+
startNode();
|
|
259
|
+
bump(syntax_kind_1.SyntaxKind.Identifier);
|
|
260
|
+
if (eat(syntax_kind_1.SyntaxKind.Colon) && !eat(syntax_kind_1.SyntaxKind.Identifier)) {
|
|
261
|
+
const nameNodeWithColon = completeNode(syntax_kind_1.SyntaxKind.TagNameNode);
|
|
262
|
+
errorAt(diagnostics_1.DIAGS.expTagNameAfterNamespace, nameNodeWithColon.pos, nameNodeWithColon.end);
|
|
263
|
+
errNodeUntil(RECOVER_OPEN_TAG);
|
|
264
|
+
return nameNodeWithColon;
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
return completeNode(syntax_kind_1.SyntaxKind.TagNameNode);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
260
270
|
/** emits errors when the attribute name is incorrect. Otherwise adds the attribute name to the list of valid names*/
|
|
261
271
|
function checkAttrName(attrNames, { nameIdent, nsIdent }) {
|
|
262
272
|
const attrName = getText(nameIdent);
|
|
263
|
-
const attrNs = nsIdent
|
|
273
|
+
const attrNs = nsIdent && getText(nsIdent);
|
|
264
274
|
const attrKeyMatches = ({ ns, name }) => name === attrName && ns === attrNs;
|
|
265
275
|
const isDuplicate = attrNames.findIndex(attrKeyMatches) !== -1;
|
|
266
276
|
const nameStartsWithUppercase = "A" <= attrName[0] && attrName[0] <= "Z";
|
|
267
277
|
const faultyName = isDuplicate || nameStartsWithUppercase;
|
|
278
|
+
//TODO: account for the namespace as well
|
|
268
279
|
if (isDuplicate) {
|
|
269
|
-
errorAt(
|
|
280
|
+
errorAt(diagnostics_1.DIAGS.duplAttr(attrName), nameIdent.pos, nameIdent.end);
|
|
270
281
|
}
|
|
271
|
-
if (nameStartsWithUppercase) {
|
|
272
|
-
errorAt(
|
|
282
|
+
if (!nsIdent && nameStartsWithUppercase) {
|
|
283
|
+
errorAt(diagnostics_1.DIAGS.uppercaseAttr(attrName), nameIdent.pos, nameIdent.end);
|
|
273
284
|
}
|
|
274
285
|
if (!faultyName) {
|
|
275
|
-
attrNames.push({ name: attrName });
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
function at(kindToCheck) {
|
|
279
|
-
return peek().kind === kindToCheck;
|
|
280
|
-
}
|
|
281
|
-
function eat(kind) {
|
|
282
|
-
const kindMatched = at(kind);
|
|
283
|
-
if (kindMatched) {
|
|
284
|
-
bumpAny();
|
|
286
|
+
attrNames.push({ name: attrName, ns: attrNs });
|
|
285
287
|
}
|
|
286
|
-
return kindMatched;
|
|
287
|
-
}
|
|
288
|
-
function atAnyOf(kinds) {
|
|
289
|
-
return kinds.includes(peek().kind);
|
|
290
|
-
}
|
|
291
|
-
function errNodeUntil(tokens) {
|
|
292
|
-
startNode();
|
|
293
|
-
advance(tokens);
|
|
294
|
-
if (node.children.length === 0) {
|
|
295
|
-
abandonNode();
|
|
296
|
-
return null;
|
|
297
|
-
}
|
|
298
|
-
else {
|
|
299
|
-
return completeNode(syntax_kind_1.SyntaxKind.ErrorNode);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* report an error and skip the next token if it isn't in the recoveryTokens. EoF isn't skipped.
|
|
304
|
-
* @param recoveryTokens the [FollowSet](https://www.geeksforgeeks.org/follow-set-in-syntax-analysis/) of the parsed InnerNode. These tokens (or the EoF token) won't be skipped
|
|
305
|
-
* @returns true if the current token is in the recovery set or EoF
|
|
306
|
-
* */
|
|
307
|
-
function errRecover(errCodeAndMsg, recoveryTokens) {
|
|
308
|
-
if (atAnyOf(recoveryTokens) || at(syntax_kind_1.SyntaxKind.EndOfFileToken)) {
|
|
309
|
-
error(errCodeAndMsg);
|
|
310
|
-
return true;
|
|
311
|
-
}
|
|
312
|
-
startNode();
|
|
313
|
-
error(errCodeAndMsg);
|
|
314
|
-
bumpAny();
|
|
315
|
-
completeNode(syntax_kind_1.SyntaxKind.ErrorNode);
|
|
316
|
-
return false;
|
|
317
|
-
}
|
|
318
|
-
/** Bumps over the next token and marks it as an error node while adding an error to the error list*/
|
|
319
|
-
function errorAndBump(errCodeAndMsg) {
|
|
320
|
-
errRecover(errCodeAndMsg, []);
|
|
321
288
|
}
|
|
322
289
|
function error({ code, message, category }) {
|
|
323
290
|
const { pos, end } = peek();
|
|
@@ -338,9 +305,35 @@ function parseXmlUiMarkup(text) {
|
|
|
338
305
|
end,
|
|
339
306
|
});
|
|
340
307
|
}
|
|
308
|
+
/**
|
|
309
|
+
*
|
|
310
|
+
* @param tokens that won't be consumed
|
|
311
|
+
* @returns the error node with the consumed tokens, or null if there were no tokens consumed
|
|
312
|
+
*/
|
|
313
|
+
function errNodeUntil(tokens) {
|
|
314
|
+
startNode();
|
|
315
|
+
advance(tokens);
|
|
316
|
+
if (node.children.length === 0) {
|
|
317
|
+
abandonNode();
|
|
318
|
+
return null;
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
return completeNode(syntax_kind_1.SyntaxKind.ErrorNode);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
341
324
|
function advance(to) {
|
|
342
325
|
for (let token = peek(); token.kind !== syntax_kind_1.SyntaxKind.EndOfFileToken && !to.includes(token.kind); bumpAny(), token = peek()) { }
|
|
343
326
|
}
|
|
327
|
+
function eat(kind) {
|
|
328
|
+
const kindMatched = at(kind);
|
|
329
|
+
if (kindMatched) {
|
|
330
|
+
bumpAny();
|
|
331
|
+
}
|
|
332
|
+
return kindMatched;
|
|
333
|
+
}
|
|
334
|
+
function at(kindToCheck) {
|
|
335
|
+
return peek().kind === kindToCheck;
|
|
336
|
+
}
|
|
344
337
|
function peek(inContent = false) {
|
|
345
338
|
if (peekedToken !== undefined) {
|
|
346
339
|
return peekedToken;
|
|
@@ -480,7 +473,7 @@ function parseXmlUiMarkup(text) {
|
|
|
480
473
|
if (errFromScanner !== undefined) {
|
|
481
474
|
let err;
|
|
482
475
|
if (errFromScanner.message.code === diagnostics_1.ErrCodes.invalidChar) {
|
|
483
|
-
err =
|
|
476
|
+
err = diagnostics_1.DIAGS.invalidChar(scanner.getTokenText());
|
|
484
477
|
}
|
|
485
478
|
else {
|
|
486
479
|
err = errFromScanner.message;
|
|
@@ -536,9 +529,6 @@ function parseXmlUiMarkup(text) {
|
|
|
536
529
|
node = parentNode;
|
|
537
530
|
parents.pop();
|
|
538
531
|
}
|
|
539
|
-
parseSourceContent();
|
|
540
|
-
const completedNode = createNode(syntax_kind_1.SyntaxKind.ContentListNode, node.children);
|
|
541
|
-
return { node: completedNode, errors };
|
|
542
532
|
}
|
|
543
533
|
function createNode(kind, children) {
|
|
544
534
|
const firstChild = children[0];
|