@platformos/platformos-language-server-common 0.0.10 → 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.
- package/CHANGELOG.md +17 -0
- package/dist/TypeSystem.js +11 -5
- package/dist/TypeSystem.js.map +1 -1
- package/dist/completions/params/LiquidCompletionParams.js +7 -2
- package/dist/completions/params/LiquidCompletionParams.js.map +1 -1
- package/dist/documents/DocumentManager.js +0 -4
- package/dist/documents/DocumentManager.js.map +1 -1
- package/dist/documents/types.d.ts +1 -20
- package/dist/documents/types.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/TypeSystem.ts +13 -5
- package/src/completions/params/LiquidCompletionParams.ts +7 -2
- package/src/documents/DocumentManager.ts +0 -4
- 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.
|
|
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.
|
|
31
|
-
"@platformos/platformos-check-common": "0.0.
|
|
32
|
-
"@platformos/platformos-graph": "0.0.
|
|
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(
|
|
874
|
-
variableShapes.set(
|
|
877
|
+
if (!variableShapes.has(fnVarName)) {
|
|
878
|
+
variableShapes.set(fnVarName, []);
|
|
875
879
|
}
|
|
876
|
-
variableShapes.get(
|
|
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:
|
|
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 (
|
|
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)
|
|
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)
|
|
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;
|
package/src/documents/types.ts
CHANGED
|
@@ -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
|
|