funkscript 0.2.4 → 0.2.7
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/README.md +23 -5
- package/dist/ast/types.d.ts.map +1 -1
- package/dist/ast/types.js.map +1 -1
- package/dist/ast/walk.d.ts.map +1 -1
- package/dist/ast/walk.js.map +1 -1
- package/dist/cli/build-bun.d.ts.map +1 -1
- package/dist/cli/build-bun.js.map +1 -1
- package/dist/cli/build-watch.d.ts.map +1 -1
- package/dist/cli/build-watch.js +9 -27
- package/dist/cli/build-watch.js.map +1 -1
- package/dist/cli/build.d.ts +1 -1
- package/dist/cli/build.d.ts.map +1 -1
- package/dist/cli/build.js +3 -58
- package/dist/cli/build.js.map +1 -1
- package/dist/cli/check-policy.d.ts +9 -0
- package/dist/cli/check-policy.d.ts.map +1 -0
- package/dist/cli/check-policy.js +39 -0
- package/dist/cli/check-policy.js.map +1 -0
- package/dist/cli/check.d.ts.map +1 -1
- package/dist/cli/check.js +16 -30
- package/dist/cli/check.js.map +1 -1
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +11 -0
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/doc.d.ts.map +1 -1
- package/dist/cli/doc.js.map +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +5 -7
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/emit.d.ts +1 -1
- package/dist/cli/emit.d.ts.map +1 -1
- package/dist/cli/emit.js.map +1 -1
- package/dist/cli/explain.d.ts.map +1 -1
- package/dist/cli/explain.js.map +1 -1
- package/dist/cli/fmt.d.ts.map +1 -1
- package/dist/cli/fmt.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +3 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init.d.ts +1 -1
- package/dist/cli/init.d.ts.map +1 -1
- package/dist/cli/init.js +66 -21
- package/dist/cli/init.js.map +1 -1
- package/dist/cli/io.d.ts.map +1 -1
- package/dist/cli/io.js.map +1 -1
- package/dist/cli/pipeline-style.d.ts.map +1 -1
- package/dist/cli/pipeline-style.js.map +1 -1
- package/dist/cli/query.d.ts +3 -0
- package/dist/cli/query.d.ts.map +1 -0
- package/dist/cli/query.js +152 -0
- package/dist/cli/query.js.map +1 -0
- package/dist/cli/repl.d.ts.map +1 -1
- package/dist/cli/repl.js.map +1 -1
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +2 -29
- package/dist/cli/run.js.map +1 -1
- package/dist/cli/test.d.ts +1 -1
- package/dist/cli/test.d.ts.map +1 -1
- package/dist/cli/test.js.map +1 -1
- package/dist/cli/tsc.d.ts.map +1 -1
- package/dist/cli/tsc.js +6 -8
- package/dist/cli/tsc.js.map +1 -1
- package/dist/cli/typecheck.d.ts.map +1 -1
- package/dist/cli/typecheck.js.map +1 -1
- package/dist/compiler/ast-inspection.d.ts.map +1 -1
- package/dist/compiler/ast-inspection.js.map +1 -1
- package/dist/compiler/boolean-operators.d.ts.map +1 -1
- package/dist/compiler/boolean-operators.js +12 -2
- package/dist/compiler/boolean-operators.js.map +1 -1
- package/dist/compiler/check.d.ts.map +1 -1
- package/dist/compiler/check.js +113 -131
- package/dist/compiler/check.js.map +1 -1
- package/dist/compiler/diagnostics-json.d.ts +73 -0
- package/dist/compiler/diagnostics-json.d.ts.map +1 -0
- package/dist/compiler/diagnostics-json.js +957 -0
- package/dist/compiler/diagnostics-json.js.map +1 -0
- package/dist/compiler/diagnostics.d.ts.map +1 -1
- package/dist/compiler/diagnostics.js.map +1 -1
- package/dist/compiler/effect-mutation-rule.d.ts.map +1 -1
- package/dist/compiler/effect-mutation-rule.js.map +1 -1
- package/dist/compiler/entry-rules.d.ts.map +1 -1
- package/dist/compiler/entry-rules.js.map +1 -1
- package/dist/compiler/escape-audit.d.ts +46 -0
- package/dist/compiler/escape-audit.d.ts.map +1 -0
- package/dist/compiler/escape-audit.js +682 -0
- package/dist/compiler/escape-audit.js.map +1 -0
- package/dist/compiler/incremental-build.d.ts.map +1 -1
- package/dist/compiler/incremental-build.js.map +1 -1
- package/dist/compiler/incremental-dependencies.d.ts.map +1 -1
- package/dist/compiler/incremental-dependencies.js.map +1 -1
- package/dist/compiler/js-interop-nullability.d.ts.map +1 -1
- package/dist/compiler/js-interop-nullability.js.map +1 -1
- package/dist/compiler/modules/output-collisions.d.ts.map +1 -1
- package/dist/compiler/modules/output-collisions.js.map +1 -1
- package/dist/compiler/modules/output-plan.d.ts.map +1 -1
- package/dist/compiler/modules/output-plan.js +10 -5
- package/dist/compiler/modules/output-plan.js.map +1 -1
- package/dist/compiler/modules/resolution.d.ts.map +1 -1
- package/dist/compiler/modules/resolution.js +2 -1
- package/dist/compiler/modules/resolution.js.map +1 -1
- package/dist/compiler/modules/source-files.d.ts +5 -0
- package/dist/compiler/modules/source-files.d.ts.map +1 -0
- package/dist/compiler/modules/source-files.js +13 -0
- package/dist/compiler/modules/source-files.js.map +1 -0
- package/dist/compiler/numeric-comparisons.d.ts.map +1 -1
- package/dist/compiler/numeric-comparisons.js +13 -7
- package/dist/compiler/numeric-comparisons.js.map +1 -1
- package/dist/compiler/optional-arguments.d.ts.map +1 -1
- package/dist/compiler/optional-arguments.js.map +1 -1
- package/dist/compiler/package-fingerprint.d.ts.map +1 -1
- package/dist/compiler/package-fingerprint.js.map +1 -1
- package/dist/compiler/package-record-contracts.d.ts.map +1 -1
- package/dist/compiler/package-record-contracts.js.map +1 -1
- package/dist/compiler/pipelines/catalog.d.ts.map +1 -1
- package/dist/compiler/pipelines/catalog.js.map +1 -1
- package/dist/compiler/pipelines/companions.d.ts.map +1 -1
- package/dist/compiler/pipelines/companions.js.map +1 -1
- package/dist/compiler/pipelines/resolution.d.ts.map +1 -1
- package/dist/compiler/pipelines/resolution.js +24 -23
- package/dist/compiler/pipelines/resolution.js.map +1 -1
- package/dist/compiler/project-config.d.ts.map +1 -1
- package/dist/compiler/project-config.js +29 -19
- package/dist/compiler/project-config.js.map +1 -1
- package/dist/compiler/query.d.ts +53 -0
- package/dist/compiler/query.d.ts.map +1 -0
- package/dist/compiler/query.js +781 -0
- package/dist/compiler/query.js.map +1 -0
- package/dist/compiler/record-contracts.d.ts.map +1 -1
- package/dist/compiler/record-contracts.js.map +1 -1
- package/dist/compiler/rules/control-flow.d.ts.map +1 -1
- package/dist/compiler/rules/control-flow.js.map +1 -1
- package/dist/compiler/rules/diagnostic.d.ts.map +1 -1
- package/dist/compiler/rules/diagnostic.js.map +1 -1
- package/dist/compiler/rules/module-scope-refs.d.ts.map +1 -1
- package/dist/compiler/rules/module-scope-refs.js.map +1 -1
- package/dist/compiler/rules/resource-escape.d.ts +7 -0
- package/dist/compiler/rules/resource-escape.d.ts.map +1 -0
- package/dist/compiler/rules/resource-escape.js +146 -0
- package/dist/compiler/rules/resource-escape.js.map +1 -0
- package/dist/compiler/rules/resource-providers.d.ts +19 -0
- package/dist/compiler/rules/resource-providers.d.ts.map +1 -0
- package/dist/compiler/rules/resource-providers.js +222 -0
- package/dist/compiler/rules/resource-providers.js.map +1 -0
- package/dist/compiler/schemas/analysis.d.ts.map +1 -1
- package/dist/compiler/schemas/analysis.js.map +1 -1
- package/dist/compiler/schemas/imported-record-functions.d.ts.map +1 -1
- package/dist/compiler/schemas/imported-record-functions.js.map +1 -1
- package/dist/compiler/schemas/imported-schemas.d.ts.map +1 -1
- package/dist/compiler/schemas/imported-schemas.js.map +1 -1
- package/dist/compiler/source-map.d.ts.map +1 -1
- package/dist/compiler/source-map.js +2 -7
- package/dist/compiler/source-map.js.map +1 -1
- package/dist/compiler/type-view-paths.d.ts +6 -0
- package/dist/compiler/type-view-paths.d.ts.map +1 -0
- package/dist/compiler/type-view-paths.js +12 -0
- package/dist/compiler/type-view-paths.js.map +1 -0
- package/dist/compiler/typescript-context.d.ts.map +1 -1
- package/dist/compiler/typescript-context.js +5 -7
- package/dist/compiler/typescript-context.js.map +1 -1
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js.map +1 -1
- package/dist/emitter/assemblyscript.d.ts.map +1 -1
- package/dist/emitter/assemblyscript.js +120 -136
- package/dist/emitter/assemblyscript.js.map +1 -1
- package/dist/emitter/declarations.d.ts.map +1 -1
- package/dist/emitter/declarations.js.map +1 -1
- package/dist/emitter/emitter.d.ts +3 -1
- package/dist/emitter/emitter.d.ts.map +1 -1
- package/dist/emitter/emitter.js +10 -1
- package/dist/emitter/emitter.js.map +1 -1
- package/dist/emitter/imports.d.ts.map +1 -1
- package/dist/emitter/imports.js.map +1 -1
- package/dist/emitter/indent.d.ts.map +1 -1
- package/dist/emitter/indent.js.map +1 -1
- package/dist/emitter/jsx.d.ts.map +1 -1
- package/dist/emitter/jsx.js.map +1 -1
- package/dist/emitter/local-bindings.d.ts.map +1 -1
- package/dist/emitter/local-bindings.js.map +1 -1
- package/dist/emitter/match.d.ts.map +1 -1
- package/dist/emitter/match.js.map +1 -1
- package/dist/emitter/runtime-helpers.d.ts.map +1 -1
- package/dist/emitter/runtime-helpers.js.map +1 -1
- package/dist/emitter/schemas.d.ts.map +1 -1
- package/dist/emitter/schemas.js.map +1 -1
- package/dist/emitter/statements.d.ts +1 -0
- package/dist/emitter/statements.d.ts.map +1 -1
- package/dist/emitter/statements.js +1 -0
- package/dist/emitter/statements.js.map +1 -1
- package/dist/emitter/tagged-match.d.ts.map +1 -1
- package/dist/emitter/tagged-match.js.map +1 -1
- package/dist/emitter/types.d.ts.map +1 -1
- package/dist/emitter/types.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/formatter/comments.d.ts.map +1 -1
- package/dist/formatter/comments.js +13 -0
- package/dist/formatter/comments.js.map +1 -1
- package/dist/formatter/index.d.ts +9 -0
- package/dist/formatter/index.d.ts.map +1 -1
- package/dist/formatter/index.js +215 -5
- package/dist/formatter/index.js.map +1 -1
- package/dist/formatter/operator-precedence.d.ts.map +1 -1
- package/dist/formatter/operator-precedence.js.map +1 -1
- package/dist/formatter/prettier.d.ts.map +1 -1
- package/dist/formatter/prettier.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/interop/callback.d.ts.map +1 -1
- package/dist/interop/callback.js.map +1 -1
- package/dist/interop/js.d.ts.map +1 -1
- package/dist/interop/js.js.map +1 -1
- package/dist/interop/record.d.ts.map +1 -1
- package/dist/interop/record.js.map +1 -1
- package/dist/interop/valibot.d.ts.map +1 -1
- package/dist/interop/valibot.js.map +1 -1
- package/dist/interop/zod.d.ts.map +1 -1
- package/dist/interop/zod.js.map +1 -1
- package/dist/lexer/lexer.d.ts +1 -0
- package/dist/lexer/lexer.d.ts.map +1 -1
- package/dist/lexer/lexer.js +26 -10
- package/dist/lexer/lexer.js.map +1 -1
- package/dist/lexer/tokens.d.ts.map +1 -1
- package/dist/lexer/tokens.js.map +1 -1
- package/dist/lsp/code-action-worker.d.ts.map +1 -1
- package/dist/lsp/code-action-worker.js.map +1 -1
- package/dist/lsp/completion.d.ts +25 -0
- package/dist/lsp/completion.d.ts.map +1 -1
- package/dist/lsp/completion.js +1114 -51
- package/dist/lsp/completion.js.map +1 -1
- package/dist/lsp/definition.d.ts +2 -0
- package/dist/lsp/definition.d.ts.map +1 -1
- package/dist/lsp/definition.js +52 -58
- package/dist/lsp/definition.js.map +1 -1
- package/dist/lsp/diagnostics-worker.d.ts.map +1 -1
- package/dist/lsp/diagnostics-worker.js +1 -1
- package/dist/lsp/diagnostics-worker.js.map +1 -1
- package/dist/lsp/docs.d.ts +1 -1
- package/dist/lsp/docs.d.ts.map +1 -1
- package/dist/lsp/docs.js +4 -3
- package/dist/lsp/docs.js.map +1 -1
- package/dist/lsp/error-channel.d.ts.map +1 -1
- package/dist/lsp/error-channel.js.map +1 -1
- package/dist/lsp/hover.d.ts +5 -1
- package/dist/lsp/hover.d.ts.map +1 -1
- package/dist/lsp/hover.js +1016 -46
- package/dist/lsp/hover.js.map +1 -1
- package/dist/lsp/imports.d.ts +2 -0
- package/dist/lsp/imports.d.ts.map +1 -1
- package/dist/lsp/imports.js +45 -21
- package/dist/lsp/imports.js.map +1 -1
- package/dist/lsp/index.d.ts.map +1 -1
- package/dist/lsp/index.js.map +1 -1
- package/dist/lsp/inlay-hints.d.ts.map +1 -1
- package/dist/lsp/inlay-hints.js.map +1 -1
- package/dist/lsp/interop-rename.d.ts.map +1 -1
- package/dist/lsp/interop-rename.js.map +1 -1
- package/dist/lsp/match-arms.d.ts.map +1 -1
- package/dist/lsp/match-arms.js.map +1 -1
- package/dist/lsp/navigation.d.ts +1 -1
- package/dist/lsp/navigation.d.ts.map +1 -1
- package/dist/lsp/navigation.js +30 -12
- package/dist/lsp/navigation.js.map +1 -1
- package/dist/lsp/parsed-documents.d.ts.map +1 -1
- package/dist/lsp/parsed-documents.js.map +1 -1
- package/dist/lsp/range-format.d.ts +4 -0
- package/dist/lsp/range-format.d.ts.map +1 -0
- package/dist/lsp/range-format.js +88 -0
- package/dist/lsp/range-format.js.map +1 -0
- package/dist/lsp/rename-worker.d.ts.map +1 -1
- package/dist/lsp/rename-worker.js.map +1 -1
- package/dist/lsp/schema-import-hover.d.ts +8 -0
- package/dist/lsp/schema-import-hover.d.ts.map +1 -0
- package/dist/lsp/schema-import-hover.js +52 -0
- package/dist/lsp/schema-import-hover.js.map +1 -0
- package/dist/lsp/server.d.ts +3 -1
- package/dist/lsp/server.d.ts.map +1 -1
- package/dist/lsp/server.js +73 -48
- package/dist/lsp/server.js.map +1 -1
- package/dist/lsp/signature-help.d.ts +6 -0
- package/dist/lsp/signature-help.d.ts.map +1 -0
- package/dist/lsp/signature-help.js +183 -0
- package/dist/lsp/signature-help.js.map +1 -0
- package/dist/lsp/thunk-pipeline.d.ts.map +1 -1
- package/dist/lsp/thunk-pipeline.js.map +1 -1
- package/dist/lsp/validation.d.ts.map +1 -1
- package/dist/lsp/validation.js +3 -2
- package/dist/lsp/validation.js.map +1 -1
- package/dist/lsp/workspace.d.ts +3 -1
- package/dist/lsp/workspace.d.ts.map +1 -1
- package/dist/lsp/workspace.js +66 -10
- package/dist/lsp/workspace.js.map +1 -1
- package/dist/parser/declarations.d.ts.map +1 -1
- package/dist/parser/declarations.js +22 -1
- package/dist/parser/declarations.js.map +1 -1
- package/dist/parser/errors.d.ts.map +1 -1
- package/dist/parser/errors.js.map +1 -1
- package/dist/parser/jsx.d.ts.map +1 -1
- package/dist/parser/jsx.js.map +1 -1
- package/dist/parser/operator-expressions.d.ts.map +1 -1
- package/dist/parser/operator-expressions.js.map +1 -1
- package/dist/parser/parser.d.ts.map +1 -1
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/patterns.d.ts.map +1 -1
- package/dist/parser/patterns.js.map +1 -1
- package/dist/parser/pipeline-expressions.d.ts.map +1 -1
- package/dist/parser/pipeline-expressions.js.map +1 -1
- package/dist/parser/scope.d.ts.map +1 -1
- package/dist/parser/scope.js.map +1 -1
- package/dist/parser/statements.d.ts.map +1 -1
- package/dist/parser/statements.js.map +1 -1
- package/dist/parser/types.d.ts.map +1 -1
- package/dist/parser/types.js.map +1 -1
- package/dist/plugins/bun-preload.d.ts.map +1 -1
- package/dist/plugins/bun-preload.js.map +1 -1
- package/dist/plugins/bun.d.ts +2 -18
- package/dist/plugins/bun.d.ts.map +1 -1
- package/dist/plugins/bun.js +5 -30
- package/dist/plugins/bun.js.map +1 -1
- package/dist/plugins/esbuild.d.ts +1 -1
- package/dist/plugins/esbuild.d.ts.map +1 -1
- package/dist/plugins/esbuild.js +10 -36
- package/dist/plugins/esbuild.js.map +1 -1
- package/dist/plugins/server-boundary.d.ts +14 -0
- package/dist/plugins/server-boundary.d.ts.map +1 -0
- package/dist/plugins/server-boundary.js +25 -0
- package/dist/plugins/server-boundary.js.map +1 -0
- package/dist/plugins/type-view.d.ts.map +1 -1
- package/dist/plugins/type-view.js +5 -3
- package/dist/plugins/type-view.js.map +1 -1
- package/dist/plugins/vite.d.ts +2 -18
- package/dist/plugins/vite.d.ts.map +1 -1
- package/dist/plugins/vite.js +4 -29
- package/dist/plugins/vite.js.map +1 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/tooling/doc.d.ts.map +1 -1
- package/dist/tooling/doc.js.map +1 -1
- package/dist/tooling/idiomatic.d.ts.map +1 -1
- package/dist/tooling/idiomatic.js.map +1 -1
- package/dist/tooling/pipeline-style.d.ts.map +1 -1
- package/dist/tooling/pipeline-style.js.map +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +13 -6
- package/src/cli/build-watch.ts +10 -29
- package/src/cli/build.ts +9 -60
- package/src/cli/check-policy.ts +54 -0
- package/src/cli/check.ts +19 -31
- package/src/cli/commands.ts +13 -0
- package/src/cli/doctor.ts +10 -7
- package/src/cli/index.ts +3 -0
- package/src/cli/init.ts +66 -21
- package/src/cli/query.ts +191 -0
- package/src/cli/run.ts +5 -30
- package/src/cli/tsc.ts +10 -8
- package/src/compiler/boolean-operators.ts +11 -2
- package/src/compiler/check.ts +152 -180
- package/src/compiler/diagnostics-json.ts +1205 -0
- package/src/compiler/escape-audit.ts +913 -0
- package/src/compiler/modules/output-plan.ts +11 -9
- package/src/compiler/modules/resolution.ts +2 -1
- package/src/compiler/modules/source-files.ts +13 -0
- package/src/compiler/numeric-comparisons.ts +14 -8
- package/src/compiler/pipelines/resolution.ts +30 -26
- package/src/compiler/project-config.ts +30 -19
- package/src/compiler/query.ts +1177 -0
- package/src/compiler/rules/resource-escape.ts +223 -0
- package/src/compiler/rules/resource-providers.ts +293 -0
- package/src/compiler/source-map.ts +3 -7
- package/src/compiler/type-view-paths.ts +10 -0
- package/src/compiler/typescript-context.ts +6 -7
- package/src/emitter/assemblyscript.ts +101 -147
- package/src/emitter/emitter.ts +13 -1
- package/src/emitter/statements.ts +2 -0
- package/src/formatter/comments.ts +14 -0
- package/src/formatter/index.ts +299 -4
- package/src/index.ts +3 -0
- package/src/lexer/lexer.ts +39 -20
- package/src/lsp/completion.ts +1452 -66
- package/src/lsp/definition.ts +50 -58
- package/src/lsp/diagnostics-worker.ts +1 -4
- package/src/lsp/docs.ts +4 -3
- package/src/lsp/hover.ts +1465 -44
- package/src/lsp/imports.ts +75 -22
- package/src/lsp/navigation.ts +41 -22
- package/src/lsp/range-format.ts +102 -0
- package/src/lsp/schema-import-hover.ts +76 -0
- package/src/lsp/server.ts +99 -69
- package/src/lsp/signature-help.ts +226 -0
- package/src/lsp/validation.ts +3 -2
- package/src/lsp/workspace.ts +63 -9
- package/src/parser/declarations.ts +27 -1
- package/src/plugins/bun.ts +14 -66
- package/src/plugins/esbuild.ts +16 -55
- package/src/plugins/server-boundary.ts +41 -0
- package/src/plugins/type-view.ts +11 -3
- package/src/plugins/vite.ts +12 -62
- package/dist/Widget.tsx +0 -9
- package/dist/cli/output-collisions.d.ts +0 -2
- package/dist/cli/output-collisions.d.ts.map +0 -1
- package/dist/cli/output-collisions.js +0 -39
- package/dist/cli/output-collisions.js.map +0 -1
- package/dist/compiler/imported-record-functions.d.ts +0 -4
- package/dist/compiler/imported-record-functions.d.ts.map +0 -1
- package/dist/compiler/imported-record-functions.js +0 -706
- package/dist/compiler/imported-record-functions.js.map +0 -1
- package/dist/compiler/imported-schemas.d.ts +0 -21
- package/dist/compiler/imported-schemas.d.ts.map +0 -1
- package/dist/compiler/imported-schemas.js +0 -461
- package/dist/compiler/imported-schemas.js.map +0 -1
- package/dist/compiler/module-resolution.d.ts +0 -6
- package/dist/compiler/module-resolution.d.ts.map +0 -1
- package/dist/compiler/module-resolution.js +0 -44
- package/dist/compiler/module-resolution.js.map +0 -1
- package/dist/compiler/pipeline-companions.d.ts +0 -18
- package/dist/compiler/pipeline-companions.d.ts.map +0 -1
- package/dist/compiler/pipeline-companions.js +0 -1042
- package/dist/compiler/pipeline-companions.js.map +0 -1
- package/dist/compiler/providers.d.ts +0 -4
- package/dist/compiler/providers.d.ts.map +0 -1
- package/dist/compiler/providers.js +0 -101
- package/dist/compiler/providers.js.map +0 -1
- package/dist/emitter/pipeline-catalog.d.ts +0 -15
- package/dist/emitter/pipeline-catalog.d.ts.map +0 -1
- package/dist/emitter/pipeline-catalog.js +0 -55
- package/dist/emitter/pipeline-catalog.js.map +0 -1
- package/dist/emitter/pipeline-resolution.d.ts +0 -38
- package/dist/emitter/pipeline-resolution.d.ts.map +0 -1
- package/dist/emitter/pipeline-resolution.js +0 -571
- package/dist/emitter/pipeline-resolution.js.map +0 -1
- package/dist/interop/index.d.ts +0 -6
- package/dist/interop/index.d.ts.map +0 -1
- package/dist/interop/index.js +0 -6
- package/dist/interop/index.js.map +0 -1
- package/dist/math.ts +0 -1
- package/dist/parser/index.d.ts +0 -9
- package/dist/parser/index.d.ts.map +0 -1
- package/dist/parser/index.js +0 -9
- package/dist/parser/index.js.map +0 -1
- package/dist/service.ts +0 -3
- package/dist/service.ts.map +0 -1
- package/dist/tooling/migrate.d.ts +0 -62
- package/dist/tooling/migrate.d.ts.map +0 -1
- package/dist/tooling/migrate.js +0 -608
- package/dist/tooling/migrate.js.map +0 -1
package/src/lsp/server.ts
CHANGED
|
@@ -53,6 +53,8 @@ import {
|
|
|
53
53
|
type PublishDiagnosticsParams,
|
|
54
54
|
type ReferenceParams,
|
|
55
55
|
type RenameParams,
|
|
56
|
+
type SignatureHelp,
|
|
57
|
+
type SignatureHelpParams,
|
|
56
58
|
type RequestMessage,
|
|
57
59
|
type ResponseMessage,
|
|
58
60
|
type SymbolInformation,
|
|
@@ -70,11 +72,14 @@ import { convertPipelineStyle } from "../tooling/pipeline-style.js";
|
|
|
70
72
|
import { FUNSCRIPT_VERSION } from "../version.js";
|
|
71
73
|
import { complete } from "./completion.js";
|
|
72
74
|
import { findHoverAsync } from "./hover.js";
|
|
75
|
+
import { formatSelection } from "./range-format.js";
|
|
73
76
|
import {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
} from "./
|
|
77
|
+
hasRelativeImportedName,
|
|
78
|
+
importedFunSchemaHover,
|
|
79
|
+
} from "./schema-import-hover.js";
|
|
80
|
+
import { findImportCodeActions } from "./imports.js";
|
|
77
81
|
import { findInlayHints } from "./inlay-hints.js";
|
|
82
|
+
import { findSignatureHelp } from "./signature-help.js";
|
|
78
83
|
import { InteropRenameSession, renameInterop } from "./interop-rename.js";
|
|
79
84
|
import { findFillMatchArmsCodeActions } from "./match-arms.js";
|
|
80
85
|
import { findThunkPipelineCodeActions } from "./thunk-pipeline.js";
|
|
@@ -219,6 +224,7 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
219
224
|
);
|
|
220
225
|
connection.onDefinition((params) => this.onDefinitionHandler(params));
|
|
221
226
|
connection.onHover((params) => this.onHoverHandler(params));
|
|
227
|
+
connection.onSignatureHelp((params) => this.onSignatureHelpHandler(params));
|
|
222
228
|
connection.onCompletion((params) => this.onCompletionHandler(params));
|
|
223
229
|
connection.onDocumentSymbol((params) =>
|
|
224
230
|
this.onDocumentSymbolHandler(params),
|
|
@@ -266,13 +272,16 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
266
272
|
capabilities: {
|
|
267
273
|
textDocumentSync: TextDocumentSyncKind.Full,
|
|
268
274
|
documentFormattingProvider: true,
|
|
269
|
-
documentRangeFormattingProvider: true,
|
|
270
275
|
definitionProvider: true,
|
|
271
276
|
documentSymbolProvider: true,
|
|
272
277
|
workspaceSymbolProvider: true,
|
|
273
278
|
referencesProvider: true,
|
|
274
279
|
renameProvider: { prepareProvider: true },
|
|
275
280
|
hoverProvider: true,
|
|
281
|
+
signatureHelpProvider: {
|
|
282
|
+
triggerCharacters: ["(", ","],
|
|
283
|
+
retriggerCharacters: [","],
|
|
284
|
+
},
|
|
276
285
|
completionProvider: {
|
|
277
286
|
resolveProvider: false,
|
|
278
287
|
triggerCharacters: [".", "<", ">"],
|
|
@@ -305,20 +314,7 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
305
314
|
if (params?.textDocument) {
|
|
306
315
|
this.documentRevision++;
|
|
307
316
|
this.cancelCodeActionsFor(params.textDocument.uri);
|
|
308
|
-
this.
|
|
309
|
-
this.syncProjectConfigWatchers();
|
|
310
|
-
const diagnostics = validateSyntax(
|
|
311
|
-
params.textDocument.text,
|
|
312
|
-
params.textDocument.uri,
|
|
313
|
-
).diagnostics;
|
|
314
|
-
if (diagnostics.length) this.syntaxErrors.add(params.textDocument.uri);
|
|
315
|
-
else this.syntaxErrors.delete(params.textDocument.uri);
|
|
316
|
-
this.publishDiagnostics(
|
|
317
|
-
params.textDocument.uri,
|
|
318
|
-
params.textDocument.version,
|
|
319
|
-
diagnostics,
|
|
320
|
-
);
|
|
321
|
-
this.scheduleTypeDiagnostics();
|
|
317
|
+
this.updateDocument(params.textDocument);
|
|
322
318
|
}
|
|
323
319
|
}
|
|
324
320
|
|
|
@@ -338,23 +334,20 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
338
334
|
version: updatedVersion,
|
|
339
335
|
text: newText,
|
|
340
336
|
};
|
|
341
|
-
this.
|
|
342
|
-
this.syncProjectConfigWatchers();
|
|
343
|
-
const diagnostics = validateSyntax(
|
|
344
|
-
newText,
|
|
345
|
-
params.textDocument.uri,
|
|
346
|
-
).diagnostics;
|
|
347
|
-
if (diagnostics.length) this.syntaxErrors.add(updatedDoc.uri);
|
|
348
|
-
else this.syntaxErrors.delete(updatedDoc.uri);
|
|
349
|
-
this.publishDiagnostics(
|
|
350
|
-
params.textDocument.uri,
|
|
351
|
-
updatedVersion,
|
|
352
|
-
diagnostics,
|
|
353
|
-
);
|
|
354
|
-
this.scheduleTypeDiagnostics();
|
|
337
|
+
this.updateDocument(updatedDoc);
|
|
355
338
|
}
|
|
356
339
|
}
|
|
357
340
|
|
|
341
|
+
private updateDocument(document: TextDocumentItem): void {
|
|
342
|
+
this.documents.set(document.uri, document);
|
|
343
|
+
this.syncProjectConfigWatchers();
|
|
344
|
+
const diagnostics = validateSyntax(document.text, document.uri).diagnostics;
|
|
345
|
+
if (diagnostics.length) this.syntaxErrors.add(document.uri);
|
|
346
|
+
else this.syntaxErrors.delete(document.uri);
|
|
347
|
+
this.publishDiagnostics(document.uri, document.version, diagnostics);
|
|
348
|
+
this.scheduleTypeDiagnostics();
|
|
349
|
+
}
|
|
350
|
+
|
|
358
351
|
public onDidCloseHandler(params: DidCloseTextDocumentParams): void {
|
|
359
352
|
if (params?.textDocument) {
|
|
360
353
|
this.documentRevision++;
|
|
@@ -387,7 +380,7 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
387
380
|
params.options.tabSize > 0
|
|
388
381
|
? params.options.tabSize
|
|
389
382
|
: undefined;
|
|
390
|
-
const filename = uri ?
|
|
383
|
+
const filename = uri.startsWith("file:") ? fileURLToPath(uri) : undefined;
|
|
391
384
|
const projectFormat = filename
|
|
392
385
|
? loadFormatConfigForFile(filename)
|
|
393
386
|
: undefined;
|
|
@@ -541,26 +534,9 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
541
534
|
}
|
|
542
535
|
|
|
543
536
|
try {
|
|
544
|
-
|
|
545
|
-
doc.text,
|
|
546
|
-
uri,
|
|
547
|
-
params.range,
|
|
548
|
-
);
|
|
549
|
-
actions.push(...autoImportActions);
|
|
537
|
+
actions.push(...findImportCodeActions(doc.text, uri, params.range));
|
|
550
538
|
} catch (error) {
|
|
551
|
-
/*
|
|
552
|
-
if (!isExpectedSyntaxError(error)) throw error;
|
|
553
|
-
}
|
|
554
|
-
|
|
555
|
-
try {
|
|
556
|
-
const unusedImportActions = findRemoveUnusedImportsCodeActions(
|
|
557
|
-
doc.text,
|
|
558
|
-
uri,
|
|
559
|
-
params.range,
|
|
560
|
-
);
|
|
561
|
-
actions.push(...unusedImportActions);
|
|
562
|
-
} catch (error) {
|
|
563
|
-
/* Remove unused imports gracefully declines. */
|
|
539
|
+
/* Import actions gracefully decline on invalid syntax. */
|
|
564
540
|
if (!isExpectedSyntaxError(error)) throw error;
|
|
565
541
|
}
|
|
566
542
|
|
|
@@ -639,26 +615,25 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
639
615
|
const doc = uri ? this.documents.get(uri) : undefined;
|
|
640
616
|
if (!doc) return null;
|
|
641
617
|
|
|
642
|
-
// The formatter currently operates on complete syntax trees. Only accept a
|
|
643
|
-
// range that covers the full document; partial edits could alter unrelated code.
|
|
644
618
|
const lines = doc.text.split("\n");
|
|
645
619
|
const lastLine = lines.length - 1;
|
|
646
620
|
const end = params.range?.end;
|
|
647
621
|
const start = params.range?.start;
|
|
648
|
-
if (
|
|
649
|
-
|
|
650
|
-
!end ||
|
|
651
|
-
start.line !== 0 ||
|
|
652
|
-
start.character !== 0 ||
|
|
653
|
-
end.line < lastLine ||
|
|
654
|
-
(end.line === lastLine && end.character < lines[lastLine].length)
|
|
655
|
-
) {
|
|
656
|
-
return null;
|
|
657
|
-
}
|
|
658
|
-
return this.onFormattingHandler({
|
|
622
|
+
if (!start || !end) return null;
|
|
623
|
+
const formatting = this.onFormattingHandler({
|
|
659
624
|
textDocument: params.textDocument,
|
|
660
625
|
options: params.options,
|
|
661
626
|
});
|
|
627
|
+
if (!formatting) return null;
|
|
628
|
+
if (!formatting.length) return [];
|
|
629
|
+
if (
|
|
630
|
+
start.line === 0 &&
|
|
631
|
+
start.character === 0 &&
|
|
632
|
+
(end.line > lastLine ||
|
|
633
|
+
(end.line === lastLine && end.character >= lines[lastLine].length))
|
|
634
|
+
)
|
|
635
|
+
return formatting;
|
|
636
|
+
return formatSelection(doc.text, formatting[0].newText, uri, params.range);
|
|
662
637
|
}
|
|
663
638
|
|
|
664
639
|
public onDefinitionHandler(
|
|
@@ -678,7 +653,7 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
678
653
|
doc.text,
|
|
679
654
|
uri,
|
|
680
655
|
params.position,
|
|
681
|
-
this.workspaceSnapshot()?.fun ?? this.getDocuments(),
|
|
656
|
+
this.workspaceSnapshot(true)?.fun ?? this.getDocuments(),
|
|
682
657
|
clientSupportsLink,
|
|
683
658
|
);
|
|
684
659
|
}
|
|
@@ -690,6 +665,35 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
690
665
|
return null;
|
|
691
666
|
}
|
|
692
667
|
|
|
668
|
+
const line = doc.text.split("\n")[params.position.line] ?? "";
|
|
669
|
+
const before = line.slice(0, params.position.character);
|
|
670
|
+
const after = line.slice(params.position.character);
|
|
671
|
+
const word =
|
|
672
|
+
(before.match(/[A-Za-z0-9_]*$/)?.[0] ?? "") +
|
|
673
|
+
(after.match(/^[A-Za-z0-9_]*/)?.[0] ?? "");
|
|
674
|
+
if (
|
|
675
|
+
/^[A-Z]/.test(word) &&
|
|
676
|
+
/\bimport\b/.test(doc.text) &&
|
|
677
|
+
hasRelativeImportedName(doc.text, uri, word)
|
|
678
|
+
) {
|
|
679
|
+
let imported = await importedFunSchemaHover(
|
|
680
|
+
doc.text,
|
|
681
|
+
uri,
|
|
682
|
+
params.position,
|
|
683
|
+
this.getDocuments(),
|
|
684
|
+
);
|
|
685
|
+
if (!imported) {
|
|
686
|
+
const snapshot = this.workspaceSnapshot(true);
|
|
687
|
+
if (snapshot)
|
|
688
|
+
imported = await importedFunSchemaHover(
|
|
689
|
+
doc.text,
|
|
690
|
+
uri,
|
|
691
|
+
params.position,
|
|
692
|
+
snapshot.fun,
|
|
693
|
+
);
|
|
694
|
+
}
|
|
695
|
+
if (imported) return imported;
|
|
696
|
+
}
|
|
693
697
|
return findHoverAsync(doc.text, uri, params.position);
|
|
694
698
|
}
|
|
695
699
|
|
|
@@ -700,6 +704,20 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
700
704
|
return findInlayHints(doc.text, uri, params?.range);
|
|
701
705
|
}
|
|
702
706
|
|
|
707
|
+
public onSignatureHelpHandler(
|
|
708
|
+
params: SignatureHelpParams,
|
|
709
|
+
): SignatureHelp | null {
|
|
710
|
+
const uri = params?.textDocument?.uri;
|
|
711
|
+
const doc = uri ? this.documents.get(uri) : undefined;
|
|
712
|
+
if (!doc || !params?.position) return null;
|
|
713
|
+
return findSignatureHelp(
|
|
714
|
+
doc.text,
|
|
715
|
+
uri,
|
|
716
|
+
params.position,
|
|
717
|
+
this.getDocuments(),
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
|
|
703
721
|
public onCompletionHandler(params: CompletionParams): CompletionItem[] {
|
|
704
722
|
const uri = params?.textDocument?.uri;
|
|
705
723
|
const doc = uri ? this.documents.get(uri) : undefined;
|
|
@@ -724,7 +742,10 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
724
742
|
public onWorkspaceSymbolHandler(
|
|
725
743
|
params: WorkspaceSymbolParams,
|
|
726
744
|
): SymbolInformation[] {
|
|
727
|
-
return workspaceSymbols(
|
|
745
|
+
return workspaceSymbols(
|
|
746
|
+
this.workspaceSnapshot(true)?.fun ?? this.getDocuments(),
|
|
747
|
+
params?.query ?? "",
|
|
748
|
+
);
|
|
728
749
|
}
|
|
729
750
|
|
|
730
751
|
public onReferencesHandler(params: ReferenceParams): Location[] {
|
|
@@ -735,7 +756,7 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
735
756
|
doc.text,
|
|
736
757
|
uri,
|
|
737
758
|
params.position,
|
|
738
|
-
this.workspaceSnapshot()?.fun ?? this.getDocuments(),
|
|
759
|
+
this.workspaceSnapshot(true)?.fun ?? this.getDocuments(),
|
|
739
760
|
params.context.includeDeclaration,
|
|
740
761
|
)
|
|
741
762
|
: [];
|
|
@@ -991,11 +1012,12 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
991
1012
|
});
|
|
992
1013
|
}
|
|
993
1014
|
|
|
994
|
-
private workspaceSnapshot() {
|
|
1015
|
+
private workspaceSnapshot(allowIncomplete = false) {
|
|
995
1016
|
return workspaceSnapshot(
|
|
996
1017
|
this.workspaceRoots,
|
|
997
1018
|
this.documents.values(),
|
|
998
1019
|
this.interopDocuments.values(),
|
|
1020
|
+
{ allowIncomplete },
|
|
999
1021
|
);
|
|
1000
1022
|
}
|
|
1001
1023
|
|
|
@@ -1087,6 +1109,14 @@ export class FunScriptLspServer extends EventEmitter {
|
|
|
1087
1109
|
};
|
|
1088
1110
|
}
|
|
1089
1111
|
|
|
1112
|
+
if (req.method === "textDocument/signatureHelp") {
|
|
1113
|
+
return {
|
|
1114
|
+
jsonrpc: "2.0",
|
|
1115
|
+
id: req.id,
|
|
1116
|
+
result: this.onSignatureHelpHandler(req.params as SignatureHelpParams),
|
|
1117
|
+
};
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1090
1120
|
if (req.method === "textDocument/inlayHint") {
|
|
1091
1121
|
const result = this.onInlayHintHandler(req.params as InlayHintParams);
|
|
1092
1122
|
return {
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import * as Effect from "effect/Effect";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
import ts from "typescript";
|
|
6
|
+
import {
|
|
7
|
+
MarkupKind,
|
|
8
|
+
type Position,
|
|
9
|
+
type SignatureHelp,
|
|
10
|
+
} from "vscode-languageserver/node";
|
|
11
|
+
import { compileString } from "../compiler.js";
|
|
12
|
+
import { TypeScriptCompilationContext } from "../compiler/typescript-context.js";
|
|
13
|
+
import { resolveFunModule } from "../compiler/modules/resolution.js";
|
|
14
|
+
import { FunScriptError } from "../errors.js";
|
|
15
|
+
import { Lexer } from "../lexer/lexer.js";
|
|
16
|
+
import { TokenType, type Token } from "../lexer/tokens.js";
|
|
17
|
+
|
|
18
|
+
const marker = "__funkscript_signature_help_argument__";
|
|
19
|
+
const opening = new Set([
|
|
20
|
+
TokenType.LPAREN,
|
|
21
|
+
TokenType.LBRACKET,
|
|
22
|
+
TokenType.LBRACE,
|
|
23
|
+
]);
|
|
24
|
+
const closing = new Map([
|
|
25
|
+
[TokenType.RPAREN, TokenType.LPAREN],
|
|
26
|
+
[TokenType.RBRACKET, TokenType.LBRACKET],
|
|
27
|
+
[TokenType.RBRACE, TokenType.LBRACE],
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
function cursorOffset(source: string, position: Position): number | undefined {
|
|
31
|
+
if (position.line < 0 || position.character < 0) return undefined;
|
|
32
|
+
const lines = source.split("\n");
|
|
33
|
+
if (
|
|
34
|
+
position.line >= lines.length ||
|
|
35
|
+
position.character > lines[position.line].length
|
|
36
|
+
)
|
|
37
|
+
return undefined;
|
|
38
|
+
return (
|
|
39
|
+
lines.slice(0, position.line).reduce((n, line) => n + line.length + 1, 0) +
|
|
40
|
+
position.character
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function activeArgument(
|
|
45
|
+
tokens: Token[],
|
|
46
|
+
offset: number,
|
|
47
|
+
): { start: number; end: number; index: number; closed: boolean } | undefined {
|
|
48
|
+
const stack: number[] = [];
|
|
49
|
+
for (
|
|
50
|
+
let i = 0;
|
|
51
|
+
i < tokens.length && tokens[i].span.start.offset < offset;
|
|
52
|
+
i++
|
|
53
|
+
) {
|
|
54
|
+
const token = tokens[i];
|
|
55
|
+
if (opening.has(token.type)) stack.push(i);
|
|
56
|
+
else if (
|
|
57
|
+
closing.has(token.type) &&
|
|
58
|
+
tokens[stack[stack.length - 1]]?.type === closing.get(token.type)
|
|
59
|
+
)
|
|
60
|
+
stack.pop();
|
|
61
|
+
}
|
|
62
|
+
const openIndex = [...stack]
|
|
63
|
+
.reverse()
|
|
64
|
+
.find((i) => tokens[i].type === TokenType.LPAREN);
|
|
65
|
+
if (openIndex === undefined) return undefined;
|
|
66
|
+
const previous = tokens[openIndex - 1];
|
|
67
|
+
if (
|
|
68
|
+
!previous ||
|
|
69
|
+
![
|
|
70
|
+
TokenType.IDENTIFIER,
|
|
71
|
+
TokenType.UPPER_IDENTIFIER,
|
|
72
|
+
TokenType.RPAREN,
|
|
73
|
+
TokenType.RBRACKET,
|
|
74
|
+
].includes(previous.type)
|
|
75
|
+
)
|
|
76
|
+
return undefined;
|
|
77
|
+
let depth = 0;
|
|
78
|
+
let start = tokens[openIndex].span.end.offset;
|
|
79
|
+
let index = 0;
|
|
80
|
+
for (let i = openIndex + 1; i < tokens.length; i++) {
|
|
81
|
+
const token = tokens[i];
|
|
82
|
+
if (
|
|
83
|
+
depth === 0 &&
|
|
84
|
+
(token.type === TokenType.COMMA || token.type === TokenType.RPAREN)
|
|
85
|
+
) {
|
|
86
|
+
if (token.span.start.offset >= offset)
|
|
87
|
+
return { start, end: token.span.start.offset, index, closed: true };
|
|
88
|
+
if (token.type === TokenType.RPAREN) return undefined;
|
|
89
|
+
start = token.span.end.offset;
|
|
90
|
+
index++;
|
|
91
|
+
} else if (opening.has(token.type)) depth++;
|
|
92
|
+
else if (closing.has(token.type)) depth = Math.max(0, depth - 1);
|
|
93
|
+
}
|
|
94
|
+
return { start, end: offset, index, closed: false };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function findSignatureHelp(
|
|
98
|
+
source: string,
|
|
99
|
+
uri: string,
|
|
100
|
+
position: Position,
|
|
101
|
+
documents: ReadonlyArray<{ uri: string; text: string }> = [],
|
|
102
|
+
): SignatureHelp | null {
|
|
103
|
+
const offset = cursorOffset(source, position);
|
|
104
|
+
if (offset === undefined || source.includes(marker)) return null;
|
|
105
|
+
try {
|
|
106
|
+
let tokens: Token[];
|
|
107
|
+
try {
|
|
108
|
+
tokens = new Lexer(source, uri).tokenize();
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (!(error instanceof FunScriptError)) throw error;
|
|
111
|
+
// The cursor is often inside a string that has not been closed yet.
|
|
112
|
+
tokens = new Lexer(
|
|
113
|
+
source.slice(0, offset) + '"' + source.slice(offset),
|
|
114
|
+
uri,
|
|
115
|
+
).tokenize();
|
|
116
|
+
}
|
|
117
|
+
const active = activeArgument(tokens, offset);
|
|
118
|
+
if (!active) return null;
|
|
119
|
+
const repaired =
|
|
120
|
+
`ts { declare const ${marker}: any; }\n` +
|
|
121
|
+
source.slice(0, active.start) +
|
|
122
|
+
marker +
|
|
123
|
+
(active.closed ? "" : ")") +
|
|
124
|
+
source.slice(active.end);
|
|
125
|
+
const filename = uri.startsWith("file:") ? fileURLToPath(uri) : uri;
|
|
126
|
+
const context = new TypeScriptCompilationContext(filename);
|
|
127
|
+
const result = Effect.runSync(
|
|
128
|
+
compileString(repaired, filename, { context, sourcemap: false }),
|
|
129
|
+
);
|
|
130
|
+
const openFiles = new Map<string, string>();
|
|
131
|
+
for (const document of documents) {
|
|
132
|
+
if (document.uri.startsWith("file:")) {
|
|
133
|
+
openFiles.set(resolve(fileURLToPath(document.uri)), document.text);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
const auxiliary = new Map<string, string>();
|
|
137
|
+
for (const declaration of result.ast.body) {
|
|
138
|
+
if (declaration.kind !== "ImportDeclaration") continue;
|
|
139
|
+
const specifier = declaration.source.parts
|
|
140
|
+
.map((part) => (part.kind === "StringRawPart" ? part.value : ""))
|
|
141
|
+
.join("");
|
|
142
|
+
const target = resolveFunModule(
|
|
143
|
+
filename,
|
|
144
|
+
specifier,
|
|
145
|
+
(file) => openFiles.has(file) || existsSync(file),
|
|
146
|
+
);
|
|
147
|
+
if (!target) continue;
|
|
148
|
+
const virtualFile = target.replace(
|
|
149
|
+
/\.funx?$/,
|
|
150
|
+
target.endsWith(".funx") ? ".tsx" : ".ts",
|
|
151
|
+
);
|
|
152
|
+
// A real TypeScript sibling must never masquerade as an explicit FunkScript import.
|
|
153
|
+
if (existsSync(virtualFile)) return null;
|
|
154
|
+
const importedSource =
|
|
155
|
+
openFiles.get(target) ?? readFileSync(target, "utf8");
|
|
156
|
+
const imported = Effect.runSync(
|
|
157
|
+
compileString(importedSource, target, { sourcemap: false }),
|
|
158
|
+
);
|
|
159
|
+
auxiliary.set(virtualFile, imported.typescript);
|
|
160
|
+
}
|
|
161
|
+
if (auxiliary.size) context.setAuxiliarySources(auxiliary);
|
|
162
|
+
const checked = context.check(result.typescript);
|
|
163
|
+
if (!checked) return null;
|
|
164
|
+
let call: ts.CallExpression | undefined;
|
|
165
|
+
const visit = (node: ts.Node): void => {
|
|
166
|
+
if (
|
|
167
|
+
ts.isIdentifier(node) &&
|
|
168
|
+
node.text === marker &&
|
|
169
|
+
ts.isCallExpression(node.parent) &&
|
|
170
|
+
node.parent.arguments.includes(node)
|
|
171
|
+
)
|
|
172
|
+
call = node.parent;
|
|
173
|
+
else ts.forEachChild(node, visit);
|
|
174
|
+
};
|
|
175
|
+
visit(checked.sourceFile);
|
|
176
|
+
if (!call) return null;
|
|
177
|
+
const signatures = checked.checker
|
|
178
|
+
.getTypeAtLocation(call.expression)
|
|
179
|
+
.getCallSignatures();
|
|
180
|
+
if (!signatures.length) return null;
|
|
181
|
+
const resolved = checked.checker.getResolvedSignature(call);
|
|
182
|
+
const selected = Math.max(
|
|
183
|
+
0,
|
|
184
|
+
signatures.findIndex(
|
|
185
|
+
(signature) =>
|
|
186
|
+
signature === resolved ||
|
|
187
|
+
(resolved &&
|
|
188
|
+
signature.getDeclaration() === resolved.getDeclaration()),
|
|
189
|
+
),
|
|
190
|
+
);
|
|
191
|
+
return {
|
|
192
|
+
signatures: signatures.map((signature) => ({
|
|
193
|
+
label: checked.checker.signatureToString(
|
|
194
|
+
signature,
|
|
195
|
+
call,
|
|
196
|
+
ts.TypeFormatFlags.NoTruncation,
|
|
197
|
+
),
|
|
198
|
+
documentation: {
|
|
199
|
+
kind: MarkupKind.Markdown,
|
|
200
|
+
value: ts.displayPartsToString(
|
|
201
|
+
signature.getDocumentationComment(checked.checker),
|
|
202
|
+
),
|
|
203
|
+
},
|
|
204
|
+
parameters: signature.getParameters().map((parameter) => ({
|
|
205
|
+
label: parameter.getName(),
|
|
206
|
+
documentation: {
|
|
207
|
+
kind: MarkupKind.Markdown,
|
|
208
|
+
value: ts.displayPartsToString(
|
|
209
|
+
parameter.getDocumentationComment(checked.checker),
|
|
210
|
+
),
|
|
211
|
+
},
|
|
212
|
+
})),
|
|
213
|
+
})),
|
|
214
|
+
activeSignature: selected,
|
|
215
|
+
activeParameter: active.index,
|
|
216
|
+
};
|
|
217
|
+
} catch (error) {
|
|
218
|
+
if (
|
|
219
|
+
error instanceof FunScriptError ||
|
|
220
|
+
error instanceof URIError ||
|
|
221
|
+
error instanceof TypeError
|
|
222
|
+
)
|
|
223
|
+
return null;
|
|
224
|
+
throw error;
|
|
225
|
+
}
|
|
226
|
+
}
|
package/src/lsp/validation.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pathToFileURL } from "node:url";
|
|
1
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
2
2
|
import {
|
|
3
3
|
DiagnosticSeverity,
|
|
4
4
|
type Diagnostic,
|
|
@@ -134,7 +134,8 @@ export function validateFunScript(
|
|
|
134
134
|
const { diagnostics, ast } = validateSyntax(source, uri);
|
|
135
135
|
if (!diagnostics.length && ast) {
|
|
136
136
|
try {
|
|
137
|
-
const
|
|
137
|
+
const filename = uri.startsWith("file:") ? fileURLToPath(uri) : uri;
|
|
138
|
+
const context = new TypeScriptCompilationContext(filename);
|
|
138
139
|
if (!ast.body.some((decl) => decl.kind === "AsDeclaration"))
|
|
139
140
|
validateNumericComparisons(ast, source, context);
|
|
140
141
|
validateBooleanOperators(ast, source, context);
|
package/src/lsp/workspace.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { readdirSync, readFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
3
|
-
import { pathToFileURL } from "node:url";
|
|
1
|
+
import { readdirSync, readFileSync, realpathSync, statSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, join, relative, sep } from "node:path";
|
|
3
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
4
|
import type { TextDocumentItem } from "vscode-languageserver/node";
|
|
5
5
|
import { isFileNotFoundError } from "../errors.js";
|
|
6
6
|
|
|
@@ -9,7 +9,12 @@ export function isExpectedFsAccessError(error: unknown): boolean {
|
|
|
9
9
|
if (typeof error !== "object" || error === null || !("code" in error))
|
|
10
10
|
return false;
|
|
11
11
|
const code = (error as { code?: unknown }).code;
|
|
12
|
-
return
|
|
12
|
+
return (
|
|
13
|
+
code === "EACCES" ||
|
|
14
|
+
code === "EPERM" ||
|
|
15
|
+
code === "ENOSYS" ||
|
|
16
|
+
code === "ELOOP"
|
|
17
|
+
);
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
/** Read a fresh workspace view; unsaved open buffers always win over disk. */
|
|
@@ -17,6 +22,7 @@ export function workspaceSnapshot(
|
|
|
17
22
|
roots: string[],
|
|
18
23
|
documents: Iterable<TextDocumentItem>,
|
|
19
24
|
interopDocuments: Iterable<TextDocumentItem>,
|
|
25
|
+
options: { allowIncomplete?: boolean } = {},
|
|
20
26
|
): {
|
|
21
27
|
fun: TextDocumentItem[];
|
|
22
28
|
interop: TextDocumentItem[];
|
|
@@ -24,6 +30,7 @@ export function workspaceSnapshot(
|
|
|
24
30
|
if (!roots.length) return null;
|
|
25
31
|
const files = new Map<string, TextDocumentItem>();
|
|
26
32
|
const visited = new Set<string>();
|
|
33
|
+
let incomplete = false;
|
|
27
34
|
const excluded = new Set([
|
|
28
35
|
"node_modules",
|
|
29
36
|
".git",
|
|
@@ -32,14 +39,44 @@ export function workspaceSnapshot(
|
|
|
32
39
|
"build",
|
|
33
40
|
"coverage",
|
|
34
41
|
]);
|
|
42
|
+
const canonicalRoots: string[] = [];
|
|
43
|
+
try {
|
|
44
|
+
for (const root of roots) canonicalRoots.push(realpathSync(root));
|
|
45
|
+
} catch (error) {
|
|
46
|
+
if (!isExpectedFsAccessError(error)) throw error;
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
const indexedTarget = (path: string): boolean =>
|
|
50
|
+
canonicalRoots.some((root) => {
|
|
51
|
+
const child = relative(root, path);
|
|
52
|
+
return (
|
|
53
|
+
child !== ".." &&
|
|
54
|
+
!child.startsWith(`..${sep}`) &&
|
|
55
|
+
!isAbsolute(child) &&
|
|
56
|
+
!child.split(sep).some((part) => excluded.has(part))
|
|
57
|
+
);
|
|
58
|
+
});
|
|
35
59
|
const walk = (directory: string): void => {
|
|
36
60
|
if (visited.has(directory)) return;
|
|
37
61
|
visited.add(directory);
|
|
38
62
|
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
39
63
|
if (excluded.has(entry.name)) continue;
|
|
40
64
|
const path = join(directory, entry.name);
|
|
41
|
-
if (entry.isSymbolicLink())
|
|
42
|
-
|
|
65
|
+
if (entry.isSymbolicLink()) {
|
|
66
|
+
try {
|
|
67
|
+
const target = realpathSync(path);
|
|
68
|
+
if (
|
|
69
|
+
!indexedTarget(target) ||
|
|
70
|
+
(!statSync(target).isDirectory() &&
|
|
71
|
+
!/\.(?:fun|funs|funx|[cm]?[jt]sx?)$/.test(target))
|
|
72
|
+
)
|
|
73
|
+
incomplete = true;
|
|
74
|
+
} catch (error) {
|
|
75
|
+
if (!isExpectedFsAccessError(error)) throw error;
|
|
76
|
+
incomplete = true;
|
|
77
|
+
}
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
43
80
|
if (entry.isDirectory()) {
|
|
44
81
|
walk(path);
|
|
45
82
|
continue;
|
|
@@ -59,13 +96,30 @@ export function workspaceSnapshot(
|
|
|
59
96
|
}
|
|
60
97
|
};
|
|
61
98
|
try {
|
|
62
|
-
for (const root of
|
|
99
|
+
for (const root of canonicalRoots) walk(root);
|
|
63
100
|
} catch (error) {
|
|
64
101
|
if (!isExpectedFsAccessError(error)) throw error;
|
|
65
102
|
return null;
|
|
66
103
|
}
|
|
67
|
-
|
|
68
|
-
|
|
104
|
+
if (incomplete && !options.allowIncomplete) return null;
|
|
105
|
+
const openFiles = new Map<string, TextDocumentItem>();
|
|
106
|
+
for (const doc of [...documents, ...interopDocuments]) {
|
|
107
|
+
let key = doc.uri;
|
|
108
|
+
if (doc.uri.startsWith("file:")) {
|
|
109
|
+
try {
|
|
110
|
+
const canonical = realpathSync(fileURLToPath(doc.uri));
|
|
111
|
+
if (!indexedTarget(canonical) && !options.allowIncomplete) return null;
|
|
112
|
+
key = pathToFileURL(canonical).href;
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (!isExpectedFsAccessError(error)) throw error;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const previous = openFiles.get(key);
|
|
118
|
+
if (previous && previous.text !== doc.text && !options.allowIncomplete)
|
|
119
|
+
return null;
|
|
120
|
+
openFiles.set(key, doc);
|
|
121
|
+
}
|
|
122
|
+
for (const [uri, doc] of openFiles) files.set(uri, doc);
|
|
69
123
|
const all = [...files.values()];
|
|
70
124
|
return {
|
|
71
125
|
fun: all.filter((doc) => /\.(?:fun|funs|funx)$/.test(doc.uri)),
|
|
@@ -277,6 +277,16 @@ export function parseImportDeclaration(
|
|
|
277
277
|
namespaceBinding = ctx.parseAnyIdentifier();
|
|
278
278
|
} else {
|
|
279
279
|
ctx.consume(TokenType.LBRACE, "Expected '{' or '*' in import declaration");
|
|
280
|
+
const skipImportWhitespace = () => {
|
|
281
|
+
while (
|
|
282
|
+
ctx.match(TokenType.NEWLINE) ||
|
|
283
|
+
ctx.match(TokenType.INDENT) ||
|
|
284
|
+
ctx.match(TokenType.DEDENT)
|
|
285
|
+
) {
|
|
286
|
+
// Consume indentation tokens that only separate import specifiers.
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
skipImportWhitespace();
|
|
280
290
|
if (!ctx.check(TokenType.RBRACE)) {
|
|
281
291
|
do {
|
|
282
292
|
let specTypeOnly = false;
|
|
@@ -321,7 +331,23 @@ export function parseImportDeclaration(
|
|
|
321
331
|
local: localId,
|
|
322
332
|
span: { start: importedId.span.start, end: localId.span.end },
|
|
323
333
|
});
|
|
324
|
-
|
|
334
|
+
// Keep the newline as a recovery boundary if the next token cannot
|
|
335
|
+
// continue the import; it may start another top-level declaration.
|
|
336
|
+
let lookahead = 0;
|
|
337
|
+
while (
|
|
338
|
+
ctx.peekAhead(lookahead).type === TokenType.NEWLINE ||
|
|
339
|
+
ctx.peekAhead(lookahead).type === TokenType.INDENT ||
|
|
340
|
+
ctx.peekAhead(lookahead).type === TokenType.DEDENT
|
|
341
|
+
)
|
|
342
|
+
lookahead++;
|
|
343
|
+
if (
|
|
344
|
+
ctx.peekAhead(lookahead).type === TokenType.COMMA ||
|
|
345
|
+
ctx.peekAhead(lookahead).type === TokenType.RBRACE
|
|
346
|
+
)
|
|
347
|
+
skipImportWhitespace();
|
|
348
|
+
if (!ctx.match(TokenType.COMMA)) break;
|
|
349
|
+
skipImportWhitespace();
|
|
350
|
+
} while (!ctx.check(TokenType.RBRACE));
|
|
325
351
|
}
|
|
326
352
|
ctx.consume(TokenType.RBRACE, "Expected '}' after import specifiers");
|
|
327
353
|
}
|