@platformos/platformos-language-server-common 0.0.11 → 0.0.12

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.
Files changed (35) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/TypeSystem.js +11 -5
  3. package/dist/TypeSystem.js.map +1 -1
  4. package/dist/codeActions/CodeActionsProvider.d.ts +1 -1
  5. package/dist/codeActions/providers/GenerateDocBlockProvider.d.ts +10 -0
  6. package/dist/codeActions/providers/GenerateDocBlockProvider.js +39 -0
  7. package/dist/codeActions/providers/GenerateDocBlockProvider.js.map +1 -0
  8. package/dist/commands/providers/GenerateDocBlockCommandProvider.d.ts +19 -0
  9. package/dist/commands/providers/GenerateDocBlockCommandProvider.js +64 -0
  10. package/dist/commands/providers/GenerateDocBlockCommandProvider.js.map +1 -0
  11. package/dist/completions/params/LiquidCompletionParams.js +7 -2
  12. package/dist/completions/params/LiquidCompletionParams.js.map +1 -1
  13. package/dist/documents/DocumentManager.js +0 -4
  14. package/dist/documents/DocumentManager.js.map +1 -1
  15. package/dist/documents/types.d.ts +1 -20
  16. package/dist/documents/types.js.map +1 -1
  17. package/dist/json/completions/providers/BlockTypeCompletionProvider.d.ts +4 -3
  18. package/dist/json/completions/providers/BlockTypeCompletionProvider.js +5 -10
  19. package/dist/json/completions/providers/BlockTypeCompletionProvider.js.map +1 -1
  20. package/dist/json/hover/providers/BlockSettingsHoverProvider.js +5 -10
  21. package/dist/json/hover/providers/BlockSettingsHoverProvider.js.map +1 -1
  22. package/dist/json/schemaSettings.d.ts +3 -3
  23. package/dist/json/schemaSettings.js.map +1 -1
  24. package/dist/renamed/handlers/BlockRenameHandler.d.ts +3 -3
  25. package/dist/renamed/handlers/BlockRenameHandler.js +86 -15
  26. package/dist/renamed/handlers/BlockRenameHandler.js.map +1 -1
  27. package/dist/renamed/handlers/SectionRenameHandler.d.ts +3 -3
  28. package/dist/renamed/handlers/SectionRenameHandler.js +3 -3
  29. package/dist/renamed/handlers/SectionRenameHandler.js.map +1 -1
  30. package/dist/tsconfig.tsbuildinfo +1 -1
  31. package/package.json +4 -4
  32. package/src/TypeSystem.ts +13 -5
  33. package/src/completions/params/LiquidCompletionParams.ts +7 -2
  34. package/src/documents/DocumentManager.ts +0 -4
  35. package/src/documents/types.ts +1 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformos/platformos-language-server-common",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "platformOS",
@@ -27,9 +27,9 @@
27
27
  "type-check": "tsc --noEmit -p ./tsconfig.json"
28
28
  },
29
29
  "dependencies": {
30
- "@platformos/liquid-html-parser": "^0.0.10",
31
- "@platformos/platformos-check-common": "0.0.11",
32
- "@platformos/platformos-graph": "0.0.11",
30
+ "@platformos/liquid-html-parser": "^0.0.11",
31
+ "@platformos/platformos-check-common": "0.0.12",
32
+ "@platformos/platformos-graph": "0.0.12",
33
33
  "@vscode/web-custom-data": "^0.4.6",
34
34
  "vscode-json-languageservice": "^5.7.1",
35
35
  "vscode-languageserver": "^9.0.1",
package/src/TypeSystem.ts CHANGED
@@ -868,12 +868,16 @@ async function buildSymbolsTable(
868
868
  }
869
869
  }
870
870
 
871
+ // For hash/array targets like function hash['key'] = 'partial', skip type tracking
872
+ const fnVarName = markup.name.name;
873
+ if (!fnVarName || markup.name.lookups.length > 0) return;
874
+
871
875
  // Track shape for potential hash_assign merging
