@player-tools/json-language-service 0.9.0 → 0.9.1--canary.189.4062

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.
@@ -1040,7 +1040,7 @@ function createValidationVisitor(ctx, sdk) {
1040
1040
  ctx.addViolation({
1041
1041
  node: findErrorNode(assetNode, issue.node),
1042
1042
  message: `Asset Validation Error - ${issue.type}: ${issue.message}`,
1043
- severity: import_vscode_languageserver_types6.DiagnosticSeverity.Error
1043
+ severity: issue.severity ?? import_vscode_languageserver_types6.DiagnosticSeverity.Error
1044
1044
  });
1045
1045
  }
1046
1046
  });
@@ -1263,6 +1263,16 @@ var XLRPlugin = class {
1263
1263
 
1264
1264
  // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/json-language-service/src/plugins/duplicate-id-plugin.ts
1265
1265
  var import_vscode_languageserver_types7 = require("vscode-languageserver-types");
1266
+ var checkParentTemplate = (node, depth = 0) => {
1267
+ if (node.parent) {
1268
+ if (isPropertyNode(node.parent) && node.parent.keyNode.value === "template") {
1269
+ depth += 1;
1270
+ return checkParentTemplate(node.parent, depth);
1271
+ }
1272
+ return checkParentTemplate(node.parent, depth);
1273
+ }
1274
+ return depth;
1275
+ };
1266
1276
  var generateID = (node) => {
1267
1277
  if (!node || node.type === "view") {
1268
1278
  return "";
@@ -1313,6 +1323,25 @@ var createValidationVisitor2 = (ctx) => {
1313
1323
  }
1314
1324
  const assetIDMap = viewInfo.get(view);
1315
1325
  const idInfo = assetIDMap?.get(id);
1326
+ const templateDepth = checkParentTemplate(assetNode);
1327
+ if (templateDepth > 0) {
1328
+ const expectedIndexElements = [];
1329
+ for (let i = 0; i < templateDepth; i++) {
1330
+ expectedIndexElements.push(`_index${i === 0 ? "" : i}_`);
1331
+ }
1332
+ const missingIndexSegments = expectedIndexElements.filter(
1333
+ (e) => !id.includes(e)
1334
+ );
1335
+ if (missingIndexSegments.length !== 0) {
1336
+ ctx.addViolation({
1337
+ node: assetNode,
1338
+ severity: import_vscode_languageserver_types7.DiagnosticSeverity.Error,
1339
+ message: `The id for this templated elements is missing the following index segments: ${missingIndexSegments.join(
1340
+ ", "
1341
+ )}`
1342
+ });
1343
+ }
1344
+ }
1316
1345
  if (idInfo) {
1317
1346
  if (!idInfo.handled) {
1318
1347
  const origViolation = createViolation(idInfo.original);
@@ -1659,43 +1688,47 @@ var applyAssetWrapperOrSwitch = (node, capability) => {
1659
1688
  })(node, capability);
1660
1689
  };
1661
1690
  var applyValueRefs = (node, capability) => {
1662
- return (0, import_xlr_sdk.simpleTransformGenerator)("object", "Assets", (inputNode) => {
1663
- const xlrNode = { ...inputNode };
1664
- for (const key in xlrNode.properties) {
1665
- if (key === "id" || key === "type") {
1666
- continue;
1667
- }
1668
- const value = xlrNode.properties[key];
1669
- if (value.node.type === "or") {
1670
- value.node.or.push({
1671
- type: "ref",
1672
- ref: "ExpressionRef"
1673
- });
1674
- value.node.or.push({
1675
- type: "ref",
1676
- ref: "BindingRef"
1677
- });
1678
- } else if ((0, import_xlr_utils.isPrimitiveTypeNode)(value.node)) {
1679
- const newUnionType = {
1680
- type: "or",
1681
- description: value.node.description,
1682
- or: [
1683
- value.node,
1684
- {
1685
- type: "ref",
1686
- ref: "ExpressionRef"
1687
- },
1688
- {
1689
- type: "ref",
1690
- ref: "BindingRef"
1691
- }
1692
- ]
1693
- };
1694
- value.node = newUnionType;
1691
+ return (0, import_xlr_sdk.simpleTransformGenerator)(
1692
+ "object",
1693
+ ["Assets", "Views"],
1694
+ (inputNode) => {
1695
+ const xlrNode = { ...inputNode };
1696
+ for (const key in xlrNode.properties) {
1697
+ if (key === "id") {
1698
+ continue;
1699
+ }
1700
+ const value = xlrNode.properties[key];
1701
+ if (value.node.type === "or") {
1702
+ value.node.or.push({
1703
+ type: "ref",
1704
+ ref: "ExpressionRef"
1705
+ });
1706
+ value.node.or.push({
1707
+ type: "ref",
1708
+ ref: "BindingRef"
1709
+ });
1710
+ } else if ((0, import_xlr_utils.isPrimitiveTypeNode)(value.node)) {
1711
+ const newUnionType = {
1712
+ type: "or",
1713
+ description: value.node.description,
1714
+ or: [
1715
+ value.node,
1716
+ {
1717
+ type: "ref",
1718
+ ref: "ExpressionRef"
1719
+ },
1720
+ {
1721
+ type: "ref",
1722
+ ref: "BindingRef"
1723
+ }
1724
+ ]
1725
+ };
1726
+ value.node = newUnionType;
1727
+ }
1695
1728
  }
1729
+ return xlrNode;
1696
1730
  }
1697
- return xlrNode;
1698
- })(node, capability);
1731
+ )(node, capability);
1699
1732
  };
1700
1733
  var applyTemplateProperty = (node, capability) => {
1701
1734
  return (0, import_xlr_sdk.simpleTransformGenerator)(