xmlui 0.10.13 → 0.10.15
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-Db5iQkFp.mjs → index-axjeT2uJ.mjs} +1626 -1080
- package/dist/lib/index.css +1 -1
- package/dist/lib/{initMock-B9LtmFJG.mjs → initMock-BoTWMs19.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-D90qqMGc.mjs → metadata-utils-CtY0QcvH.mjs} +2 -1
- package/dist/lib/{server-common-lmBDLpUh.mjs → server-common-Cine5nRR.mjs} +1 -1
- package/dist/lib/xmlui.d.ts +99 -6
- package/dist/lib/xmlui.mjs +78 -42
- package/dist/metadata/{collectedComponentMetadata-BN8eg9Gr.mjs → collectedComponentMetadata-CQywuPDB.mjs} +17448 -16984
- package/dist/metadata/{initMock-J7pN8owj.mjs → initMock-Bi5kF5Af.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 +3 -3
- package/dist/scripts/bin/build-lib.js +21 -13
- package/dist/scripts/bin/viteConfig.js +3 -1
- package/dist/scripts/package.json +2 -3
- package/dist/scripts/src/abstractions/scripting/Token.js +2 -0
- package/dist/scripts/src/abstractions/scripting/TryScope.js +2 -0
- package/dist/scripts/src/abstractions/scripting/modules.js +2 -0
- package/dist/scripts/src/components/APICall/APICall.spec.js +910 -0
- package/dist/scripts/src/components/Accordion/Accordion.spec.js +969 -0
- package/dist/scripts/src/components/Animation/Animation.js +50 -0
- package/dist/scripts/src/components/App/App.spec.js +219 -0
- package/dist/scripts/src/components/AppHeader/AppHeader.spec.js +169 -0
- package/dist/scripts/src/components/AppState/AppState.js +32 -2
- package/dist/scripts/src/components/AppState/AppState.spec.js +268 -0
- package/dist/scripts/src/components/AppState/AppStateNative.js +27 -3
- package/dist/scripts/src/components/AutoComplete/AutoComplete.spec.js +383 -0
- package/dist/scripts/src/components/Avatar/Avatar.spec.js +1543 -0
- package/dist/scripts/src/components/Backdrop/Backdrop.spec.js +131 -0
- package/dist/scripts/src/components/Badge/Badge.spec.js +2214 -0
- package/dist/scripts/src/components/Bookmark/Bookmark.spec.js +230 -0
- package/dist/scripts/src/components/Breakout/Breakout.spec.js +56 -0
- package/dist/scripts/src/components/Button/Button-style.spec.js +274 -0
- package/dist/scripts/src/components/Button/Button.js +5 -1
- package/dist/scripts/src/components/Button/Button.spec.js +454 -0
- package/dist/scripts/src/components/Card/Card.spec.js +150 -0
- package/dist/scripts/src/components/Carousel/Carousel.spec.js +343 -0
- package/dist/scripts/src/components/Carousel/CarouselNative.js +2 -2
- package/dist/scripts/src/components/ChangeListener/ChangeListener.spec.js +169 -0
- package/dist/scripts/src/components/Charts/AreaChart/AreaChart.spec.js +999 -0
- package/dist/scripts/src/components/Charts/BarChart/BarChart.spec.js +597 -0
- package/dist/scripts/src/components/Charts/DonutChart/DonutChart.spec.js +608 -0
- package/dist/scripts/src/components/Charts/LabelList/LabelList.spec.js +539 -0
- package/dist/scripts/src/components/Charts/Legend/Legend.spec.js +558 -0
- package/dist/scripts/src/components/Charts/LineChart/LineChart.spec.js +450 -0
- package/dist/scripts/src/components/Charts/PieChart/PieChart.spec.js +584 -0
- package/dist/scripts/src/components/Charts/PieChart/PieChartNative.js +41 -2
- package/dist/scripts/src/components/Charts/RadarChart/RadarChart.spec.js +571 -0
- package/dist/scripts/src/components/Charts/Tooltip/TooltipContent.spec.js +449 -0
- package/dist/scripts/src/components/Checkbox/Checkbox.spec.js +964 -0
- package/dist/scripts/src/components/CodeBlock/CodeBlock.spec.js +196 -0
- package/dist/scripts/src/components/ColorPicker/ColorPicker.spec.js +283 -0
- package/dist/scripts/src/components/ColorPicker/ColorPickerNative.js +9 -26
- package/dist/scripts/src/components/Column/doc-resources/list-component-data.js +53 -0
- package/dist/scripts/src/components/ComponentProvider.js +6 -2
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.spec.js +338 -0
- package/dist/scripts/src/components/DateInput/DateInput.spec.js +918 -0
- package/dist/scripts/src/components/DatePicker/DatePicker.spec.js +362 -0
- package/dist/scripts/src/components/DatePicker/DatePickerNative.js +3 -3
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.spec.js +331 -0
- package/dist/scripts/src/components/DropdownMenu/DropdownMenuNative.js +7 -9
- package/dist/scripts/src/components/EmojiSelector/EmojiSelector.spec.js +29 -0
- package/dist/scripts/src/components/ExpandableItem/ExpandableItem.spec.js +435 -0
- package/dist/scripts/src/components/FileInput/FileInput.spec.js +249 -0
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZone.spec.js +296 -0
- package/dist/scripts/src/components/FlowLayout/FlowLayout.spec.js +518 -0
- package/dist/scripts/src/components/Footer/Footer.spec.js +991 -0
- package/dist/scripts/src/components/Form/Form.spec.js +1257 -0
- package/dist/scripts/src/components/FormItem/FormItem.spec.js +723 -0
- package/dist/scripts/src/components/FormItem/ItemWithLabel.js +3 -3
- package/dist/scripts/src/components/FormSection/FormSection.js +6 -31
- package/dist/scripts/src/components/Fragment/Fragment.spec.js +50 -0
- package/dist/scripts/src/components/Heading/H1.spec.js +66 -0
- package/dist/scripts/src/components/Heading/H2.spec.js +66 -0
- package/dist/scripts/src/components/Heading/H3.spec.js +66 -0
- package/dist/scripts/src/components/Heading/H4.spec.js +66 -0
- package/dist/scripts/src/components/Heading/H5.spec.js +66 -0
- package/dist/scripts/src/components/Heading/H6.spec.js +66 -0
- package/dist/scripts/src/components/Heading/Heading.spec.js +897 -0
- package/dist/scripts/src/components/HtmlTags/HtmlTags.spec.js +69 -0
- package/dist/scripts/src/components/IFrame/IFrame.spec.js +527 -0
- package/dist/scripts/src/components/Icon/ArrowDropDown.js +11 -0
- package/dist/scripts/src/components/Icon/ArrowDropUp.js +11 -0
- package/dist/scripts/src/components/Icon/ArrowLeft.js +11 -0
- package/dist/scripts/src/components/Icon/ArrowRight.js +11 -0
- package/dist/scripts/src/components/Icon/ChevronDownIcon.js +7 -0
- package/dist/scripts/src/components/Icon/ChevronUpIcon.js +7 -0
- package/dist/scripts/src/components/Icon/Icon.spec.js +527 -0
- package/dist/scripts/src/components/Icon/SunIcon.js +10 -0
- package/dist/scripts/src/components/Image/Image.js +2 -1
- package/dist/scripts/src/components/Image/Image.spec.js +198 -0
- package/dist/scripts/src/components/Image/ImageNative.js +30 -2
- package/dist/scripts/src/components/Input/InputLabel.js +25 -0
- package/dist/scripts/src/components/Input/index.js +5 -0
- package/dist/scripts/src/components/Items/Items.spec.js +397 -0
- package/dist/scripts/src/components/Link/Link.spec.js +894 -0
- package/dist/scripts/src/components/List/List.spec.js +927 -0
- package/dist/scripts/src/components/List/doc-resources/list-component-data.js +53 -0
- package/dist/scripts/src/components/Markdown/Markdown.spec.js +188 -0
- package/dist/scripts/src/components/ModalDialog/ModalDialog.spec.js +162 -0
- package/dist/scripts/src/components/NavGroup/NavGroup.spec.js +212 -0
- package/dist/scripts/src/components/NavGroup/NavGroupNative.js +15 -7
- package/dist/scripts/src/components/NavLink/NavLink.spec.js +864 -0
- package/dist/scripts/src/components/NavPanel/NavPanel.spec.js +864 -0
- package/dist/scripts/src/components/NoResult/NoResult.spec.js +863 -0
- package/dist/scripts/src/components/NumberBox/NumberBox.spec.js +1237 -0
- package/dist/scripts/src/components/Option/Option.spec.js +472 -0
- package/dist/scripts/src/components/PageMetaTitle/PageMetaTitle.spec.js +80 -0
- package/dist/scripts/src/components/Pagination/Pagination.spec.js +1003 -0
- package/dist/scripts/src/components/ProfileMenu/ProfileMenu.js +20 -0
- package/dist/scripts/src/components/ProgressBar/ProgressBar.spec.js +166 -0
- package/dist/scripts/src/components/Queue/Queue.spec.js +626 -0
- package/dist/scripts/src/components/RadioGroup/RadioGroup.spec.js +479 -0
- package/dist/scripts/src/components/Redirect/Redirect.spec.js +527 -0
- package/dist/scripts/src/components/ResponsiveBar/ResponsiveBar.spec.js +76 -0
- package/dist/scripts/src/components/Select/Select.spec.js +527 -0
- package/dist/scripts/src/components/SelectionStore/SelectionStoreNative.js +3 -1
- package/dist/scripts/src/components/Slider/Slider.js +2 -0
- package/dist/scripts/src/components/Slider/Slider.spec.js +574 -0
- package/dist/scripts/src/components/Slider/SliderNative.js +63 -26
- package/dist/scripts/src/components/Slot/Slot.spec.js +368 -0
- package/dist/scripts/src/components/SpaceFiller/SpaceFiller.spec.js +184 -0
- package/dist/scripts/src/components/Spinner/Spinner.spec.js +161 -0
- package/dist/scripts/src/components/Splitter/HSplitter.spec.js +104 -0
- package/dist/scripts/src/components/Splitter/Splitter.spec.js +543 -0
- package/dist/scripts/src/components/Splitter/VSplitter.spec.js +104 -0
- package/dist/scripts/src/components/Stack/CHStack.spec.js +86 -0
- package/dist/scripts/src/components/Stack/CVStack.spec.js +86 -0
- package/dist/scripts/src/components/Stack/HStack.spec.js +67 -0
- package/dist/scripts/src/components/Stack/Stack.spec.js +654 -0
- package/dist/scripts/src/components/Stack/VStack.spec.js +67 -0
- package/dist/scripts/src/components/Switch/Switch.spec.js +829 -0
- package/dist/scripts/src/components/Table/Table.js +7 -1
- package/dist/scripts/src/components/Table/Table.spec.js +555 -0
- package/dist/scripts/src/components/Table/TableNative.js +4 -1
- package/dist/scripts/src/components/Table/doc-resources/list-component-data.js +53 -0
- package/dist/scripts/src/components/Table/useRowSelection.js +215 -1
- package/dist/scripts/src/components/TableOfContents/TableOfContents.spec.js +838 -0
- package/dist/scripts/src/components/Tabs/Tabs.spec.js +875 -0
- package/dist/scripts/src/components/Text/Text.spec.js +1075 -0
- package/dist/scripts/src/components/TextArea/TextArea.spec.js +714 -0
- package/dist/scripts/src/components/TextBox/TextBox.js +1 -5
- package/dist/scripts/src/components/TextBox/TextBox.spec.js +687 -0
- package/dist/scripts/src/components/TextBox/TextBoxNative.js +10 -15
- package/dist/scripts/src/components/Theme/Theme.spec.js +124 -0
- package/dist/scripts/src/components/Theme/ThemeNative.js +2 -6
- package/dist/scripts/src/components/TimeInput/TimeInput.js +1 -5
- package/dist/scripts/src/components/TimeInput/TimeInput.spec.js +1122 -0
- package/dist/scripts/src/components/TimeInput/TimeInputNative.js +2 -9
- package/dist/scripts/src/components/Timer/Timer.spec.js +358 -0
- package/dist/scripts/src/components/ToneChangerButton/ToneChangerButton.spec.js +414 -0
- package/dist/scripts/src/components/ToneSwitch/ToneSwitch.spec.js +89 -0
- package/dist/scripts/src/components/Tooltip/Tooltip.spec.js +418 -0
- package/dist/scripts/src/components/chart-color-schemes.js +43 -0
- package/dist/scripts/src/components-core/ApiBoundComponent.js +38 -24
- package/dist/scripts/src/components-core/CompoundComponent.js +1 -1
- package/dist/scripts/src/components-core/RestApiProxy.js +84 -8
- package/dist/scripts/src/components-core/behaviors/BehaviorContext.js +54 -0
- package/dist/scripts/src/components-core/behaviors/CoreBehaviors.js +80 -0
- package/dist/scripts/src/components-core/descriptorHelper.js +1 -0
- package/dist/scripts/src/components-core/devtools/InspectorDialogVisibilityContext.js +8 -0
- package/dist/scripts/src/components-core/parts.js +4 -1
- package/dist/scripts/src/components-core/renderers.js +31 -0
- package/dist/scripts/src/components-core/rendering/AppRoot.js +2 -1
- package/dist/scripts/src/components-core/rendering/ComponentAdapter.js +31 -46
- package/dist/scripts/src/components-core/rendering/nodeUtils.js +6 -0
- package/dist/scripts/src/components-core/script-runner/simplify-expression.js +386 -0
- package/dist/scripts/src/components-core/theming/component-layout-resolver.js +153 -0
- package/dist/scripts/src/components-core/theming/layout-resolver.js +2 -0
- package/dist/scripts/src/components-core/theming/parse-layout-props.js +98 -0
- package/dist/scripts/src/components-core/theming/themes/solid.js +16 -0
- package/dist/scripts/src/components-core/utils/audio-utils.js +83 -0
- package/dist/scripts/src/index-standalone.js +61 -0
- package/dist/scripts/src/index.js +39 -1
- package/dist/scripts/src/language-server/server-common.js +151 -0
- package/dist/scripts/src/language-server/server-web-worker.js +47 -0
- package/dist/scripts/src/language-server/server.js +42 -0
- package/dist/scripts/src/language-server/services/common/docs-generation.js +73 -0
- package/dist/scripts/src/language-server/services/common/lsp-utils.js +9 -0
- package/dist/scripts/src/language-server/services/common/syntax-node-utilities.js +135 -0
- package/dist/scripts/src/language-server/services/completion.js +270 -0
- package/dist/scripts/src/language-server/services/diagnostic.js +19 -0
- package/dist/scripts/src/language-server/services/format.js +430 -0
- package/dist/scripts/src/language-server/services/hover.js +164 -0
- package/dist/scripts/src/language-server/xmlui-metadata-generated.mjs +16266 -0
- package/dist/scripts/src/logging/xmlui.js +21 -0
- package/dist/scripts/src/parsers/common/utils.js +19 -0
- package/dist/scripts/src/syntax/monaco/grammar.monacoLanguage.js +286 -0
- package/dist/scripts/src/syntax/monaco/index.js +14 -0
- package/dist/scripts/src/syntax/monaco/xmlui-dark.js +25 -0
- package/dist/scripts/src/syntax/monaco/xmlui-light.js +25 -0
- package/dist/scripts/src/syntax/monaco/xmluiscript.monacoLanguage.js +310 -0
- package/dist/scripts/src/syntax/textMate/index.js +14 -0
- package/dist/scripts/src/syntax/textMate/xmlui-dark.json +631 -0
- package/dist/scripts/src/syntax/textMate/xmlui-light.json +565 -0
- package/dist/scripts/src/syntax/textMate/xmlui.json +564 -0
- package/dist/scripts/src/syntax/textMate/xmlui.tmLanguage.json +341 -0
- package/dist/scripts/src/testing/ComponentDrivers.js +1327 -0
- package/dist/scripts/src/testing/assertions.js +444 -0
- package/dist/scripts/src/testing/component-test-helpers.js +389 -0
- package/dist/scripts/src/testing/drivers/DateInputDriver.js +19 -0
- package/dist/scripts/src/testing/drivers/ModalDialogDriver.js +10 -0
- package/dist/scripts/src/testing/drivers/NumberBoxDriver.js +44 -0
- package/dist/scripts/src/testing/drivers/SliderDriver.js +20 -0
- package/dist/scripts/src/testing/drivers/TextBoxDriver.js +20 -0
- package/dist/scripts/src/testing/drivers/TimeInputDriver.js +22 -0
- package/dist/scripts/src/testing/drivers/TimerDriver.js +64 -0
- package/dist/scripts/src/testing/fixtures.js +513 -0
- package/dist/scripts/src/testing/infrastructure/TestBed.js +17 -0
- package/dist/scripts/src/testing/infrastructure/main.js +9 -0
- package/dist/scripts/src/testing/infrastructure/public/mockServiceWorker.js +266 -0
- package/dist/scripts/src/testing/themed-app-test-helpers.js +139 -0
- package/dist/standalone/xmlui-standalone.es.d.ts +172 -10
- package/dist/standalone/xmlui-standalone.umd.js +36 -36
- package/package.json +2 -3
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleDocumentFormatting = handleDocumentFormatting;
|
|
4
|
+
exports.format = format;
|
|
5
|
+
const xmlui_parser_1 = require("../../parsers/xmlui-parser");
|
|
6
|
+
const syntax_node_utilities_1 = require("./common/syntax-node-utilities");
|
|
7
|
+
function handleDocumentFormatting({ node, getText, options, offsetToPosition, }) {
|
|
8
|
+
const formatted = format(node, getText, options);
|
|
9
|
+
// If content is already formatted correctly, return empty array
|
|
10
|
+
const unformattedContent = getText(node, false);
|
|
11
|
+
if (formatted === unformattedContent) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
const entireDocumentRange = {
|
|
15
|
+
start: { line: 0, character: 0 },
|
|
16
|
+
end: offsetToPosition(unformattedContent.length),
|
|
17
|
+
};
|
|
18
|
+
return [
|
|
19
|
+
{
|
|
20
|
+
range: entireDocumentRange,
|
|
21
|
+
newText: formatted,
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
class XmluiFormatter {
|
|
26
|
+
constructor(node, getText, options) {
|
|
27
|
+
this.newlineToken = "\n";
|
|
28
|
+
this.getText = getText;
|
|
29
|
+
this.startingNode = node;
|
|
30
|
+
this.indentationLvl = 0;
|
|
31
|
+
this.maxLineLength = 80;
|
|
32
|
+
this.tabSize = options.tabSize;
|
|
33
|
+
this.indentationToken = options.insertSpaces ? " ".repeat(options.tabSize) : "\t";
|
|
34
|
+
if (options.insertFinalNewline && !options.trimFinalNewlines) {
|
|
35
|
+
this.handleTrailingWhitespace = (formatted) => {
|
|
36
|
+
return formatted.trimEnd() + this.newlineToken;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this.handleTrailingWhitespace = (formatted) => {
|
|
41
|
+
return formatted.trimEnd();
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
format() {
|
|
46
|
+
let formattedStr;
|
|
47
|
+
if (this.startingNode.kind !== xmlui_parser_1.SyntaxKind.ContentListNode) {
|
|
48
|
+
formattedStr = this.getText(this.startingNode);
|
|
49
|
+
}
|
|
50
|
+
formattedStr = this.printContentListNode(this.startingNode);
|
|
51
|
+
formattedStr = this.handleTrailingWhitespace(formattedStr);
|
|
52
|
+
return formattedStr;
|
|
53
|
+
}
|
|
54
|
+
printContentListNode(node) {
|
|
55
|
+
let acc = this.printEveryTrivia(node);
|
|
56
|
+
if (!node.children) {
|
|
57
|
+
acc += this.getText(node);
|
|
58
|
+
return acc;
|
|
59
|
+
}
|
|
60
|
+
for (let i = 0; i < node.children.length; i++) {
|
|
61
|
+
const c = node.children[i];
|
|
62
|
+
const prevChild = i > 0 ? node.children[i - 1] : null;
|
|
63
|
+
switch (c.kind) {
|
|
64
|
+
case xmlui_parser_1.SyntaxKind.CData:
|
|
65
|
+
case xmlui_parser_1.SyntaxKind.Script:
|
|
66
|
+
case xmlui_parser_1.SyntaxKind.ElementNode: {
|
|
67
|
+
const comment = this.getCommentsSpaceJoined(c);
|
|
68
|
+
const prevIsText = (prevChild === null || prevChild === void 0 ? void 0 : prevChild.kind) === xmlui_parser_1.SyntaxKind.TextNode;
|
|
69
|
+
if (comment) {
|
|
70
|
+
let commentInline = true;
|
|
71
|
+
if (this.hasNewlineTriviaBeforeComment(c)) {
|
|
72
|
+
commentInline = false;
|
|
73
|
+
}
|
|
74
|
+
else if (prevIsText) {
|
|
75
|
+
const prevText = this.getText(prevChild);
|
|
76
|
+
commentInline = !hasNewlineInTrailingWhitespace(prevText);
|
|
77
|
+
}
|
|
78
|
+
if (commentInline) {
|
|
79
|
+
if (acc.at(-1) === this.newlineToken) {
|
|
80
|
+
acc = acc.substring(0, acc.length - this.newlineToken.length);
|
|
81
|
+
}
|
|
82
|
+
acc += ` ${comment}${this.newlineToken}`;
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
acc += this.indent(this.indentationLvl) + comment + this.newlineToken;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
acc += this.indent(this.indentationLvl);
|
|
89
|
+
acc += this.printTagLike(c);
|
|
90
|
+
acc += this.newlineToken;
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
case xmlui_parser_1.SyntaxKind.StringLiteral:
|
|
94
|
+
case xmlui_parser_1.SyntaxKind.TextNode: {
|
|
95
|
+
const formattedContent = this.printContentString(c);
|
|
96
|
+
if (formattedContent !== "") {
|
|
97
|
+
acc += this.indent(this.indentationLvl);
|
|
98
|
+
acc += formattedContent;
|
|
99
|
+
acc += this.newlineToken;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
acc.trimEnd();
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
case xmlui_parser_1.SyntaxKind.ErrorNode:
|
|
107
|
+
acc += this.getText(c, false);
|
|
108
|
+
break;
|
|
109
|
+
case xmlui_parser_1.SyntaxKind.EndOfFileToken:
|
|
110
|
+
const comment = this.getCommentsSpaceJoined(c);
|
|
111
|
+
if (comment) {
|
|
112
|
+
if (!this.hasNewlineTriviaBeforeComment(c) && acc.at(-1) === this.newlineToken) {
|
|
113
|
+
acc = acc.substring(0, acc.length - this.newlineToken.length) + " ";
|
|
114
|
+
}
|
|
115
|
+
acc += this.indent(this.indentationLvl) + comment;
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return acc;
|
|
121
|
+
}
|
|
122
|
+
printTagLike(node) {
|
|
123
|
+
switch (node.kind) {
|
|
124
|
+
case xmlui_parser_1.SyntaxKind.Script:
|
|
125
|
+
case xmlui_parser_1.SyntaxKind.CData:
|
|
126
|
+
return this.getText(node);
|
|
127
|
+
default:
|
|
128
|
+
return this.printElementNode(node);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
printElementNode(node) {
|
|
132
|
+
let acc = "";
|
|
133
|
+
const contentListIdx = node.children.findIndex((c) => c.kind === xmlui_parser_1.SyntaxKind.ContentListNode);
|
|
134
|
+
const hasContentList = contentListIdx !== -1;
|
|
135
|
+
const closeNodeStartIdx = node.children.findIndex((c) => c.kind === xmlui_parser_1.SyntaxKind.CloseNodeStart);
|
|
136
|
+
const hasCloseNodeStart = closeNodeStartIdx !== -1;
|
|
137
|
+
let openTagNodeCount;
|
|
138
|
+
if (hasContentList) {
|
|
139
|
+
openTagNodeCount = contentListIdx;
|
|
140
|
+
}
|
|
141
|
+
else if (hasCloseNodeStart) {
|
|
142
|
+
openTagNodeCount = closeNodeStartIdx;
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
openTagNodeCount = node.children.length;
|
|
146
|
+
}
|
|
147
|
+
const openTagNodes = node.children.slice(0, openTagNodeCount);
|
|
148
|
+
acc += this.printOpenTag(openTagNodes);
|
|
149
|
+
if (hasContentList) {
|
|
150
|
+
const contentListNode = node.children[contentListIdx];
|
|
151
|
+
++this.indentationLvl;
|
|
152
|
+
acc += this.newlineToken;
|
|
153
|
+
acc += this.printContentListNode(contentListNode);
|
|
154
|
+
--this.indentationLvl;
|
|
155
|
+
}
|
|
156
|
+
let closeTagNodesStartIdx;
|
|
157
|
+
if (hasCloseNodeStart) {
|
|
158
|
+
closeTagNodesStartIdx = closeNodeStartIdx;
|
|
159
|
+
}
|
|
160
|
+
else if (hasContentList) {
|
|
161
|
+
closeTagNodesStartIdx = contentListIdx + 1;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
closeTagNodesStartIdx = openTagNodeCount + 1;
|
|
165
|
+
}
|
|
166
|
+
const closeTagNodes = node.children.slice(closeTagNodesStartIdx);
|
|
167
|
+
acc += this.printClosingTag(closeTagNodes, hasContentList);
|
|
168
|
+
return acc;
|
|
169
|
+
}
|
|
170
|
+
printOpenTag(tagChildren) {
|
|
171
|
+
let acc = "";
|
|
172
|
+
for (let i = 0; i < tagChildren.length; ++i) {
|
|
173
|
+
const c = tagChildren[i];
|
|
174
|
+
switch (c.kind) {
|
|
175
|
+
case xmlui_parser_1.SyntaxKind.OpenNodeStart:
|
|
176
|
+
acc += "<";
|
|
177
|
+
break;
|
|
178
|
+
case xmlui_parser_1.SyntaxKind.CloseNodeStart:
|
|
179
|
+
acc += "</";
|
|
180
|
+
break;
|
|
181
|
+
case xmlui_parser_1.SyntaxKind.TagNameNode:
|
|
182
|
+
acc += this.printTagName(c);
|
|
183
|
+
break;
|
|
184
|
+
case xmlui_parser_1.SyntaxKind.NodeClose:
|
|
185
|
+
case xmlui_parser_1.SyntaxKind.NodeEnd:
|
|
186
|
+
case xmlui_parser_1.SyntaxKind.AttributeListNode:
|
|
187
|
+
acc += this.printTagAfterName(tagChildren.slice(i), acc);
|
|
188
|
+
return acc;
|
|
189
|
+
case xmlui_parser_1.SyntaxKind.ErrorNode:
|
|
190
|
+
acc += this.getText(c, false);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return acc;
|
|
194
|
+
}
|
|
195
|
+
printClosingTag(tagChildren, hasContentList) {
|
|
196
|
+
let acc = "";
|
|
197
|
+
for (let i = 0; i < tagChildren.length; ++i) {
|
|
198
|
+
const c = tagChildren[i];
|
|
199
|
+
switch (c.kind) {
|
|
200
|
+
case xmlui_parser_1.SyntaxKind.CloseNodeStart:
|
|
201
|
+
const comment = this.getCommentsSpaceJoined(c);
|
|
202
|
+
if (comment) {
|
|
203
|
+
if (!hasContentList) {
|
|
204
|
+
acc += this.newlineToken;
|
|
205
|
+
}
|
|
206
|
+
acc += this.indent(this.indentationLvl + 1);
|
|
207
|
+
acc += comment + this.newlineToken;
|
|
208
|
+
}
|
|
209
|
+
acc += this.indent(this.indentationLvl) + "</";
|
|
210
|
+
break;
|
|
211
|
+
case xmlui_parser_1.SyntaxKind.TagNameNode:
|
|
212
|
+
acc += this.printTagName(c);
|
|
213
|
+
break;
|
|
214
|
+
case xmlui_parser_1.SyntaxKind.NodeEnd:
|
|
215
|
+
acc += this.printTagAfterName(tagChildren.slice(i), acc);
|
|
216
|
+
return acc;
|
|
217
|
+
case xmlui_parser_1.SyntaxKind.ErrorNode:
|
|
218
|
+
acc += this.getText(c, false);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
return acc;
|
|
222
|
+
}
|
|
223
|
+
printTagAfterName(nodes, tagAcc) {
|
|
224
|
+
let acc = "";
|
|
225
|
+
let closingIsNodeClose = false;
|
|
226
|
+
let attrSegmentsFormatted = [];
|
|
227
|
+
let attrListOffsetInAcc;
|
|
228
|
+
let closingSegmentsFormatted = [];
|
|
229
|
+
let closingOffsetInAcc;
|
|
230
|
+
let attrsAlreadyMultiline = false;
|
|
231
|
+
for (let i = 0; i < nodes.length; ++i) {
|
|
232
|
+
const c = nodes[i];
|
|
233
|
+
switch (c.kind) {
|
|
234
|
+
case xmlui_parser_1.SyntaxKind.AttributeListNode:
|
|
235
|
+
attrSegmentsFormatted = this.printAttrList(c);
|
|
236
|
+
attrsAlreadyMultiline = c.children.some((attr) => (0, syntax_node_utilities_1.getTriviaNodes)(attr).some((attrTrivia) => attrTrivia.kind === xmlui_parser_1.SyntaxKind.NewLineTrivia));
|
|
237
|
+
attrListOffsetInAcc = acc.length;
|
|
238
|
+
break;
|
|
239
|
+
case xmlui_parser_1.SyntaxKind.NodeClose: {
|
|
240
|
+
closingOffsetInAcc = acc.length;
|
|
241
|
+
closingIsNodeClose = true;
|
|
242
|
+
const comments = this.getCommentsSpaceJoined(c);
|
|
243
|
+
if (comments) {
|
|
244
|
+
closingSegmentsFormatted = [comments, "/>"];
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
closingSegmentsFormatted = ["/>"];
|
|
248
|
+
}
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
case xmlui_parser_1.SyntaxKind.NodeEnd: {
|
|
252
|
+
closingOffsetInAcc = acc.length;
|
|
253
|
+
closingIsNodeClose = false;
|
|
254
|
+
const comments = this.getCommentsSpaceJoined(c);
|
|
255
|
+
if (comments) {
|
|
256
|
+
closingSegmentsFormatted = [comments, ">"];
|
|
257
|
+
}
|
|
258
|
+
else {
|
|
259
|
+
closingSegmentsFormatted = [">"];
|
|
260
|
+
}
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
case xmlui_parser_1.SyntaxKind.ErrorNode:
|
|
264
|
+
acc += this.getText(c, true);
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
const lineLenBeforeAttrs = this.indentationLvl * this.tabSize + tagAcc.length;
|
|
269
|
+
const errorNodesLen = acc.length;
|
|
270
|
+
const restOfTag = attrSegmentsFormatted.concat(closingSegmentsFormatted);
|
|
271
|
+
const restOfTagNonWsLen = restOfTag.reduce((sum, attr) => attr.length + sum, 0);
|
|
272
|
+
const spacesBetweenRestOfTagNodes = attrSegmentsFormatted.length - 1;
|
|
273
|
+
const sameLineTagLen = errorNodesLen + lineLenBeforeAttrs + restOfTagNonWsLen + spacesBetweenRestOfTagNodes;
|
|
274
|
+
const breakAttrsToMultipleLines = attrsAlreadyMultiline || sameLineTagLen > this.maxLineLength;
|
|
275
|
+
const attrsAndTrailingComments = attrSegmentsFormatted.concat(closingSegmentsFormatted.slice(0, -1));
|
|
276
|
+
const hasClosing = closingSegmentsFormatted.length > 0;
|
|
277
|
+
const closingFormatted = closingSegmentsFormatted.at(-1);
|
|
278
|
+
if (breakAttrsToMultipleLines) {
|
|
279
|
+
const wsBeforeAttr = this.newlineToken + this.indent(this.indentationLvl + 1);
|
|
280
|
+
const attrsFormatted = attrsAndTrailingComments.join(wsBeforeAttr);
|
|
281
|
+
if (attrsAndTrailingComments.length > 0) {
|
|
282
|
+
acc += wsBeforeAttr + attrsFormatted;
|
|
283
|
+
}
|
|
284
|
+
if (hasClosing) {
|
|
285
|
+
if (closingIsNodeClose) {
|
|
286
|
+
acc += " ";
|
|
287
|
+
}
|
|
288
|
+
acc += closingFormatted;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
else {
|
|
292
|
+
const wsBeforeAttr = " ";
|
|
293
|
+
const attrsFormatted = attrsAndTrailingComments.join(wsBeforeAttr);
|
|
294
|
+
if (attrsAndTrailingComments.length > 0) {
|
|
295
|
+
acc += wsBeforeAttr + attrsFormatted;
|
|
296
|
+
}
|
|
297
|
+
if (hasClosing) {
|
|
298
|
+
if (closingIsNodeClose) {
|
|
299
|
+
acc += " ";
|
|
300
|
+
}
|
|
301
|
+
acc += closingFormatted;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return acc;
|
|
305
|
+
}
|
|
306
|
+
printAttrList(node) {
|
|
307
|
+
const attrsFormatted = [];
|
|
308
|
+
for (const c of node.children) {
|
|
309
|
+
const comments = this.getCommentsSpaceJoined(c);
|
|
310
|
+
if (comments) {
|
|
311
|
+
attrsFormatted.push(comments);
|
|
312
|
+
}
|
|
313
|
+
attrsFormatted.push(this.printAttrNode(c));
|
|
314
|
+
}
|
|
315
|
+
return attrsFormatted;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
*
|
|
319
|
+
* @param node a potential ErrorNode
|
|
320
|
+
* @returns the formatted string if the node was an ErrorNode
|
|
321
|
+
* otherwise `null`.
|
|
322
|
+
*/
|
|
323
|
+
printIfErrNode(node) {
|
|
324
|
+
if (node.kind === xmlui_parser_1.SyntaxKind.ErrorNode) {
|
|
325
|
+
return this.getText(node, true);
|
|
326
|
+
}
|
|
327
|
+
else {
|
|
328
|
+
return null;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
/**
|
|
332
|
+
* trivia before the first child element is not handled, as that is
|
|
333
|
+
* the job of the parent function, that joins attrNodes together
|
|
334
|
+
*
|
|
335
|
+
* @param node attrNode
|
|
336
|
+
* @returns
|
|
337
|
+
*/
|
|
338
|
+
printAttrNode(node) {
|
|
339
|
+
const formattedErrNode = this.printIfErrNode(node);
|
|
340
|
+
if (formattedErrNode !== null) {
|
|
341
|
+
return formattedErrNode;
|
|
342
|
+
}
|
|
343
|
+
let acc = this.printAttrKeyNode(node.children[0]);
|
|
344
|
+
const otherChildren = node.children.slice(1);
|
|
345
|
+
acc += this.printNodesSpaceJoinedCommentsBefore(otherChildren);
|
|
346
|
+
return acc;
|
|
347
|
+
}
|
|
348
|
+
printAttrKeyNode(node) {
|
|
349
|
+
let acc = this.getText(node.children[0]);
|
|
350
|
+
const otherChildren = node.children.slice(1);
|
|
351
|
+
acc += this.printNodesSpaceJoinedCommentsBefore(otherChildren);
|
|
352
|
+
return acc;
|
|
353
|
+
}
|
|
354
|
+
printNodesSpaceJoinedCommentsBefore(nodes) {
|
|
355
|
+
let acc = "";
|
|
356
|
+
for (let node of nodes) {
|
|
357
|
+
if (node.kind === xmlui_parser_1.SyntaxKind.ErrorNode) {
|
|
358
|
+
acc += this.getText(node, false);
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
const comment = this.getCommentsSpaceJoined(node);
|
|
362
|
+
if (comment) {
|
|
363
|
+
acc += " " + comment + " ";
|
|
364
|
+
}
|
|
365
|
+
acc += this.getText(node);
|
|
366
|
+
}
|
|
367
|
+
return acc;
|
|
368
|
+
}
|
|
369
|
+
printTagName(node) {
|
|
370
|
+
const commentBefName = this.getCommentsSpaceJoined(node.children[0]);
|
|
371
|
+
const firstTokenPrint = this.getText(node.children[0]);
|
|
372
|
+
let acc = commentBefName ? ` ${commentBefName} ${firstTokenPrint}` : firstTokenPrint;
|
|
373
|
+
acc += this.printNodesSpaceJoinedCommentsBefore(node.children.slice(1));
|
|
374
|
+
return acc;
|
|
375
|
+
}
|
|
376
|
+
printContentString(node) {
|
|
377
|
+
return this.getText(node, false).trim();
|
|
378
|
+
}
|
|
379
|
+
printEveryTrivia(node) {
|
|
380
|
+
var _a;
|
|
381
|
+
return ((_a = node.triviaBefore) !== null && _a !== void 0 ? _a : []).map((trivia) => this.getText(trivia)).join("");
|
|
382
|
+
}
|
|
383
|
+
indent(lvl) {
|
|
384
|
+
return this.indentationToken.repeat(lvl);
|
|
385
|
+
}
|
|
386
|
+
getComments(node) {
|
|
387
|
+
const triviaNodes = (0, syntax_node_utilities_1.getTriviaNodes)(node);
|
|
388
|
+
return triviaNodes
|
|
389
|
+
.filter(({ kind }) => kind === xmlui_parser_1.SyntaxKind.CommentTrivia)
|
|
390
|
+
.map((comment) => this.getText(comment));
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
*
|
|
394
|
+
* @returns null if the node doesn't have comment trivia,
|
|
395
|
+
* otherwise the comments, joined with a space char.
|
|
396
|
+
*/
|
|
397
|
+
getCommentsSpaceJoined(node) {
|
|
398
|
+
const comments = this.getComments(node);
|
|
399
|
+
if (comments.length === 0) {
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
return comments.join(" ");
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* Check if comments have newlines before them
|
|
406
|
+
*/
|
|
407
|
+
hasNewlineTriviaBeforeComment(node) {
|
|
408
|
+
const triviaNodes = (0, syntax_node_utilities_1.getTriviaNodes)(node);
|
|
409
|
+
for (let c of triviaNodes) {
|
|
410
|
+
if (c.kind === xmlui_parser_1.SyntaxKind.NewLineTrivia) {
|
|
411
|
+
return true;
|
|
412
|
+
}
|
|
413
|
+
else if (c.kind === xmlui_parser_1.SyntaxKind.CommentTrivia) {
|
|
414
|
+
return false;
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
return false;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
function format(node, getText, options) {
|
|
421
|
+
const formatter = new XmluiFormatter(node, getText, options);
|
|
422
|
+
const formattedString = formatter.format();
|
|
423
|
+
return formattedString;
|
|
424
|
+
}
|
|
425
|
+
function hasNewlineInTrailingWhitespace(text) {
|
|
426
|
+
const lastNewlineIdx = text.lastIndexOf("\n");
|
|
427
|
+
const trimmedPrevText = text.trimEnd();
|
|
428
|
+
const textEndedInNewline = lastNewlineIdx >= trimmedPrevText.length;
|
|
429
|
+
return textEndedInNewline;
|
|
430
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.handleHoverCore = handleHoverCore;
|
|
37
|
+
exports.handleHover = handleHover;
|
|
38
|
+
const utils_1 = require("../../parsers/xmlui-parser/utils");
|
|
39
|
+
const syntax_kind_1 = require("../../parsers/xmlui-parser/syntax-kind");
|
|
40
|
+
const syntax_node_utilities_1 = require("./common/syntax-node-utilities");
|
|
41
|
+
const docGen = __importStar(require("./common/docs-generation"));
|
|
42
|
+
const vscode_languageserver_1 = require("vscode-languageserver");
|
|
43
|
+
const lsp_utils_1 = require("./common/lsp-utils");
|
|
44
|
+
/**
|
|
45
|
+
* @returns The hover content string
|
|
46
|
+
*/
|
|
47
|
+
function handleHoverCore({ node, getText, metaByComp }, position) {
|
|
48
|
+
const findRes = (0, utils_1.findTokenAtPos)(node, position);
|
|
49
|
+
if (findRes === undefined) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const { chainAtPos } = findRes;
|
|
53
|
+
const atNode = chainAtPos.at(-1);
|
|
54
|
+
const parentNode = chainAtPos.at(-2);
|
|
55
|
+
switch (atNode.kind) {
|
|
56
|
+
case syntax_kind_1.SyntaxKind.Identifier:
|
|
57
|
+
switch (parentNode === null || parentNode === void 0 ? void 0 : parentNode.kind) {
|
|
58
|
+
case syntax_kind_1.SyntaxKind.TagNameNode: {
|
|
59
|
+
return hoverName({
|
|
60
|
+
metaByComp: metaByComp,
|
|
61
|
+
tagNameNode: parentNode,
|
|
62
|
+
identNode: atNode,
|
|
63
|
+
getText
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
case syntax_kind_1.SyntaxKind.AttributeKeyNode: {
|
|
67
|
+
return hoverAttr({
|
|
68
|
+
metaByComp,
|
|
69
|
+
attrKeyNode: parentNode,
|
|
70
|
+
parentStack: chainAtPos.slice(0, -2),
|
|
71
|
+
getText,
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}
|
|
79
|
+
function handleHover(ctx, position) {
|
|
80
|
+
const hoverRes = handleHoverCore(ctx, position);
|
|
81
|
+
if (hoverRes === null) {
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
const { value, range } = hoverRes;
|
|
85
|
+
return {
|
|
86
|
+
contents: {
|
|
87
|
+
kind: vscode_languageserver_1.MarkupKind.Markdown,
|
|
88
|
+
value,
|
|
89
|
+
},
|
|
90
|
+
range: (0, lsp_utils_1.offsetToPosRange)(ctx.offsetToPosition, range)
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
function hoverAttr({ metaByComp, attrKeyNode, parentStack, getText, }) {
|
|
94
|
+
var _a, _b;
|
|
95
|
+
if (parentStack.at(-1).kind !== syntax_kind_1.SyntaxKind.AttributeNode) {
|
|
96
|
+
return null;
|
|
97
|
+
}
|
|
98
|
+
if (parentStack.at(-2).kind !== syntax_kind_1.SyntaxKind.AttributeListNode) {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
const tag = parentStack.at(-3);
|
|
102
|
+
if ((tag === null || tag === void 0 ? void 0 : tag.kind) !== syntax_kind_1.SyntaxKind.ElementNode) {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
const tagNameNode = (0, syntax_node_utilities_1.findTagNameNodeInStack)(parentStack);
|
|
106
|
+
if (!tagNameNode) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
const compName = (0, syntax_node_utilities_1.compNameForTagNameNode)(tagNameNode, getText);
|
|
110
|
+
const component = metaByComp.getComponent(compName);
|
|
111
|
+
if (!component) {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
const attrKeyChildren = attrKeyNode.children;
|
|
115
|
+
const identIdx = attrKeyChildren.findIndex((c) => c.kind === syntax_kind_1.SyntaxKind.Identifier);
|
|
116
|
+
if (identIdx === -1) {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
const attrIdent = attrKeyChildren[identIdx];
|
|
120
|
+
const propIsNamespaceDefinition = ((_a = attrKeyChildren[identIdx + 1]) === null || _a === void 0 ? void 0 : _a.kind) === syntax_kind_1.SyntaxKind.Colon &&
|
|
121
|
+
((_b = attrKeyChildren[identIdx + 2]) === null || _b === void 0 ? void 0 : _b.kind) === syntax_kind_1.SyntaxKind.Identifier &&
|
|
122
|
+
getText(attrIdent) === "xmlns";
|
|
123
|
+
if (propIsNamespaceDefinition) {
|
|
124
|
+
return {
|
|
125
|
+
value: `Defines a namespace. TODO Further Documentation needed.`,
|
|
126
|
+
range: {
|
|
127
|
+
pos: attrKeyNode.pos,
|
|
128
|
+
end: attrKeyNode.end,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const attrName = getText(attrIdent);
|
|
133
|
+
const attrMd = component.getAttr(attrName);
|
|
134
|
+
if (!attrMd) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
const value = docGen.generateAttrDescription(attrName, attrMd);
|
|
138
|
+
return {
|
|
139
|
+
value,
|
|
140
|
+
range: {
|
|
141
|
+
pos: attrKeyNode.pos,
|
|
142
|
+
end: attrKeyNode.end,
|
|
143
|
+
},
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
function hoverName({ metaByComp, tagNameNode, identNode, getText, }) {
|
|
147
|
+
var _a;
|
|
148
|
+
const compName = (0, syntax_node_utilities_1.compNameForTagNameNode)(tagNameNode, getText);
|
|
149
|
+
if (!compName) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
const compMetadata = (_a = metaByComp.getComponent(compName)) === null || _a === void 0 ? void 0 : _a.getMetadata();
|
|
153
|
+
if (!compMetadata) {
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
const value = docGen.generateCompNameDescription(compName, compMetadata);
|
|
157
|
+
return {
|
|
158
|
+
value,
|
|
159
|
+
range: {
|
|
160
|
+
pos: identNode.pos,
|
|
161
|
+
end: identNode.end,
|
|
162
|
+
},
|
|
163
|
+
};
|
|
164
|
+
}
|