872
876
  if (returnType && isShapeType(returnType)) {
873
- if (!variableShapes.has(markup.name)) {
874
- variableShapes.set(markup.name, []);
877
+ if (!variableShapes.has(fnVarName)) {
878
+ variableShapes.set(fnVarName, []);
875
879
  }
876
- variableShapes.get(markup.name)!.push({
880
+ variableShapes.get(fnVarName)!.push({
877
881
  shape: returnType.shape,
878
882
  rangeEnd: node.position.end,
879
883
  });
@@ -881,7 +885,7 @@ async function buildSymbolsTable(
881
885
 
882
886
  // Always add function variable to symbolsTable, using Untyped as fallback
883
887
  return {
884
- identifier: markup.name,
888
+ identifier: fnVarName,
885
889
  type: returnType ?? Untyped,
886
890
  range: [node.position.end],
887
891
  };
@@ -1568,7 +1572,11 @@ async function inferFunctionReturnType(
1568
1572
 
1569
1573
  await visit<SourceCodeType.LiquidHtml, void>(partialAst, {
1570
1574
  async LiquidTag(node) {
1571
- if (node.name === NamedTags.return && typeof node.markup !== 'string') {
1575
+ if (
1576
+ node.name === NamedTags.return &&
1577
+ node.markup !== null &&
1578
+ typeof node.markup !== 'string'
1579
+ ) {
1572
1580
  // markup is LiquidVariable - infer its type
1573
1581
  const type = inferType(node.markup, partialSymbolsTable, objectMap, filtersMap);
1574
1582
  // Flatten union types into individual types
@@ -228,7 +228,9 @@ function findCurrentNode(
228
228
  (isInLiquidLiquidTagContext(finder) && isCovered(cursor, current.blockStartPosition))
229
229
  ) {
230
230
  if (hasNonNullProperty(current, 'markup') && typeof current.markup !== 'string') {
231
- finder.current = Array.isArray(current.markup) ? current.markup.at(-1) : current.markup;
231
+ finder.current = Array.isArray(current.markup)
232
+ ? current.markup.at(-1)
233
+ : (current.markup ?? undefined);
232
234
  } else {
233
235
  // Exits the loop and the node is the thing to complete
234
236
  // (presumably name or something else)
@@ -244,7 +246,9 @@ function findCurrentNode(
244
246
 
245
247
  case NodeTypes.LiquidBranch:
246
248
  if (isCovered(cursor, current.blockStartPosition) && typeof current.markup !== 'string') {
247
- finder.current = Array.isArray(current.markup) ? current.markup.at(-1) : current.markup;
249
+ finder.current = Array.isArray(current.markup)
250
+ ? current.markup.at(-1)
251
+ : (current.markup ?? undefined);
248
252
  } else if (hasNonEmptyArrayProperty(current, 'children')) {
249
253
  finder.current = last(current.children);
250
254
  } else {
@@ -280,6 +284,7 @@ function findCurrentNode(
280
284
  case NodeTypes.YAMLFrontmatter:
281
285
  case NodeTypes.HtmlDoctype:
282
286
  case NodeTypes.HtmlComment:
287
+ case NodeTypes.HtmlProcessingInstruction:
283
288
  case NodeTypes.RawMarkup: {
284
289
  break;
285
290
  }
@@ -201,10 +201,6 @@ export class DocumentManager {
201
201
  ...sourceCode,
202
202
  textDocument,
203
203
  /** Lazy and only computed once per file version */
204
- getSchema: memo(async () => {
205
- return undefined;
206
- }),
207
- /** Lazy and only computed once per file version */
208
204
  getLiquidDoc: memo(async () => {
209
205
  const ast = sourceCode.ast;
210
206
  if (isError(ast)) return undefined;
@@ -1,18 +1,5 @@
1
- import { SourceCodeType, SourceCode } from '@platformos/platformos-check-common';
2
- import { JSONNode } from '@platformos/platformos-check-common';
1
+ import { SourceCodeType, SourceCode, DocDefinition } from '@platformos/platformos-check-common';
3
2
  import { TextDocument } from 'vscode-languageserver-textdocument';
4
- import { DocDefinition } from '@platformos/platformos-check-common';
5
-
6
- /**
7
- * Reserved for future use. platformOS does not use `{% schema %}` blocks,
8
- * so `getSchema()` always returns `undefined`.
9
- */
10
- export interface SchemaObject {
11
- parsed: any;
12
- validSchema?: unknown;
13
- ast: JSONNode | Error;
14
- offset: number;
15
- }
16
3
 
17
4
  /** Util type to add the common `textDocument` property to the SourceCode. */
18
5
  type _AugmentedSourceCode<SCT extends SourceCodeType = SourceCodeType> = SourceCode<SCT> & {
@@ -24,14 +11,7 @@ export type AugmentedJsonSourceCode = _AugmentedSourceCode<SourceCodeType.JSON>;
24
11
 
25
12
  export type AugmentedGraphQLSourceCode = _AugmentedSourceCode<SourceCodeType.GraphQL>;
26
13
 
27
- /**
28
- * AugmentedLiquidSourceCode may hold the schema for the section or block.
29
- *
30
- * We'll use the SourceCode as the source of truth since we won't need to care
31
- * about cache invalidation and will mean we'll parse the schema at most once.
32
- */
33
14
  export type AugmentedLiquidSourceCode = _AugmentedSourceCode<SourceCodeType.LiquidHtml> & {
34
- getSchema: () => Promise<SchemaObject | undefined>;
35
15
  getLiquidDoc: () => Promise<DocDefinition | undefined>;
36
16
  };
37
17