xmlui 0.10.19 → 0.10.21
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-DPgtUtdA.mjs → apiInterceptorWorker-QiltRtq1.mjs} +1 -1
- package/dist/lib/{index-cuh97e2e.mjs → index-BiS4wEuu.mjs} +1486 -1211
- package/dist/lib/index.css +1 -1
- package/dist/{metadata/initMock-C-cnv--V.mjs → lib/initMock-CB_cMi6U.mjs} +25 -15
- package/dist/lib/language-server-web-worker.mjs +1 -1
- package/dist/lib/language-server.mjs +1 -1
- package/dist/lib/{metadata-utils-CtY0QcvH.mjs → metadata-utils-BTIt1_wE.mjs} +1 -1
- package/dist/lib/{server-common-Cine5nRR.mjs → server-common-DYZtsdM7.mjs} +51 -14
- package/dist/lib/{transform-bHBjkKSL.mjs → transform-Tooy42EB.mjs} +16 -18
- package/dist/lib/xmlui-parser.mjs +2 -2
- package/dist/lib/{xmlui-serializer-DB6BLiXK.mjs → xmlui-serializer-uCYa8_tZ.mjs} +1 -1
- package/dist/lib/xmlui.d.ts +11 -3
- package/dist/lib/xmlui.mjs +2 -2
- package/dist/metadata/{apiInterceptorWorker-BmKP8bnq.mjs → apiInterceptorWorker-Dql7QGw2.mjs} +1 -1
- package/dist/metadata/{collectedComponentMetadata-Cp-9lpnG.mjs → collectedComponentMetadata-MFUg6aSX.mjs} +1655 -1390
- package/dist/{lib/initMock-BMxsanHc.mjs → metadata/initMock-Dw9wrVkQ.mjs} +25 -15
- 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/package.json +3 -6
- package/dist/scripts/src/components/Animation/AnimationNative.js +28 -28
- package/dist/scripts/src/components/App/App.js +4 -4
- package/dist/scripts/src/components/App/App.spec.js +17 -17
- package/dist/scripts/src/components/App/AppNative.js +1 -1
- package/dist/scripts/src/components/AppState/AppState.js +3 -2
- package/dist/scripts/src/components/AppState/AppState.spec.js +26 -2
- package/dist/scripts/src/components/AppState/AppStateNative.js +3 -4
- package/dist/scripts/src/components/AutoComplete/AutoComplete.js +15 -10
- package/dist/scripts/src/components/AutoComplete/AutoCompleteNative.js +4 -4
- package/dist/scripts/src/components/Carousel/Carousel.spec.js +214 -0
- package/dist/scripts/src/components/CodeBlock/CodeBlockNative.js +1 -1
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.js +2 -0
- package/dist/scripts/src/components/ContentSeparator/ContentSeparator.spec.js +193 -0
- package/dist/scripts/src/components/DateInput/DateInput.spec.js +6 -6
- package/dist/scripts/src/components/DateInput/DateInputNative.js +0 -1
- package/dist/scripts/src/components/DropdownMenu/DropdownMenu.spec.js +3 -3
- package/dist/scripts/src/components/FileUploadDropZone/FileUploadDropZoneNative.js +4 -13
- package/dist/scripts/src/components/Form/Form.spec.js +25 -9
- package/dist/scripts/src/components/Form/FormNative.js +7 -5
- package/dist/scripts/src/components/FormItem/FormItem.js +3 -1
- package/dist/scripts/src/components/FormItem/FormItem.spec.js +5 -14
- package/dist/scripts/src/components/FormItem/FormItemNative.js +12 -8
- package/dist/scripts/src/components/FormItem/Validations.js +2 -2
- package/dist/scripts/src/components/IFrame/IFrameNative.js +0 -2
- package/dist/scripts/src/components/IconRegistryContext.js +1 -1
- package/dist/scripts/src/components/List/ListNative.js +2 -2
- package/dist/scripts/src/components/ModalDialog/ConfirmationModalContextProvider.js +3 -12
- package/dist/scripts/src/components/ModalDialog/ModalDialog.js +2 -2
- package/dist/scripts/src/components/ModalDialog/ModalDialogNative.js +6 -3
- package/dist/scripts/src/components/NestedApp/AppWithCodeViewNative.js +1 -1
- package/dist/scripts/src/components/NestedApp/NestedAppNative.js +3 -3
- package/dist/scripts/src/components/NumberBox/NumberBox.spec.js +2 -2
- package/dist/scripts/src/components/Pagination/Pagination.spec.js +5 -0
- package/dist/scripts/src/components/Pagination/PaginationNative.js +1 -3
- package/dist/scripts/src/components/Queue/Queue.spec.js +45 -47
- package/dist/scripts/src/components/Queue/QueueNative.js +1 -1
- package/dist/scripts/src/components/RadioGroup/RadioGroup.spec.js +5 -5
- package/dist/scripts/src/components/RealTimeAdapter/RealTimeAdapterNative.js +1 -1
- package/dist/scripts/src/components/Select/MultiSelectOption.js +42 -0
- package/dist/scripts/src/components/Select/Select.js +3 -3
- package/dist/scripts/src/components/Select/SelectContext.js +8 -1
- package/dist/scripts/src/components/Select/SelectNative.js +134 -142
- package/dist/scripts/src/components/Select/SelectOption.js +34 -0
- package/dist/scripts/src/components/Select/SimpleSelect.js +57 -0
- package/dist/scripts/src/components/Spinner/Spinner.spec.js +1 -1
- package/dist/scripts/src/components/Table/useRowSelection.js +14 -23
- package/dist/scripts/src/components/Text/Text.js +5 -1
- package/dist/scripts/src/components/Text/Text.spec.js +317 -0
- package/dist/scripts/src/components/Text/TextNative.js +112 -1
- package/dist/scripts/src/components/TextArea/TextArea.spec.js +8 -8
- package/dist/scripts/src/components/Theme/Theme.js +2 -1
- package/dist/scripts/src/components/Theme/Theme.spec.js +266 -0
- package/dist/scripts/src/components/Theme/ThemeNative.js +8 -1
- package/dist/scripts/src/components/TimeInput/TimeInput.spec.js +3 -3
- package/dist/scripts/src/components/TimeInput/TimeInputNative.js +0 -1
- package/dist/scripts/src/components/Timer/TimerNative.js +0 -1
- package/dist/scripts/src/components/Tree/TreeNative.js +16 -23
- package/dist/scripts/src/components-core/InspectorContext.js +1 -1
- package/dist/scripts/src/components-core/StandaloneApp.js +6 -8
- package/dist/scripts/src/components-core/action/FileUploadAction.js +1 -1
- package/dist/scripts/src/components-core/behaviors/BehaviorContext.js +50 -0
- package/dist/scripts/src/components-core/behaviors/CoreBehaviors.js +6 -1
- package/dist/scripts/src/components-core/interception/ApiInterceptor.js +9 -11
- package/dist/scripts/src/components-core/interception/ApiInterceptorProvider.js +3 -3
- package/dist/scripts/src/components-core/interception/Backend.js +1 -1
- package/dist/scripts/src/components-core/interception/IndexedDb.js +64 -66
- package/dist/scripts/src/components-core/interception/apiInterceptorWorker.js +2 -2
- package/dist/scripts/src/components-core/loader/DataLoader.js +6 -14
- package/dist/scripts/src/components-core/loader/Loader.js +11 -11
- package/dist/scripts/src/components-core/loader/MockLoaderRenderer.js +4 -2
- package/dist/scripts/src/components-core/loader/PageableLoader.js +10 -9
- package/dist/scripts/src/components-core/rendering/AppContent.js +1 -7
- package/dist/scripts/src/components-core/rendering/ErrorBoundary.js +1 -1
- package/dist/scripts/src/components-core/script-runner/bannedFunctions.js +1 -1
- package/dist/scripts/src/components-core/script-runner/eval-tree-async.js +180 -186
- package/dist/scripts/src/components-core/script-runner/eval-tree-sync.js +6 -6
- package/dist/scripts/src/components-core/script-runner/process-statement-sync.js +2 -2
- package/dist/scripts/src/components-core/utils/actionUtils.js +1 -1
- package/dist/scripts/src/components-core/utils/hooks.js +1 -1
- package/dist/scripts/src/components-core/utils/misc.js +4 -4
- package/dist/scripts/src/components-core/xmlui-parser.js +47 -31
- package/dist/scripts/src/language-server/server-common.js +25 -24
- package/dist/scripts/src/language-server/services/common/lsp-utils.js +2 -2
- package/dist/scripts/src/language-server/services/completion.js +20 -2
- package/dist/scripts/src/language-server/services/diagnostic.js +1 -1
- package/dist/scripts/src/language-server/services/hover.js +2 -2
- package/dist/scripts/src/parsers/common/utils.js +2 -2
- package/dist/scripts/src/parsers/scripting/Lexer.js +21 -15
- package/dist/scripts/src/parsers/scripting/Parser.js +8 -9
- package/dist/scripts/src/parsers/style-parser/StyleLexer.js +22 -22
- package/dist/scripts/src/parsers/style-parser/StyleParser.js +70 -68
- package/dist/scripts/src/testing/ComponentDrivers.js +20 -39
- package/dist/scripts/src/testing/component-test-helpers.js +34 -50
- package/dist/scripts/src/testing/fixtures.js +114 -113
- package/dist/scripts/src/testing/themed-app-test-helpers.js +7 -13
- package/dist/standalone/xmlui-standalone.es.d.ts +11 -3
- package/dist/standalone/xmlui-standalone.umd.js +35 -35
- package/package.json +3 -6
|
@@ -5,6 +5,7 @@ exports.errReportMessage = errReportMessage;
|
|
|
5
5
|
exports.errReportComponent = errReportComponent;
|
|
6
6
|
exports.errReportScriptError = errReportScriptError;
|
|
7
7
|
exports.errReportModuleErrors = errReportModuleErrors;
|
|
8
|
+
exports.createDocumentCursor = createDocumentCursor;
|
|
8
9
|
const parser_1 = require("../parsers/xmlui-parser/parser");
|
|
9
10
|
const transform_1 = require("../parsers/xmlui-parser/transform");
|
|
10
11
|
const diagnostics_1 = require("../parsers/xmlui-parser/diagnostics");
|
|
@@ -18,13 +19,7 @@ function xmlUiMarkupToComponent(source, fileId = 0) {
|
|
|
18
19
|
const { parse, getText } = (0, parser_1.createXmlUiParser)(source);
|
|
19
20
|
const { node, errors } = parse();
|
|
20
21
|
if (errors.length > 0) {
|
|
21
|
-
const
|
|
22
|
-
for (let i = 0; i < source.length; ++i) {
|
|
23
|
-
if (source[i] === "\n") {
|
|
24
|
-
newlinePositions.push(i);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
const errorsForDisplay = addDisplayFieldsToErrors(errors, source, newlinePositions);
|
|
22
|
+
const errorsForDisplay = addDisplayFieldsToErrors(errors, source);
|
|
28
23
|
const erroneousCompoundComponentName = getCompoundCompName(node, getText);
|
|
29
24
|
return { component: null, errors: errorsForDisplay, erroneousCompoundComponentName };
|
|
30
25
|
}
|
|
@@ -483,27 +478,6 @@ function errReportModuleErrors(errors, fileName) {
|
|
|
483
478
|
comp.component = createModuleErrorsComponent(errors, fileName);
|
|
484
479
|
return comp;
|
|
485
480
|
}
|
|
486
|
-
/**
|
|
487
|
-
* Converts a position in a string to a line and column number.
|
|
488
|
-
* @param offset the offset of the position in the string
|
|
489
|
-
* @param newlinePositions the offsets of the newlines in the string in ascending order
|
|
490
|
-
*/
|
|
491
|
-
function offsetToPosition(offset, newlinePositions) {
|
|
492
|
-
let left = 0;
|
|
493
|
-
let right = newlinePositions.length;
|
|
494
|
-
while (left < right) {
|
|
495
|
-
const mid = Math.floor((left + right) / 2);
|
|
496
|
-
if (newlinePositions[mid] < offset) {
|
|
497
|
-
left = mid + 1;
|
|
498
|
-
}
|
|
499
|
-
else {
|
|
500
|
-
right = mid;
|
|
501
|
-
}
|
|
502
|
-
}
|
|
503
|
-
let line = left + 1;
|
|
504
|
-
let col = left === 0 ? offset + 1 : offset - newlinePositions[left - 1];
|
|
505
|
-
return { line, col };
|
|
506
|
-
}
|
|
507
481
|
function getCompoundCompName(node, getText) {
|
|
508
482
|
var _a, _b, _c, _d, _e, _f;
|
|
509
483
|
const rootTag = (_a = node === null || node === void 0 ? void 0 : node.children) === null || _a === void 0 ? void 0 : _a[0];
|
|
@@ -521,12 +495,54 @@ function getCompoundCompName(node, getText) {
|
|
|
521
495
|
}
|
|
522
496
|
return undefined;
|
|
523
497
|
}
|
|
524
|
-
function addDisplayFieldsToErrors(errors, source
|
|
498
|
+
function addDisplayFieldsToErrors(errors, source) {
|
|
499
|
+
const { offsetToPosForDisplay } = createDocumentCursor(source);
|
|
525
500
|
return errors.map((err) => {
|
|
526
|
-
const { line: errPosLine,
|
|
527
|
-
const { line: contextStartLine } =
|
|
501
|
+
const { line: errPosLine, character: errPosCol } = offsetToPosForDisplay(err.pos);
|
|
502
|
+
const { line: contextStartLine } = offsetToPosForDisplay(err.contextPos);
|
|
528
503
|
return Object.assign(Object.assign({}, err), { errPosLine,
|
|
529
504
|
errPosCol,
|
|
530
505
|
contextStartLine, contextSource: source.substring(err.contextPos, err.contextEnd) });
|
|
531
506
|
});
|
|
532
507
|
}
|
|
508
|
+
function createDocumentCursor(text) {
|
|
509
|
+
const newlinePositions = [];
|
|
510
|
+
for (let i = 0; i < text.length; ++i) {
|
|
511
|
+
if (text[i] === "\n") {
|
|
512
|
+
newlinePositions.push(i);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
return {
|
|
516
|
+
offsetToPos,
|
|
517
|
+
offsetToPosForDisplay,
|
|
518
|
+
};
|
|
519
|
+
/**
|
|
520
|
+
* Converts a position in a string to 0 based line and column number.
|
|
521
|
+
* @param offset the 0 based offset into the string
|
|
522
|
+
*/
|
|
523
|
+
function offsetToPos(offset) {
|
|
524
|
+
let left = 0;
|
|
525
|
+
let right = newlinePositions.length;
|
|
526
|
+
while (left < right) {
|
|
527
|
+
const mid = Math.floor((left + right) / 2);
|
|
528
|
+
if (newlinePositions[mid] < offset) {
|
|
529
|
+
left = mid + 1;
|
|
530
|
+
}
|
|
531
|
+
else {
|
|
532
|
+
right = mid;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
let col = left === 0 ? offset : offset - newlinePositions[left - 1] - 1;
|
|
536
|
+
return { line: left, character: col };
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Converts a position in a string to base 1 line and column number.
|
|
540
|
+
* @param offset the 0 based offset into the string
|
|
541
|
+
*/
|
|
542
|
+
function offsetToPosForDisplay(offset) {
|
|
543
|
+
let pos = offsetToPos(offset);
|
|
544
|
+
pos.line += 1;
|
|
545
|
+
pos.character += 1;
|
|
546
|
+
return pos;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -32,7 +23,7 @@ function start(connection) {
|
|
|
32
23
|
let hasWorkspaceFolderCapability = false;
|
|
33
24
|
let hasDiagnosticRelatedInformationCapability = false;
|
|
34
25
|
connection.onInitialize((params) => {
|
|
35
|
-
connection.console.log("
|
|
26
|
+
connection.console.log("Initializing!");
|
|
36
27
|
const capabilities = params.capabilities;
|
|
37
28
|
// Does the client support the `workspace/configuration` request?
|
|
38
29
|
// If not, we fall back using global settings.
|
|
@@ -50,13 +41,13 @@ function start(connection) {
|
|
|
50
41
|
},
|
|
51
42
|
hoverProvider: true,
|
|
52
43
|
documentFormattingProvider: true,
|
|
53
|
-
}
|
|
44
|
+
},
|
|
54
45
|
};
|
|
55
46
|
if (hasWorkspaceFolderCapability) {
|
|
56
47
|
result.capabilities.workspace = {
|
|
57
48
|
workspaceFolders: {
|
|
58
|
-
supported: true
|
|
59
|
-
}
|
|
49
|
+
supported: true,
|
|
50
|
+
},
|
|
60
51
|
};
|
|
61
52
|
}
|
|
62
53
|
return result;
|
|
@@ -64,22 +55,27 @@ function start(connection) {
|
|
|
64
55
|
connection.onInitialized(() => {
|
|
65
56
|
if (hasConfigurationCapability) {
|
|
66
57
|
// Register for all configuration changes.
|
|
67
|
-
connection.client.register(vscode_languageserver_1.DidChangeConfigurationNotification.type, undefined);
|
|
58
|
+
void connection.client.register(vscode_languageserver_1.DidChangeConfigurationNotification.type, undefined);
|
|
68
59
|
}
|
|
69
60
|
if (hasWorkspaceFolderCapability) {
|
|
70
|
-
connection.workspace.onDidChangeWorkspaceFolders(_event => {
|
|
71
|
-
connection.console.log(
|
|
61
|
+
connection.workspace.onDidChangeWorkspaceFolders((_event) => {
|
|
62
|
+
connection.console.log("Workspace folder change event received.");
|
|
72
63
|
});
|
|
73
64
|
}
|
|
74
65
|
});
|
|
75
|
-
connection.onCompletion((
|
|
66
|
+
connection.onCompletion(({ position, textDocument }) => {
|
|
76
67
|
const document = documents.get(textDocument.uri);
|
|
77
68
|
if (!document) {
|
|
78
69
|
return [];
|
|
79
70
|
}
|
|
80
71
|
const parseResult = parseDocument(document);
|
|
81
|
-
return (0, completion_1.handleCompletion)({
|
|
82
|
-
|
|
72
|
+
return (0, completion_1.handleCompletion)({
|
|
73
|
+
parseResult: parseResult.parseResult,
|
|
74
|
+
getText: parseResult.getText,
|
|
75
|
+
metaByComp: metadataProvider,
|
|
76
|
+
offsetToPos: (offset) => document.positionAt(offset),
|
|
77
|
+
}, document.offsetAt(position));
|
|
78
|
+
});
|
|
83
79
|
connection.onCompletionResolve((completionItem) => {
|
|
84
80
|
return (0, completion_1.handleCompletionResolve)({ metaByComp: metadataProvider, item: completionItem });
|
|
85
81
|
});
|
|
@@ -93,7 +89,7 @@ function start(connection) {
|
|
|
93
89
|
node: parseResult.node,
|
|
94
90
|
getText,
|
|
95
91
|
metaByComp: metadataProvider,
|
|
96
|
-
offsetToPosition: (offset) => document.positionAt(offset)
|
|
92
|
+
offsetToPosition: (offset) => document.positionAt(offset),
|
|
97
93
|
};
|
|
98
94
|
return (0, hover_1.handleHover)(ctx, document.offsetAt(position));
|
|
99
95
|
});
|
|
@@ -102,8 +98,13 @@ function start(connection) {
|
|
|
102
98
|
if (!document) {
|
|
103
99
|
return null;
|
|
104
100
|
}
|
|
105
|
-
const { parseResult: { node }, getText } = parseDocument(document);
|
|
106
|
-
return (0, format_1.handleDocumentFormatting)({
|
|
101
|
+
const { parseResult: { node }, getText, } = parseDocument(document);
|
|
102
|
+
return (0, format_1.handleDocumentFormatting)({
|
|
103
|
+
node,
|
|
104
|
+
getText,
|
|
105
|
+
options,
|
|
106
|
+
offsetToPosition: (offset) => document.positionAt(offset),
|
|
107
|
+
});
|
|
107
108
|
});
|
|
108
109
|
const parsedDocuments = new Map();
|
|
109
110
|
function parseDocument(document) {
|
|
@@ -136,10 +137,10 @@ function start(connection) {
|
|
|
136
137
|
offsetToPos: (offset) => document.positionAt(offset),
|
|
137
138
|
};
|
|
138
139
|
const diagnostics = (0, diagnostic_1.getDiagnostics)(ctx);
|
|
139
|
-
connection.sendDiagnostics({
|
|
140
|
+
void connection.sendDiagnostics({
|
|
140
141
|
version: document.version,
|
|
141
142
|
uri: document.uri,
|
|
142
|
-
diagnostics
|
|
143
|
+
diagnostics,
|
|
143
144
|
});
|
|
144
145
|
}
|
|
145
146
|
// Make the text document manager listen on the connection
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
function
|
|
3
|
+
exports.offsetRangeToPosRange = offsetRangeToPosRange;
|
|
4
|
+
function offsetRangeToPosRange(offsetToPos, range) {
|
|
5
5
|
return {
|
|
6
6
|
start: offsetToPos(range.pos),
|
|
7
7
|
end: offsetToPos(range.end),
|
|
@@ -60,7 +60,7 @@ function handleCompletionResolve({ item, metaByComp: metaByComp, }) {
|
|
|
60
60
|
}
|
|
61
61
|
return item;
|
|
62
62
|
}
|
|
63
|
-
function handleCompletion({ parseResult: { node }, getText, metaByComp }, position) {
|
|
63
|
+
function handleCompletion({ parseResult: { node }, getText, metaByComp, offsetToPos }, position) {
|
|
64
64
|
const findRes = (0, utils_1.findTokenAtPos)(node, position);
|
|
65
65
|
if (!findRes) {
|
|
66
66
|
return null;
|
|
@@ -81,7 +81,7 @@ function handleCompletion({ parseResult: { node }, getText, metaByComp }, positi
|
|
|
81
81
|
const compName = getNameFromElement(matchingNode, getText);
|
|
82
82
|
if (!compName)
|
|
83
83
|
return defaultCompNames;
|
|
84
|
-
const compNameSuggestion =
|
|
84
|
+
const compNameSuggestion = closingComponentCompletionItem(compName, offsetToPos, position);
|
|
85
85
|
return [compNameSuggestion, ...defaultCompNames.map((c) => (Object.assign(Object.assign({}, c), { sortText: "1" })))];
|
|
86
86
|
}
|
|
87
87
|
return defaultCompNames;
|
|
@@ -247,6 +247,24 @@ function componentCompletionItem(componentName, sortingOrder) {
|
|
|
247
247
|
},
|
|
248
248
|
};
|
|
249
249
|
}
|
|
250
|
+
function closingComponentCompletionItem(componentName, offsetToPos, cursorOffset) {
|
|
251
|
+
const cursorPos = offsetToPos(cursorOffset);
|
|
252
|
+
const updatedText = /* TODO globals.clientSupports.insertReplaceEdit ? Handle this case : */ {
|
|
253
|
+
newText: `/${componentName}>`,
|
|
254
|
+
range: { start: cursorPos, end: cursorPos },
|
|
255
|
+
};
|
|
256
|
+
return {
|
|
257
|
+
label: `/${componentName}`,
|
|
258
|
+
kind: vscode_languageserver_1.CompletionItemKind.Constructor,
|
|
259
|
+
sortText: "0",
|
|
260
|
+
textEdit: updatedText,
|
|
261
|
+
data: {
|
|
262
|
+
metadataAccessInfo: {
|
|
263
|
+
componentName,
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
};
|
|
267
|
+
}
|
|
250
268
|
function markupContent(content) {
|
|
251
269
|
return {
|
|
252
270
|
kind: vscode_languageserver_1.MarkupKind.Markdown,
|
|
@@ -12,7 +12,7 @@ function getDiagnostics(ctx) {
|
|
|
12
12
|
function errorToLspDiag(e, offsetToPos) {
|
|
13
13
|
return {
|
|
14
14
|
severity: e.category,
|
|
15
|
-
range: (0, lsp_utils_1.
|
|
15
|
+
range: (0, lsp_utils_1.offsetRangeToPosRange)(offsetToPos, e),
|
|
16
16
|
message: e.message,
|
|
17
17
|
code: e.code,
|
|
18
18
|
};
|
|
@@ -60,7 +60,7 @@ function handleHoverCore({ node, getText, metaByComp }, position) {
|
|
|
60
60
|
metaByComp: metaByComp,
|
|
61
61
|
tagNameNode: parentNode,
|
|
62
62
|
identNode: atNode,
|
|
63
|
-
getText
|
|
63
|
+
getText,
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
case syntax_kind_1.SyntaxKind.AttributeKeyNode: {
|
|
@@ -87,7 +87,7 @@ function handleHover(ctx, position) {
|
|
|
87
87
|
kind: vscode_languageserver_1.MarkupKind.Markdown,
|
|
88
88
|
value,
|
|
89
89
|
},
|
|
90
|
-
range: (0, lsp_utils_1.
|
|
90
|
+
range: (0, lsp_utils_1.offsetRangeToPosRange)(ctx.offsetToPosition, range),
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
93
|
function hoverAttr({ metaByComp, attrKeyNode, parentStack, getText, }) {
|
|
@@ -3,8 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.deepFreeze = deepFreeze;
|
|
4
4
|
function deepFreeze(o) {
|
|
5
5
|
Object.freeze(o);
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
let oIsFunction = typeof o === "function";
|
|
7
|
+
let hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
Object.getOwnPropertyNames(o).forEach(function (prop) {
|
|
9
9
|
if (hasOwnProp.call(o, prop)
|
|
10
10
|
&& (oIsFunction ? prop !== 'caller' && prop !== 'callee' && prop !== 'arguments' : true)
|
|
@@ -183,7 +183,6 @@ class Lexer {
|
|
|
183
183
|
*/
|
|
184
184
|
fetch() {
|
|
185
185
|
// --- Captured constants used in nested functions
|
|
186
|
-
const lexer = this;
|
|
187
186
|
const input = this.input;
|
|
188
187
|
const startPos = this._prefetchedPos || input.position;
|
|
189
188
|
const line = input.line;
|
|
@@ -197,6 +196,17 @@ class Lexer {
|
|
|
197
196
|
let lastEndColumn = input.column;
|
|
198
197
|
let ch = null;
|
|
199
198
|
let useResolver = false;
|
|
199
|
+
/**
|
|
200
|
+
* Appends the last character to the token, and manages positions
|
|
201
|
+
*/
|
|
202
|
+
const appendTokenChar = () => {
|
|
203
|
+
text += ch;
|
|
204
|
+
this._prefetched = null;
|
|
205
|
+
this._prefetchedPos = null;
|
|
206
|
+
this._prefetchedColumn = null;
|
|
207
|
+
lastEndPos = input.position;
|
|
208
|
+
lastEndColumn = input.position;
|
|
209
|
+
};
|
|
200
210
|
// --- Start from the beginning
|
|
201
211
|
let phase = this.getStartingPhaseThenReset();
|
|
202
212
|
// --- Process all token characters
|
|
@@ -588,7 +598,8 @@ class Lexer {
|
|
|
588
598
|
if (isDecimalDigit(ch) || ch === "_") {
|
|
589
599
|
break;
|
|
590
600
|
}
|
|
591
|
-
else if (ch === "." &&
|
|
601
|
+
else if (ch === "." &&
|
|
602
|
+
(this.input.peek() === null || isDecimalDigit(this.input.peek()))) {
|
|
592
603
|
phase = LexerPhase.RealFractionalFirst;
|
|
593
604
|
tokenType = TokenType_1.TokenType.Unknown;
|
|
594
605
|
}
|
|
@@ -875,17 +886,6 @@ class Lexer {
|
|
|
875
886
|
appendTokenChar();
|
|
876
887
|
// --- Go on with parsing the next character
|
|
877
888
|
}
|
|
878
|
-
/**
|
|
879
|
-
* Appends the last character to the token, and manages positions
|
|
880
|
-
*/
|
|
881
|
-
function appendTokenChar() {
|
|
882
|
-
text += ch;
|
|
883
|
-
lexer._prefetched = null;
|
|
884
|
-
lexer._prefetchedPos = null;
|
|
885
|
-
lexer._prefetchedColumn = null;
|
|
886
|
-
lastEndPos = input.position;
|
|
887
|
-
lastEndColumn = input.position;
|
|
888
|
-
}
|
|
889
889
|
/**
|
|
890
890
|
* Packs the specified type of token to send back
|
|
891
891
|
*/
|
|
@@ -893,7 +893,9 @@ class Lexer {
|
|
|
893
893
|
var _a;
|
|
894
894
|
if (useResolver) {
|
|
895
895
|
tokenType =
|
|
896
|
-
(_a = resolverHash.get(text)) !== null && _a !== void 0 ? _a : (isIdStart(text[0]) && text[text.length - 1] !== "'"
|
|
896
|
+
(_a = resolverHash.get(text)) !== null && _a !== void 0 ? _a : (isIdStart(text[0]) && text[text.length - 1] !== "'"
|
|
897
|
+
? TokenType_1.TokenType.Identifier
|
|
898
|
+
: TokenType_1.TokenType.Unknown);
|
|
897
899
|
}
|
|
898
900
|
return {
|
|
899
901
|
text,
|
|
@@ -1059,7 +1061,11 @@ function isIdStart(ch) {
|
|
|
1059
1061
|
* @param ch Character to test
|
|
1060
1062
|
*/
|
|
1061
1063
|
function isIdContinuation(ch) {
|
|
1062
|
-
return (ch >= "a" && ch <= "z") ||
|
|
1064
|
+
return ((ch >= "a" && ch <= "z") ||
|
|
1065
|
+
(ch >= "A" && ch <= "Z") ||
|
|
1066
|
+
(ch >= "0" && ch <= "9") ||
|
|
1067
|
+
ch === "_" ||
|
|
1068
|
+
ch === "$");
|
|
1063
1069
|
}
|
|
1064
1070
|
/**
|
|
1065
1071
|
* Tests if a character is a binary digit
|
|
@@ -831,9 +831,16 @@ class Parser {
|
|
|
831
831
|
* : "finally" blockStatement
|
|
832
832
|
*/
|
|
833
833
|
parseTryStatement() {
|
|
834
|
+
const getBlock = () => {
|
|
835
|
+
const nextToken = this._lexer.peek();
|
|
836
|
+
if (nextToken.type !== TokenType_1.TokenType.LBrace) {
|
|
837
|
+
this.reportError("W012", nextToken);
|
|
838
|
+
return null;
|
|
839
|
+
}
|
|
840
|
+
return this.parseBlockStatement();
|
|
841
|
+
};
|
|
834
842
|
const startToken = this._lexer.peek();
|
|
835
843
|
let endToken = this._lexer.get();
|
|
836
|
-
const parser = this;
|
|
837
844
|
// --- Get "try" block
|
|
838
845
|
const tryB = getBlock();
|
|
839
846
|
let catchB;
|
|
@@ -888,14 +895,6 @@ class Parser {
|
|
|
888
895
|
catchV,
|
|
889
896
|
finallyB,
|
|
890
897
|
}, startToken, endToken);
|
|
891
|
-
function getBlock() {
|
|
892
|
-
const nextToken = parser._lexer.peek();
|
|
893
|
-
if (nextToken.type !== TokenType_1.TokenType.LBrace) {
|
|
894
|
-
parser.reportError("W012", nextToken);
|
|
895
|
-
return null;
|
|
896
|
-
}
|
|
897
|
-
return parser.parseBlockStatement();
|
|
898
|
-
}
|
|
899
898
|
}
|
|
900
899
|
/**
|
|
901
900
|
* Parses a switch statement
|
|
@@ -94,7 +94,6 @@ class StyleLexer {
|
|
|
94
94
|
*/
|
|
95
95
|
fetch() {
|
|
96
96
|
// --- Captured constants used in nested functions
|
|
97
|
-
const lexer = this;
|
|
98
97
|
const input = this.input;
|
|
99
98
|
const startPos = this._prefetchedPos || input.position;
|
|
100
99
|
this._lastFetchPosition = this.input.position;
|
|
@@ -105,6 +104,25 @@ class StyleLexer {
|
|
|
105
104
|
let ch = null;
|
|
106
105
|
let useResolver = false;
|
|
107
106
|
let stringWrapper = "";
|
|
107
|
+
/**
|
|
108
|
+
* Appends the last character to the token, and manages positions
|
|
109
|
+
*/
|
|
110
|
+
const appendTokenChar = () => {
|
|
111
|
+
text += ch;
|
|
112
|
+
this._prefetched = null;
|
|
113
|
+
this._prefetchedPos = null;
|
|
114
|
+
lastEndPos = input.position;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Fetches the next character from the input stream
|
|
118
|
+
*/
|
|
119
|
+
const fetchNextChar = () => {
|
|
120
|
+
if (!this._prefetched) {
|
|
121
|
+
this._prefetchedPos = input.position;
|
|
122
|
+
this._prefetched = input.get();
|
|
123
|
+
}
|
|
124
|
+
return this._prefetched;
|
|
125
|
+
};
|
|
108
126
|
// --- Start from the beginning
|
|
109
127
|
let phase = LexerPhase.Start;
|
|
110
128
|
// --- Process all token characters
|
|
@@ -246,32 +264,14 @@ class StyleLexer {
|
|
|
246
264
|
appendTokenChar();
|
|
247
265
|
// --- Go on with parsing the next character
|
|
248
266
|
}
|
|
249
|
-
/**
|
|
250
|
-
* Appends the last character to the token, and manages positions
|
|
251
|
-
*/
|
|
252
|
-
function appendTokenChar() {
|
|
253
|
-
text += ch;
|
|
254
|
-
lexer._prefetched = null;
|
|
255
|
-
lexer._prefetchedPos = null;
|
|
256
|
-
lastEndPos = input.position;
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Fetches the next character from the input stream
|
|
260
|
-
*/
|
|
261
|
-
function fetchNextChar() {
|
|
262
|
-
if (!lexer._prefetched) {
|
|
263
|
-
lexer._prefetchedPos = input.position;
|
|
264
|
-
lexer._prefetched = input.get();
|
|
265
|
-
}
|
|
266
|
-
return lexer._prefetched;
|
|
267
|
-
}
|
|
268
267
|
/**
|
|
269
268
|
* Packs the specified type of token to send back
|
|
270
269
|
*/
|
|
271
270
|
function makeToken() {
|
|
272
271
|
var _a;
|
|
273
272
|
if (useResolver) {
|
|
274
|
-
tokenType =
|
|
273
|
+
tokenType =
|
|
274
|
+
(_a = exports.styleKeywords[text]) !== null && _a !== void 0 ? _a : (isIdStart(text[0]) ? tokens_1.StyleTokenType.Identifier : tokens_1.StyleTokenType.Unknown);
|
|
275
275
|
}
|
|
276
276
|
return {
|
|
277
277
|
text,
|
|
@@ -313,7 +313,7 @@ function isWs(t) {
|
|
|
313
313
|
* @param ch Character to test
|
|
314
314
|
*/
|
|
315
315
|
function isIdStart(ch) {
|
|
316
|
-
return (ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z") || ch === "-" || ch === "_" || ch === "$";
|
|
316
|
+
return ((ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z") || ch === "-" || ch === "_" || ch === "$");
|
|
317
317
|
}
|
|
318
318
|
/**
|
|
319
319
|
* Tests if a character is an identifier continuation character
|