@player-tools/json-language-service 0.9.0 → 0.9.1--canary.196.4186
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/cjs/index.cjs +86 -43
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +86 -43
- package/dist/index.mjs +86 -43
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/__tests__/__snapshots__/service.test.ts.snap +14 -0
- package/src/plugins/__tests__/asset-wrapper-array-plugin.test.ts +15 -0
- package/src/plugins/__tests__/duplicate-id-plugin.test.ts +89 -0
- package/src/plugins/__tests__/missing-asset-wrapper-plugin.test.ts +16 -1
- package/src/plugins/duplicate-id-plugin.ts +41 -1
- package/src/plugins/xlr-plugin.ts +32 -9
- package/src/xlr/__tests__/__snapshots__/transform.test.ts.snap +17 -3
- package/src/xlr/transforms.ts +40 -36
package/dist/cjs/index.cjs
CHANGED
|
@@ -1004,6 +1004,9 @@ var SchemaInfoPlugin = class {
|
|
|
1004
1004
|
|
|
1005
1005
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-service/src/plugins/xlr-plugin.ts
|
|
1006
1006
|
var import_vscode_languageserver_types6 = require("vscode-languageserver-types");
|
|
1007
|
+
function isError(issue) {
|
|
1008
|
+
return issue.severity === import_vscode_languageserver_types6.DiagnosticSeverity.Error;
|
|
1009
|
+
}
|
|
1007
1010
|
var findErrorNode = (rootNode, nodeToFind) => {
|
|
1008
1011
|
const children = [rootNode];
|
|
1009
1012
|
while (children.length > 0) {
|
|
@@ -1017,6 +1020,9 @@ var findErrorNode = (rootNode, nodeToFind) => {
|
|
|
1017
1020
|
}
|
|
1018
1021
|
return rootNode;
|
|
1019
1022
|
};
|
|
1023
|
+
var translateSeverity = (severity) => {
|
|
1024
|
+
return severity;
|
|
1025
|
+
};
|
|
1020
1026
|
function createValidationVisitor(ctx, sdk) {
|
|
1021
1027
|
const nodesWithErrors = /* @__PURE__ */ new Set();
|
|
1022
1028
|
return {
|
|
@@ -1035,13 +1041,15 @@ function createValidationVisitor(ctx, sdk) {
|
|
|
1035
1041
|
assetNode.jsonNode
|
|
1036
1042
|
);
|
|
1037
1043
|
validationIssues.forEach((issue) => {
|
|
1038
|
-
if (!nodesWithErrors.has(issue.node)
|
|
1039
|
-
nodesWithErrors.add(issue.node);
|
|
1044
|
+
if (!(nodesWithErrors.has(issue.node) && isError(issue))) {
|
|
1040
1045
|
ctx.addViolation({
|
|
1041
1046
|
node: findErrorNode(assetNode, issue.node),
|
|
1042
|
-
message: `Asset Validation Error - ${issue.type}: ${issue.message}
|
|
1043
|
-
severity:
|
|
1047
|
+
message: isError(issue) ? `Asset Validation Error - ${issue.type}: ${issue.message}` : issue.message,
|
|
1048
|
+
severity: translateSeverity(issue.severity)
|
|
1044
1049
|
});
|
|
1050
|
+
if (isError(issue)) {
|
|
1051
|
+
nodesWithErrors.add(issue.node);
|
|
1052
|
+
}
|
|
1045
1053
|
}
|
|
1046
1054
|
});
|
|
1047
1055
|
},
|
|
@@ -1060,13 +1068,15 @@ function createValidationVisitor(ctx, sdk) {
|
|
|
1060
1068
|
viewNode.jsonNode
|
|
1061
1069
|
);
|
|
1062
1070
|
validationIssues.forEach((issue) => {
|
|
1063
|
-
if (!nodesWithErrors.has(issue.node)
|
|
1064
|
-
nodesWithErrors.add(issue.node);
|
|
1071
|
+
if (!(nodesWithErrors.has(issue.node) && isError(issue))) {
|
|
1065
1072
|
ctx.addViolation({
|
|
1066
1073
|
node: findErrorNode(viewNode, issue.node),
|
|
1067
|
-
message: `View Validation Error - ${issue.type}: ${issue.message}
|
|
1068
|
-
severity:
|
|
1074
|
+
message: isError(issue) ? `View Validation Error - ${issue.type}: ${issue.message}` : issue.message,
|
|
1075
|
+
severity: translateSeverity(issue.severity)
|
|
1069
1076
|
});
|
|
1077
|
+
if (isError(issue)) {
|
|
1078
|
+
nodesWithErrors.add(issue.node);
|
|
1079
|
+
}
|
|
1070
1080
|
}
|
|
1071
1081
|
});
|
|
1072
1082
|
},
|
|
@@ -1263,6 +1273,16 @@ var XLRPlugin = class {
|
|
|
1263
1273
|
|
|
1264
1274
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-service/src/plugins/duplicate-id-plugin.ts
|
|
1265
1275
|
var import_vscode_languageserver_types7 = require("vscode-languageserver-types");
|
|
1276
|
+
var checkParentTemplate = (node, depth = 0) => {
|
|
1277
|
+
if (node.parent) {
|
|
1278
|
+
if (isPropertyNode(node.parent) && node.parent.keyNode.value === "template") {
|
|
1279
|
+
depth += 1;
|
|
1280
|
+
return checkParentTemplate(node.parent, depth);
|
|
1281
|
+
}
|
|
1282
|
+
return checkParentTemplate(node.parent, depth);
|
|
1283
|
+
}
|
|
1284
|
+
return depth;
|
|
1285
|
+
};
|
|
1266
1286
|
var generateID = (node) => {
|
|
1267
1287
|
if (!node || node.type === "view") {
|
|
1268
1288
|
return "";
|
|
@@ -1313,6 +1333,25 @@ var createValidationVisitor2 = (ctx) => {
|
|
|
1313
1333
|
}
|
|
1314
1334
|
const assetIDMap = viewInfo.get(view);
|
|
1315
1335
|
const idInfo = assetIDMap?.get(id);
|
|
1336
|
+
const templateDepth = checkParentTemplate(assetNode);
|
|
1337
|
+
if (templateDepth > 0) {
|
|
1338
|
+
const expectedIndexElements = [];
|
|
1339
|
+
for (let i = 0; i < templateDepth; i++) {
|
|
1340
|
+
expectedIndexElements.push(`_index${i === 0 ? "" : i}_`);
|
|
1341
|
+
}
|
|
1342
|
+
const missingIndexSegments = expectedIndexElements.filter(
|
|
1343
|
+
(e) => !id.includes(e)
|
|
1344
|
+
);
|
|
1345
|
+
if (missingIndexSegments.length !== 0) {
|
|
1346
|
+
ctx.addViolation({
|
|
1347
|
+
node: assetNode,
|
|
1348
|
+
severity: import_vscode_languageserver_types7.DiagnosticSeverity.Error,
|
|
1349
|
+
message: `The id for this templated elements is missing the following index segments: ${missingIndexSegments.join(
|
|
1350
|
+
", "
|
|
1351
|
+
)}`
|
|
1352
|
+
});
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1316
1355
|
if (idInfo) {
|
|
1317
1356
|
if (!idInfo.handled) {
|
|
1318
1357
|
const origViolation = createViolation(idInfo.original);
|
|
@@ -1659,43 +1698,47 @@ var applyAssetWrapperOrSwitch = (node, capability) => {
|
|
|
1659
1698
|
})(node, capability);
|
|
1660
1699
|
};
|
|
1661
1700
|
var applyValueRefs = (node, capability) => {
|
|
1662
|
-
return (0, import_xlr_sdk.simpleTransformGenerator)(
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1701
|
+
return (0, import_xlr_sdk.simpleTransformGenerator)(
|
|
1702
|
+
"object",
|
|
1703
|
+
["Assets", "Views"],
|
|
1704
|
+
(inputNode) => {
|
|
1705
|
+
const xlrNode = { ...inputNode };
|
|
1706
|
+
for (const key in xlrNode.properties) {
|
|
1707
|
+
if (key === "id") {
|
|
1708
|
+
continue;
|
|
1709
|
+
}
|
|
1710
|
+
const value = xlrNode.properties[key];
|
|
1711
|
+
if (value.node.type === "or") {
|
|
1712
|
+
value.node.or.push({
|
|
1713
|
+
type: "ref",
|
|
1714
|
+
ref: "ExpressionRef"
|
|
1715
|
+
});
|
|
1716
|
+
value.node.or.push({
|
|
1717
|
+
type: "ref",
|
|
1718
|
+
ref: "BindingRef"
|
|
1719
|
+
});
|
|
1720
|
+
} else if ((0, import_xlr_utils.isPrimitiveTypeNode)(value.node)) {
|
|
1721
|
+
const newUnionType = {
|
|
1722
|
+
type: "or",
|
|
1723
|
+
description: value.node.description,
|
|
1724
|
+
or: [
|
|
1725
|
+
value.node,
|
|
1726
|
+
{
|
|
1727
|
+
type: "ref",
|
|
1728
|
+
ref: "ExpressionRef"
|
|
1729
|
+
},
|
|
1730
|
+
{
|
|
1731
|
+
type: "ref",
|
|
1732
|
+
ref: "BindingRef"
|
|
1733
|
+
}
|
|
1734
|
+
]
|
|
1735
|
+
};
|
|
1736
|
+
value.node = newUnionType;
|
|
1737
|
+
}
|
|
1695
1738
|
}
|
|
1739
|
+
return xlrNode;
|
|
1696
1740
|
}
|
|
1697
|
-
|
|
1698
|
-
})(node, capability);
|
|
1741
|
+
)(node, capability);
|
|
1699
1742
|
};
|
|
1700
1743
|
var applyTemplateProperty = (node, capability) => {
|
|
1701
1744
|
return (0, import_xlr_sdk.simpleTransformGenerator)(
|