@hydranium/core 1.0.0-next.14 → 1.0.0-next.148
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 +5 -1
- package/lib/documents/ast-document-manager.d.ts +187 -27
- package/lib/documents/ast-document-manager.d.ts.map +1 -1
- package/lib/documents/ast-document-manager.js +235 -38
- package/lib/documents/ast-document-manager.js.map +1 -1
- package/lib/documents/client-ids.d.ts +5 -19
- package/lib/documents/client-ids.d.ts.map +1 -1
- package/lib/documents/client-ids.js +5 -19
- package/lib/documents/client-ids.js.map +1 -1
- package/lib/documents/client-session-errors.d.ts +15 -0
- package/lib/documents/client-session-errors.d.ts.map +1 -0
- package/lib/documents/client-session-errors.js +15 -0
- package/lib/documents/client-session-errors.js.map +1 -0
- package/lib/documents/client-session-registry.d.ts +138 -0
- package/lib/documents/client-session-registry.d.ts.map +1 -0
- package/lib/documents/client-session-registry.js +187 -0
- package/lib/documents/client-session-registry.js.map +1 -0
- package/lib/documents/file-system-task-queue.d.ts +49 -0
- package/lib/documents/file-system-task-queue.d.ts.map +1 -0
- package/lib/documents/file-system-task-queue.js +34 -0
- package/lib/documents/file-system-task-queue.js.map +1 -0
- package/lib/documents/hydranium-text-documents.d.ts +386 -57
- package/lib/documents/hydranium-text-documents.d.ts.map +1 -1
- package/lib/documents/hydranium-text-documents.js +700 -126
- package/lib/documents/hydranium-text-documents.js.map +1 -1
- package/lib/documents/index.d.ts +3 -0
- package/lib/documents/index.d.ts.map +1 -1
- package/lib/documents/index.js +3 -0
- package/lib/documents/index.js.map +1 -1
- package/lib/documents/language-client-text-shadow.d.ts +41 -9
- package/lib/documents/language-client-text-shadow.d.ts.map +1 -1
- package/lib/documents/language-client-text-shadow.js +56 -11
- package/lib/documents/language-client-text-shadow.js.map +1 -1
- package/lib/documents/self-save-registry.d.ts +37 -6
- package/lib/documents/self-save-registry.d.ts.map +1 -1
- package/lib/documents/self-save-registry.js +28 -15
- package/lib/documents/self-save-registry.js.map +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -1
- package/lib/langium/ast-extension/ast-node-builder.d.ts +32 -9
- package/lib/langium/ast-extension/ast-node-builder.d.ts.map +1 -1
- package/lib/langium/ast-extension/ast-node-builder.js +60 -22
- package/lib/langium/ast-extension/ast-node-builder.js.map +1 -1
- package/lib/langium/bootstrap.d.ts.map +1 -1
- package/lib/langium/bootstrap.js +16 -9
- package/lib/langium/bootstrap.js.map +1 -1
- package/lib/langium/config/configuration-provider.d.ts +81 -0
- package/lib/langium/config/configuration-provider.d.ts.map +1 -0
- package/lib/langium/config/configuration-provider.js +112 -0
- package/lib/langium/config/configuration-provider.js.map +1 -0
- package/lib/langium/config/index.d.ts +1 -0
- package/lib/langium/config/index.d.ts.map +1 -1
- package/lib/langium/config/index.js +1 -0
- package/lib/langium/config/index.js.map +1 -1
- package/lib/langium/diagnostics/lsp-logger.d.ts +17 -0
- package/lib/langium/diagnostics/lsp-logger.d.ts.map +1 -1
- package/lib/langium/diagnostics/lsp-logger.js +40 -6
- package/lib/langium/diagnostics/lsp-logger.js.map +1 -1
- package/lib/langium/document-builder/build-pipeline-integration.d.ts +21 -1
- package/lib/langium/document-builder/build-pipeline-integration.d.ts.map +1 -1
- package/lib/langium/document-builder/build-pipeline-integration.js +32 -5
- package/lib/langium/document-builder/build-pipeline-integration.js.map +1 -1
- package/lib/langium/document-builder/build-session.d.ts +93 -0
- package/lib/langium/document-builder/build-session.d.ts.map +1 -0
- package/lib/langium/document-builder/build-session.js +72 -0
- package/lib/langium/document-builder/build-session.js.map +1 -0
- package/lib/langium/document-builder/document-builder.d.ts +352 -16
- package/lib/langium/document-builder/document-builder.d.ts.map +1 -1
- package/lib/langium/document-builder/document-builder.js +616 -40
- package/lib/langium/document-builder/document-builder.js.map +1 -1
- package/lib/langium/document-builder/index.d.ts +1 -0
- package/lib/langium/document-builder/index.d.ts.map +1 -1
- package/lib/langium/document-builder/index.js +1 -0
- package/lib/langium/document-builder/index.js.map +1 -1
- package/lib/langium/integration-services.d.ts +45 -1
- package/lib/langium/integration-services.d.ts.map +1 -1
- package/lib/langium/integration-services.js +10 -5
- package/lib/langium/integration-services.js.map +1 -1
- package/lib/langium/integrity/integrity-rule.d.ts +13 -5
- package/lib/langium/integrity/integrity-rule.d.ts.map +1 -1
- package/lib/langium/integrity/integrity-rule.js.map +1 -1
- package/lib/langium/integrity/integrity-service.d.ts +50 -6
- package/lib/langium/integrity/integrity-service.d.ts.map +1 -1
- package/lib/langium/integrity/integrity-service.js +193 -17
- package/lib/langium/integrity/integrity-service.js.map +1 -1
- package/lib/langium/keys/containment.d.ts +64 -0
- package/lib/langium/keys/containment.d.ts.map +1 -0
- package/lib/langium/keys/containment.js +53 -0
- package/lib/langium/keys/containment.js.map +1 -0
- package/lib/langium/keys/index.d.ts +1 -0
- package/lib/langium/keys/index.d.ts.map +1 -1
- package/lib/langium/keys/index.js +1 -0
- package/lib/langium/keys/index.js.map +1 -1
- package/lib/langium/keys/name-based-key-provider.d.ts +4 -0
- package/lib/langium/keys/name-based-key-provider.d.ts.map +1 -1
- package/lib/langium/keys/name-based-key-provider.js +4 -0
- package/lib/langium/keys/name-based-key-provider.js.map +1 -1
- package/lib/langium/language-module.d.ts +27 -2
- package/lib/langium/language-module.d.ts.map +1 -1
- package/lib/langium/language-module.js +16 -2
- package/lib/langium/language-module.js.map +1 -1
- package/lib/langium/model-service/client-session.d.ts +307 -0
- package/lib/langium/model-service/client-session.d.ts.map +1 -0
- package/lib/langium/model-service/client-session.js +395 -0
- package/lib/langium/model-service/client-session.js.map +1 -0
- package/lib/langium/model-service/index.d.ts +1 -0
- package/lib/langium/model-service/index.d.ts.map +1 -1
- package/lib/langium/model-service/index.js +1 -0
- package/lib/langium/model-service/index.js.map +1 -1
- package/lib/langium/model-service/model-service.d.ts +261 -198
- package/lib/langium/model-service/model-service.d.ts.map +1 -1
- package/lib/langium/model-service/model-service.js +232 -344
- package/lib/langium/model-service/model-service.js.map +1 -1
- package/lib/langium/module.d.ts +107 -24
- package/lib/langium/module.d.ts.map +1 -1
- package/lib/langium/module.js +30 -12
- package/lib/langium/module.js.map +1 -1
- package/lib/langium/naming/name-provider.d.ts +25 -4
- package/lib/langium/naming/name-provider.d.ts.map +1 -1
- package/lib/langium/naming/name-provider.js +2 -1
- package/lib/langium/naming/name-provider.js.map +1 -1
- package/lib/langium/naming/name-separator-validation.d.ts +23 -0
- package/lib/langium/naming/name-separator-validation.d.ts.map +1 -1
- package/lib/langium/naming/name-separator-validation.js +30 -1
- package/lib/langium/naming/name-separator-validation.js.map +1 -1
- package/lib/langium/residency/cst-residency-service.d.ts +31 -11
- package/lib/langium/residency/cst-residency-service.d.ts.map +1 -1
- package/lib/langium/residency/cst-residency-service.js +13 -56
- package/lib/langium/residency/cst-residency-service.js.map +1 -1
- package/lib/langium/scope/hydranium-scope-provider.d.ts +48 -13
- package/lib/langium/scope/hydranium-scope-provider.d.ts.map +1 -1
- package/lib/langium/scope/hydranium-scope-provider.js +56 -20
- package/lib/langium/scope/hydranium-scope-provider.js.map +1 -1
- package/lib/langium/serialization/abstract-serializer.d.ts +11 -20
- package/lib/langium/serialization/abstract-serializer.d.ts.map +1 -1
- package/lib/langium/serialization/abstract-serializer.js +12 -21
- package/lib/langium/serialization/abstract-serializer.js.map +1 -1
- package/lib/langium/service-registry.d.ts +15 -1
- package/lib/langium/service-registry.d.ts.map +1 -1
- package/lib/langium/service-registry.js +16 -0
- package/lib/langium/service-registry.js.map +1 -1
- package/lib/langium/shared-services.d.ts +15 -2
- package/lib/langium/shared-services.d.ts.map +1 -1
- package/lib/langium/shared-services.js.map +1 -1
- package/lib/langium/transfer/transfer-encoder.d.ts +60 -17
- package/lib/langium/transfer/transfer-encoder.d.ts.map +1 -1
- package/lib/langium/transfer/transfer-encoder.js +38 -16
- package/lib/langium/transfer/transfer-encoder.js.map +1 -1
- package/lib/langium/trivia/comment-preserver.d.ts +423 -0
- package/lib/langium/trivia/comment-preserver.d.ts.map +1 -0
- package/lib/langium/trivia/comment-preserver.js +906 -0
- package/lib/langium/trivia/comment-preserver.js.map +1 -0
- package/lib/langium/trivia/document-ending-preserver.d.ts +43 -0
- package/lib/langium/trivia/document-ending-preserver.d.ts.map +1 -0
- package/lib/langium/trivia/document-ending-preserver.js +48 -0
- package/lib/langium/trivia/document-ending-preserver.js.map +1 -0
- package/lib/langium/trivia/index.d.ts +14 -0
- package/lib/langium/trivia/index.d.ts.map +1 -0
- package/lib/langium/trivia/index.js +14 -0
- package/lib/langium/trivia/index.js.map +1 -0
- package/lib/langium/trivia/trivia-contribution.d.ts +37 -0
- package/lib/langium/trivia/trivia-contribution.d.ts.map +1 -0
- package/lib/langium/trivia/trivia-contribution.js +10 -0
- package/lib/langium/trivia/trivia-contribution.js.map +1 -0
- package/lib/langium/trivia/trivia-preserver.d.ts +50 -0
- package/lib/langium/trivia/trivia-preserver.d.ts.map +1 -0
- package/lib/langium/trivia/trivia-preserver.js +10 -0
- package/lib/langium/trivia/trivia-preserver.js.map +1 -0
- package/lib/langium/trivia/trivia-service.d.ts +70 -0
- package/lib/langium/trivia/trivia-service.d.ts.map +1 -0
- package/lib/langium/trivia/trivia-service.js +56 -0
- package/lib/langium/trivia/trivia-service.js.map +1 -0
- package/lib/langium/update-rewrite/update-rewrite.d.ts +1 -1
- package/lib/langium/validation/document-validator.d.ts +294 -10
- package/lib/langium/validation/document-validator.d.ts.map +1 -1
- package/lib/langium/validation/document-validator.js +448 -5
- package/lib/langium/validation/document-validator.js.map +1 -1
- package/lib/langium/workspace/document-uri-policy.d.ts +3 -4
- package/lib/langium/workspace/document-uri-policy.d.ts.map +1 -1
- package/lib/langium/workspace/document-uri-policy.js +3 -4
- package/lib/langium/workspace/document-uri-policy.js.map +1 -1
- package/lib/langium/workspace/file-system-provider.d.ts +9 -1
- package/lib/langium/workspace/file-system-provider.d.ts.map +1 -1
- package/lib/langium/workspace/file-system-provider.js +40 -7
- package/lib/langium/workspace/file-system-provider.js.map +1 -1
- package/lib/langium/workspace/hydranium-langium-document-factory.d.ts +25 -0
- package/lib/langium/workspace/hydranium-langium-document-factory.d.ts.map +1 -1
- package/lib/langium/workspace/hydranium-langium-document-factory.js +25 -0
- package/lib/langium/workspace/hydranium-langium-document-factory.js.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-lock.d.ts +13 -0
- package/lib/langium/workspace/hydranium-workspace-lock.d.ts.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-lock.js +18 -0
- package/lib/langium/workspace/hydranium-workspace-lock.js.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-manager.d.ts +21 -1
- package/lib/langium/workspace/hydranium-workspace-manager.d.ts.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-manager.js +28 -0
- package/lib/langium/workspace/hydranium-workspace-manager.js.map +1 -1
- package/lib/langium/workspace/in-memory-file-system-provider.d.ts +23 -0
- package/lib/langium/workspace/in-memory-file-system-provider.d.ts.map +1 -1
- package/lib/langium/workspace/in-memory-file-system-provider.js +55 -9
- package/lib/langium/workspace/in-memory-file-system-provider.js.map +1 -1
- package/lib/langium/workspace/initialize-workspace.d.ts +31 -2
- package/lib/langium/workspace/initialize-workspace.d.ts.map +1 -1
- package/lib/langium/workspace/initialize-workspace.js +13 -5
- package/lib/langium/workspace/initialize-workspace.js.map +1 -1
- package/lib/langium/workspace/langium-documents.d.ts +79 -17
- package/lib/langium/workspace/langium-documents.d.ts.map +1 -1
- package/lib/langium/workspace/langium-documents.js +83 -28
- package/lib/langium/workspace/langium-documents.js.map +1 -1
- package/lib/langium/workspace/virtual-document.d.ts +18 -3
- package/lib/langium/workspace/virtual-document.d.ts.map +1 -1
- package/lib/langium/workspace/virtual-document.js +19 -2
- package/lib/langium/workspace/virtual-document.js.map +1 -1
- package/lib/langium/workspace/write-lock-scope.d.ts +4 -3
- package/lib/langium/workspace/write-lock-scope.d.ts.map +1 -1
- package/lib/langium/workspace/write-lock-scope.js +4 -3
- package/lib/langium/workspace/write-lock-scope.js.map +1 -1
- package/lib/locale/index.d.ts +10 -0
- package/lib/locale/index.d.ts.map +1 -0
- package/lib/locale/index.js +10 -0
- package/lib/locale/index.js.map +1 -0
- package/lib/locale/server-locale.d.ts +73 -0
- package/lib/locale/server-locale.d.ts.map +1 -0
- package/lib/locale/server-locale.js +61 -0
- package/lib/locale/server-locale.js.map +1 -0
- package/lib/lsp/completion/hydranium-completion-provider.d.ts +44 -2
- package/lib/lsp/completion/hydranium-completion-provider.d.ts.map +1 -1
- package/lib/lsp/completion/hydranium-completion-provider.js +68 -0
- package/lib/lsp/completion/hydranium-completion-provider.js.map +1 -1
- package/lib/lsp/connection-features.d.ts +23 -0
- package/lib/lsp/connection-features.d.ts.map +1 -0
- package/lib/lsp/connection-features.js +60 -0
- package/lib/lsp/connection-features.js.map +1 -0
- package/lib/lsp/diagnostics-connection.d.ts +27 -0
- package/lib/lsp/diagnostics-connection.d.ts.map +1 -0
- package/lib/lsp/diagnostics-connection.js +53 -0
- package/lib/lsp/diagnostics-connection.js.map +1 -0
- package/lib/lsp/hydranium-document-update-handler.d.ts +90 -79
- package/lib/lsp/hydranium-document-update-handler.d.ts.map +1 -1
- package/lib/lsp/hydranium-document-update-handler.js +152 -99
- package/lib/lsp/hydranium-document-update-handler.js.map +1 -1
- package/lib/lsp/index.d.ts +3 -1
- package/lib/lsp/index.d.ts.map +1 -1
- package/lib/lsp/index.js +3 -1
- package/lib/lsp/index.js.map +1 -1
- package/lib/lsp/lsp-latency.d.ts +39 -0
- package/lib/lsp/lsp-latency.d.ts.map +1 -0
- package/lib/lsp/lsp-latency.js +58 -0
- package/lib/lsp/lsp-latency.js.map +1 -0
- package/lib/lsp/semantic-token-provider.d.ts +34 -1
- package/lib/lsp/semantic-token-provider.d.ts.map +1 -1
- package/lib/lsp/semantic-token-provider.js +55 -8
- package/lib/lsp/semantic-token-provider.js.map +1 -1
- package/lib/lsp/shared-module.d.ts +4 -8
- package/lib/lsp/shared-module.d.ts.map +1 -1
- package/lib/lsp/shared-module.js.map +1 -1
- package/lib/lsp/start-language-server.d.ts +8 -7
- package/lib/lsp/start-language-server.d.ts.map +1 -1
- package/lib/lsp/start-language-server.js +13 -7
- package/lib/lsp/start-language-server.js.map +1 -1
- package/lib/messages/carriers.d.ts +54 -0
- package/lib/messages/carriers.d.ts.map +1 -0
- package/lib/messages/carriers.js +62 -0
- package/lib/messages/carriers.js.map +1 -0
- package/lib/messages/index.d.ts +25 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +25 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/renderer.d.ts +142 -0
- package/lib/messages/renderer.d.ts.map +1 -0
- package/lib/messages/renderer.js +165 -0
- package/lib/messages/renderer.js.map +1 -0
- package/lib/node/heap-ceiling.d.ts +61 -0
- package/lib/node/heap-ceiling.d.ts.map +1 -0
- package/lib/node/heap-ceiling.js +72 -0
- package/lib/node/heap-ceiling.js.map +1 -0
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +1 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/latency-from-env.d.ts +1 -1
- package/lib/node/latency-from-env.js +1 -1
- package/lib/node/measure-memory.d.ts.map +1 -1
- package/lib/node/measure-memory.js +1 -0
- package/lib/node/measure-memory.js.map +1 -1
- package/lib/node/node-file-system-provider.d.ts +35 -1
- package/lib/node/node-file-system-provider.d.ts.map +1 -1
- package/lib/node/node-file-system-provider.js +140 -45
- package/lib/node/node-file-system-provider.js.map +1 -1
- package/lib/node/profile-capture.d.ts +8 -2
- package/lib/node/profile-capture.d.ts.map +1 -1
- package/lib/node/profile-capture.js.map +1 -1
- package/lib/node/profiling-run.d.ts +2 -2
- package/lib/node/profiling-run.js +1 -1
- package/lib/node/profiling-run.js.map +1 -1
- package/lib/node/rename-over-open-readers.d.ts +52 -0
- package/lib/node/rename-over-open-readers.d.ts.map +1 -0
- package/lib/node/rename-over-open-readers.js +66 -0
- package/lib/node/rename-over-open-readers.js.map +1 -0
- package/lib/node/socket-launcher.d.ts +16 -1
- package/lib/node/socket-launcher.d.ts.map +1 -1
- package/lib/node/socket-launcher.js +4 -3
- package/lib/node/socket-launcher.js.map +1 -1
- package/lib/node/stdio-launcher.d.ts +1 -1
- package/lib/node/stdio-launcher.d.ts.map +1 -1
- package/lib/node/stdio-launcher.js +1 -1
- package/lib/node/stdio-launcher.js.map +1 -1
- package/lib/testing/fake-document.d.ts +16 -4
- package/lib/testing/fake-document.d.ts.map +1 -1
- package/lib/testing/fake-document.js +18 -3
- package/lib/testing/fake-document.js.map +1 -1
- package/lib/testing/make-noop-shared-services.d.ts +14 -0
- package/lib/testing/make-noop-shared-services.d.ts.map +1 -1
- package/lib/testing/make-noop-shared-services.js +28 -2
- package/lib/testing/make-noop-shared-services.js.map +1 -1
- package/lib/testing/make-test-services.d.ts +62 -14
- package/lib/testing/make-test-services.d.ts.map +1 -1
- package/lib/testing/make-test-services.js +27 -6
- package/lib/testing/make-test-services.js.map +1 -1
- package/lib/testing/node/index.d.ts +1 -0
- package/lib/testing/node/index.d.ts.map +1 -1
- package/lib/testing/node/index.js +1 -0
- package/lib/testing/node/index.js.map +1 -1
- package/lib/testing/node/lsp-harness.d.ts.map +1 -1
- package/lib/testing/node/lsp-harness.js +2 -0
- package/lib/testing/node/lsp-harness.js.map +1 -1
- package/lib/testing/node/lsp-server-connection.d.ts +11 -3
- package/lib/testing/node/lsp-server-connection.d.ts.map +1 -1
- package/lib/testing/node/lsp-server-connection.js +42 -9
- package/lib/testing/node/lsp-server-connection.js.map +1 -1
- package/lib/testing/node/scratch-workspace.d.ts.map +1 -1
- package/lib/testing/node/scratch-workspace.js +10 -5
- package/lib/testing/node/scratch-workspace.js.map +1 -1
- package/lib/testing/node/spawned-server.d.ts +14 -0
- package/lib/testing/node/spawned-server.d.ts.map +1 -1
- package/lib/testing/node/spawned-server.js +33 -1
- package/lib/testing/node/spawned-server.js.map +1 -1
- package/lib/testing/node/unhandled-rejections.d.ts +20 -0
- package/lib/testing/node/unhandled-rejections.d.ts.map +1 -0
- package/lib/testing/node/unhandled-rejections.js +32 -0
- package/lib/testing/node/unhandled-rejections.js.map +1 -0
- package/lib/testing/playwright/flaky-network-proxy.d.ts +76 -0
- package/lib/testing/playwright/flaky-network-proxy.d.ts.map +1 -0
- package/lib/testing/playwright/flaky-network-proxy.js +164 -0
- package/lib/testing/playwright/flaky-network-proxy.js.map +1 -0
- package/lib/testing/playwright/index.d.ts +1 -0
- package/lib/testing/playwright/index.d.ts.map +1 -1
- package/lib/testing/playwright/index.js +1 -0
- package/lib/testing/playwright/index.js.map +1 -1
- package/lib/testing/playwright/server-log-capture.d.ts +14 -4
- package/lib/testing/playwright/server-log-capture.d.ts.map +1 -1
- package/lib/testing/playwright/server-log-capture.js +21 -4
- package/lib/testing/playwright/server-log-capture.js.map +1 -1
- package/lib/testing/playwright/server-log-rename-reporter.d.ts.map +1 -1
- package/lib/testing/playwright/server-log-rename-reporter.js +10 -1
- package/lib/testing/playwright/server-log-rename-reporter.js.map +1 -1
- package/lib/testing/run-update-pipeline.d.ts +4 -4
- package/lib/testing/run-update-pipeline.d.ts.map +1 -1
- package/lib/testing/stub-ast-document-manager.d.ts +10 -9
- package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
- package/lib/testing/stub-ast-document-manager.js +17 -9
- package/lib/testing/stub-ast-document-manager.js.map +1 -1
- package/lib/testing/stub-document-builder.d.ts +26 -11
- package/lib/testing/stub-document-builder.d.ts.map +1 -1
- package/lib/testing/stub-document-builder.js +57 -4
- package/lib/testing/stub-document-builder.js.map +1 -1
- package/lib/testing/stub-hydranium-text-documents.d.ts +22 -7
- package/lib/testing/stub-hydranium-text-documents.d.ts.map +1 -1
- package/lib/testing/stub-hydranium-text-documents.js +92 -15
- package/lib/testing/stub-hydranium-text-documents.js.map +1 -1
- package/lib/testing/stub-langium-documents.d.ts +3 -2
- package/lib/testing/stub-langium-documents.d.ts.map +1 -1
- package/lib/testing/stub-langium-documents.js.map +1 -1
- package/lib/testing/stub-model-service.d.ts +7 -6
- package/lib/testing/stub-model-service.d.ts.map +1 -1
- package/lib/testing/stub-model-service.js +4 -4
- package/lib/testing/stub-model-service.js.map +1 -1
- package/lib/util/connection-liveness.d.ts +7 -6
- package/lib/util/connection-liveness.d.ts.map +1 -1
- package/lib/util/connection-liveness.js +35 -14
- package/lib/util/connection-liveness.js.map +1 -1
- package/package.json +17 -8
- package/src/documents/ast-document-manager.ts +345 -62
- package/src/documents/client-ids.ts +5 -22
- package/src/documents/client-session-errors.ts +24 -0
- package/src/documents/client-session-registry.ts +240 -0
- package/src/documents/file-system-task-queue.ts +68 -0
- package/src/documents/hydranium-text-documents.ts +856 -154
- package/src/documents/index.ts +3 -0
- package/src/documents/language-client-text-shadow.ts +59 -11
- package/src/documents/self-save-registry.ts +52 -13
- package/src/index.ts +6 -0
- package/src/langium/ast-extension/ast-node-builder.ts +66 -22
- package/src/langium/bootstrap.ts +16 -9
- package/src/langium/config/configuration-provider.ts +119 -0
- package/src/langium/config/index.ts +1 -0
- package/src/langium/diagnostics/lsp-logger.ts +41 -6
- package/src/langium/document-builder/build-pipeline-integration.ts +50 -5
- package/src/langium/document-builder/build-session.ts +87 -0
- package/src/langium/document-builder/document-builder.ts +698 -39
- package/src/langium/document-builder/index.ts +1 -0
- package/src/langium/integration-services.ts +67 -6
- package/src/langium/integrity/integrity-rule.ts +13 -5
- package/src/langium/integrity/integrity-service.ts +202 -17
- package/src/langium/keys/containment.ts +87 -0
- package/src/langium/keys/index.ts +1 -0
- package/src/langium/keys/name-based-key-provider.ts +4 -0
- package/src/langium/language-module.ts +42 -4
- package/src/langium/model-service/client-session.ts +606 -0
- package/src/langium/model-service/index.ts +1 -0
- package/src/langium/model-service/model-service.ts +393 -349
- package/src/langium/module.ts +137 -30
- package/src/langium/naming/name-provider.ts +27 -5
- package/src/langium/naming/name-separator-validation.ts +34 -5
- package/src/langium/residency/cst-residency-service.ts +36 -14
- package/src/langium/scope/hydranium-scope-provider.ts +60 -22
- package/src/langium/serialization/abstract-serializer.ts +13 -32
- package/src/langium/service-registry.ts +19 -2
- package/src/langium/shared-services.ts +19 -2
- package/src/langium/transfer/transfer-encoder.ts +85 -24
- package/src/langium/trivia/comment-preserver.ts +1100 -0
- package/src/langium/trivia/document-ending-preserver.ts +55 -0
- package/src/langium/trivia/index.ts +14 -0
- package/src/langium/trivia/trivia-contribution.ts +39 -0
- package/src/langium/trivia/trivia-preserver.ts +54 -0
- package/src/langium/trivia/trivia-service.ts +99 -0
- package/src/langium/update-rewrite/update-rewrite.ts +1 -1
- package/src/langium/validation/document-validator.ts +537 -11
- package/src/langium/workspace/document-uri-policy.ts +3 -4
- package/src/langium/workspace/file-system-provider.ts +48 -8
- package/src/langium/workspace/hydranium-langium-document-factory.ts +34 -0
- package/src/langium/workspace/hydranium-workspace-lock.ts +21 -0
- package/src/langium/workspace/hydranium-workspace-manager.ts +30 -1
- package/src/langium/workspace/in-memory-file-system-provider.ts +62 -10
- package/src/langium/workspace/initialize-workspace.ts +43 -5
- package/src/langium/workspace/langium-documents.ts +106 -33
- package/src/langium/workspace/virtual-document.ts +21 -3
- package/src/langium/workspace/write-lock-scope.ts +4 -3
- package/src/locale/index.ts +10 -0
- package/src/locale/server-locale.ts +86 -0
- package/src/lsp/completion/hydranium-completion-provider.ts +82 -2
- package/src/lsp/connection-features.ts +67 -0
- package/src/lsp/diagnostics-connection.ts +56 -0
- package/src/lsp/hydranium-document-update-handler.ts +182 -106
- package/src/lsp/index.ts +3 -1
- package/src/lsp/lsp-latency.ts +62 -0
- package/src/lsp/semantic-token-provider.ts +74 -7
- package/src/lsp/shared-module.ts +4 -8
- package/src/lsp/start-language-server.ts +13 -7
- package/src/messages/carriers.ts +78 -0
- package/src/messages/index.ts +36 -0
- package/src/messages/renderer.ts +212 -0
- package/src/node/heap-ceiling.ts +108 -0
- package/src/node/index.ts +1 -0
- package/src/node/latency-from-env.ts +1 -1
- package/src/node/measure-memory.ts +1 -0
- package/src/node/node-file-system-provider.ts +154 -47
- package/src/node/profile-capture.ts +8 -2
- package/src/node/profiling-run.ts +3 -3
- package/src/node/rename-over-open-readers.ts +78 -0
- package/src/node/socket-launcher.ts +19 -4
- package/src/node/stdio-launcher.ts +1 -2
- package/src/testing/fake-document.ts +24 -5
- package/src/testing/make-noop-shared-services.ts +50 -2
- package/src/testing/make-test-services.ts +103 -27
- package/src/testing/node/index.ts +1 -0
- package/src/testing/node/lsp-harness.ts +2 -0
- package/src/testing/node/lsp-server-connection.ts +61 -11
- package/src/testing/node/scratch-workspace.ts +10 -5
- package/src/testing/node/spawned-server.ts +35 -1
- package/src/testing/node/unhandled-rejections.ts +31 -0
- package/src/testing/playwright/flaky-network-proxy.ts +240 -0
- package/src/testing/playwright/index.ts +1 -0
- package/src/testing/playwright/server-log-capture.ts +24 -5
- package/src/testing/playwright/server-log-rename-reporter.ts +12 -1
- package/src/testing/run-update-pipeline.ts +4 -4
- package/src/testing/stub-ast-document-manager.ts +28 -21
- package/src/testing/stub-document-builder.ts +83 -17
- package/src/testing/stub-hydranium-text-documents.ts +127 -22
- package/src/testing/stub-langium-documents.ts +3 -2
- package/src/testing/stub-model-service.ts +9 -8
- package/src/util/connection-liveness.ts +37 -14
- package/lib/lsp/instrument-connection.d.ts +0 -36
- package/lib/lsp/instrument-connection.d.ts.map +0 -1
- package/lib/lsp/instrument-connection.js +0 -62
- package/lib/lsp/instrument-connection.js.map +0 -1
- package/src/lsp/instrument-connection.ts +0 -66
|
@@ -7,9 +7,14 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { ObservableValue } from '@hydranium/protocol';
|
|
10
|
-
import { DefaultDocumentBuilder, DocumentState, OperationCancelled, UriUtils, interruptAndCheck, isOperationCancelled } from '@hydranium/langium';
|
|
11
|
-
|
|
10
|
+
import { DefaultDocumentBuilder, DocumentState, MultiMap, OperationCancelled, UriUtils, interruptAndCheck, isOperationCancelled } from '@hydranium/langium';
|
|
11
|
+
// `Diagnostic` as a VALUE: `renderDiagnostics` needs its `getMessageString`
|
|
12
|
+
// namespace helper to read the `string | MarkupContent` union without
|
|
13
|
+
// restating it.
|
|
14
|
+
import { CancellationToken, Diagnostic, Disposable } from 'vscode-languageserver-protocol';
|
|
12
15
|
import { CST_REHYDRATION_RESET_STATE, isCstShed } from '../residency/cst-residency-service.js';
|
|
16
|
+
import { HydraniumWorkspaceLock } from '../workspace/hydranium-workspace-lock.js';
|
|
17
|
+
import { BuildSession } from './build-session.js';
|
|
13
18
|
import { labelPhaseListener } from './labeled-phase-listener.js';
|
|
14
19
|
/** Document states a phase-reached line is emitted for by default — every built phase. */
|
|
15
20
|
export const DEFAULT_LOGGED_PHASES = [
|
|
@@ -20,6 +25,19 @@ export const DEFAULT_LOGGED_PHASES = [
|
|
|
20
25
|
DocumentState.IndexedReferences,
|
|
21
26
|
DocumentState.Validated
|
|
22
27
|
];
|
|
28
|
+
/**
|
|
29
|
+
* The build reasons the framework stages through
|
|
30
|
+
* {@link HydraniumDocumentBuilder.markNextReason}: the LSP events the update
|
|
31
|
+
* handler dispatches on, and `didClose` for the revert the text store runs
|
|
32
|
+
* after a last close. Exposed so a subclass layering reasons of its own keeps
|
|
33
|
+
* the names the framework emits.
|
|
34
|
+
*/
|
|
35
|
+
export const HYDRANIUM_BUILD_REASONS = Object.freeze({
|
|
36
|
+
didOpen: 'didOpen',
|
|
37
|
+
didChangeContent: 'didChangeContent',
|
|
38
|
+
didChangeWatchedFiles: 'didChangeWatchedFiles',
|
|
39
|
+
didClose: 'didClose'
|
|
40
|
+
});
|
|
23
41
|
/**
|
|
24
42
|
* Consecutive re-queued builds that leave a waited-on document at the same state
|
|
25
43
|
* before {@link HydraniumDocumentBuilder.awaitDocumentState} stops re-queuing it.
|
|
@@ -32,25 +50,37 @@ const MAX_STALLED_REQUEUES = 3;
|
|
|
32
50
|
* Extends Langium's {@link DefaultDocumentBuilder} with:
|
|
33
51
|
*
|
|
34
52
|
* - **Bug-fixes** (always on): an {@link awaitDocumentState} that waits where
|
|
35
|
-
* the default rejects,
|
|
53
|
+
* the default rejects (re-queuing, under the workspace lock, a document no
|
|
54
|
+
* build will carry), a {@link prepareBuild} that keeps a cancelled
|
|
36
55
|
* non-validating build from suppressing validation, and a
|
|
37
56
|
* {@link shouldRelink} that never judges a document unaffected on an index
|
|
38
57
|
* that does not describe it.
|
|
58
|
+
* - **Shared locked builds** ({@link scheduleUpdate}): build requests that
|
|
59
|
+
* coincide share one locked build instead of cancelling each other.
|
|
39
60
|
* - **URI handling** (always on): directory-aware flattening and cascade
|
|
40
61
|
* deletes in {@link update}, plus the CST-rehydration and cross-document
|
|
41
62
|
* refresh resets in {@link resetToState}.
|
|
42
63
|
* - **In-place rebuild helpers** — {@link reparse} and
|
|
43
64
|
* {@link reparseAndRelink} — for a build-phase listener that mutated a
|
|
44
65
|
* document's AST and must reconcile it within the same build.
|
|
45
|
-
* - **Diagnostic dedupe** at `Validated` ({@link dedupeDiagnostics})
|
|
66
|
+
* - **Diagnostic dedupe** at `Validated` ({@link dedupeDiagnostics}), followed
|
|
67
|
+
* by the **one server-side message render** every head inherits
|
|
68
|
+
* ({@link renderDiagnostics}).
|
|
69
|
+
* - **Build sessions** ({@link BuildSession}): each `update` / `build` call is
|
|
70
|
+
* one correlated unit carrying an id, a trigger label, a start time and
|
|
71
|
+
* cancellation lineage, so every line of a rebuild reads as belonging to it
|
|
72
|
+
* and a preempted build is distinguishable from the winner.
|
|
46
73
|
* - **Logging instrumentation** (default on, opt-out via `logLevel: 'off'`):
|
|
47
|
-
* phase-reached lines, slow-listener breakdowns on
|
|
48
|
-
* and slow-build-phase totals on `notifyBuildPhase`.
|
|
74
|
+
* a per-build line, phase-reached lines, slow-listener breakdowns on
|
|
75
|
+
* `notifyDocumentPhase`, and slow-build-phase totals on `notifyBuildPhase`.
|
|
49
76
|
*
|
|
50
77
|
* Adopters extend this class — the configuration knobs cover what most
|
|
51
78
|
* adopters need; the `format*Line` methods, `formatUri`, and
|
|
52
79
|
* `collectDeletedURIs` are protected so subclasses can customise wording or
|
|
53
|
-
* domain-aware cascades without re-implementing surrounding logic.
|
|
80
|
+
* domain-aware cascades without re-implementing surrounding logic. An adopter
|
|
81
|
+
* with build-scoped state of its own subclasses {@link BuildSession} and
|
|
82
|
+
* overrides {@link createBuildSession}, which puts that state under the same
|
|
83
|
+
* preemption-correct teardown rather than a reimplementation of it.
|
|
54
84
|
*/
|
|
55
85
|
export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
56
86
|
tracer;
|
|
@@ -64,8 +94,15 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
64
94
|
slowListenerMs;
|
|
65
95
|
/** Live slow-build-phase-total threshold; read `.value` per phase. */
|
|
66
96
|
slowBuildMs;
|
|
97
|
+
/** Live phase-detail buffering threshold; read `.value` once per build, onto the session. */
|
|
98
|
+
phaseDetailMs;
|
|
67
99
|
uriPolicy;
|
|
68
100
|
clock;
|
|
101
|
+
messageRenderer;
|
|
102
|
+
/** The lock {@link scheduleUpdate} builds under. */
|
|
103
|
+
workspaceLock;
|
|
104
|
+
/** The latest write {@link scheduleUpdate} queued, until it ends; see {@link ScheduledUpdate}. */
|
|
105
|
+
scheduledUpdate;
|
|
69
106
|
/** Narrower handle on the same registry as the inherited `serviceRegistry`, for {@link ExtendedServiceRegistry.registrations}. */
|
|
70
107
|
languageRegistry;
|
|
71
108
|
languageFileExtensions = [];
|
|
@@ -76,17 +113,49 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
76
113
|
refreshCrossDocumentComputedScopes;
|
|
77
114
|
/** LSP event name (e.g. `'didChangeWatchedFiles'`) staged for the next `update()` call. */
|
|
78
115
|
pendingUpdateReason;
|
|
116
|
+
/**
|
|
117
|
+
* The build currently in progress, or `undefined` between builds.
|
|
118
|
+
*
|
|
119
|
+
* A subclass carrying its own build-scoped state returns a {@link BuildSession}
|
|
120
|
+
* subclass from {@link createBuildSession} and narrows this with a typeguard
|
|
121
|
+
* where it reads that state — rather than redeclaring the field, whose
|
|
122
|
+
* initialiser would run after `super()` and clear a session opened during
|
|
123
|
+
* construction.
|
|
124
|
+
*/
|
|
125
|
+
activeSession;
|
|
126
|
+
/**
|
|
127
|
+
* `traceId` of the last build that ended in cancellation, for the successor's
|
|
128
|
+
* "cancels #N" tag. Held here rather than on a session because the session
|
|
129
|
+
* that carries it is already gone by the time its successor is opened.
|
|
130
|
+
*/
|
|
131
|
+
lastCancelledTraceId;
|
|
132
|
+
/** Registered through {@link onDocumentPhaseDelivered}, by phase. */
|
|
133
|
+
documentPhaseDeliveredListeners = new MultiMap();
|
|
134
|
+
/**
|
|
135
|
+
* Called with `false` by {@link buildDocuments} once a build has run every
|
|
136
|
+
* phase, and with `true` by {@link checkWaitsOnceDrained} after a build that
|
|
137
|
+
* threw; see {@link awaitDocumentState}. A listener runs synchronously,
|
|
138
|
+
* inside the build or inside that check's lock read. A throw fails the
|
|
139
|
+
* finished build; in the read it skips the listeners after it and surfaces
|
|
140
|
+
* only as an unhandled rejection.
|
|
141
|
+
*/
|
|
142
|
+
buildEndedListeners = new Set();
|
|
143
|
+
/** Set while the lock read {@link checkWaitsOnceDrained} queued has not run. */
|
|
144
|
+
drainCheckQueued = false;
|
|
79
145
|
constructor(services, options = {}) {
|
|
80
146
|
super(services);
|
|
81
147
|
this.languageRegistry = services.ServiceRegistry;
|
|
82
148
|
this.uriPolicy = services.workspace.DocumentUriPolicy;
|
|
83
149
|
this.clock = services.Clock;
|
|
150
|
+
this.messageRenderer = services.MessageRenderer;
|
|
151
|
+
this.workspaceLock = services.workspace.WorkspaceLock;
|
|
84
152
|
this.tracer = services.Tracer.for(options.logName ?? 'DocumentBuilder').trace('instantiated');
|
|
85
153
|
this.logLevel = options.logLevel ?? 'debug';
|
|
86
154
|
this.loggedPhases = options.loggedPhases ?? DEFAULT_LOGGED_PHASES;
|
|
87
155
|
this.slowPhaseMs = ObservableValue.from(options.slowPhaseMs ?? 25);
|
|
88
156
|
this.slowListenerMs = ObservableValue.from(options.slowListenerMs ?? 5);
|
|
89
157
|
this.slowBuildMs = ObservableValue.from(options.slowBuildMs ?? 25);
|
|
158
|
+
this.phaseDetailMs = ObservableValue.from(options.phaseDetailMs ?? 0);
|
|
90
159
|
this.refreshCrossDocumentComputedScopes = options.refreshCrossDocumentComputedScopes ?? false;
|
|
91
160
|
if (this.logLevel !== 'off') {
|
|
92
161
|
this.registerPhaseListeners();
|
|
@@ -97,8 +166,8 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
97
166
|
// ============================================================
|
|
98
167
|
/**
|
|
99
168
|
* Stage an LSP event name for the next `update()` call. Adopters call before
|
|
100
|
-
* the update fires; `HydraniumDocumentUpdateHandler` does it for the
|
|
101
|
-
*
|
|
169
|
+
* the update fires; `HydraniumDocumentUpdateHandler` does it for the LSP
|
|
170
|
+
* events, and the text store for the revert that follows a last close.
|
|
102
171
|
*
|
|
103
172
|
* The framework stages the value and never reads it back. The consumer is a
|
|
104
173
|
* subclass overriding the build logging, which takes
|
|
@@ -109,6 +178,23 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
109
178
|
markNextReason(reason) {
|
|
110
179
|
this.pendingUpdateReason = reason;
|
|
111
180
|
}
|
|
181
|
+
/**
|
|
182
|
+
* Call `listener` with a document once every {@link onDocumentPhase}
|
|
183
|
+
* listener of `state` ran for it and none was skipped by cancellation, and
|
|
184
|
+
* with the text version the phase listeners were called at. A write during
|
|
185
|
+
* them moves the document's own version on, past what they saw.
|
|
186
|
+
*
|
|
187
|
+
* Only here is it known what the phase listeners delivered. Langium sets the
|
|
188
|
+
* document's state before it notifies, and a cancel between two listeners
|
|
189
|
+
* skips the rest, leaving the document at the phase with those listeners
|
|
190
|
+
* never run and nothing to run them later. A build-phase listener comes too
|
|
191
|
+
* late: a cancel after this document but before the batch ends skips it,
|
|
192
|
+
* although every listener of this document ran.
|
|
193
|
+
*/
|
|
194
|
+
onDocumentPhaseDelivered(state, listener) {
|
|
195
|
+
this.documentPhaseDeliveredListeners.add(state, listener);
|
|
196
|
+
return Disposable.create(() => this.documentPhaseDeliveredListeners.delete(state, listener));
|
|
197
|
+
}
|
|
112
198
|
/**
|
|
113
199
|
* Diagnostic snapshot for use in timeout/error messages around document
|
|
114
200
|
* state.
|
|
@@ -126,7 +212,15 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
126
212
|
const doc = this.langiumDocuments.getDocument(UriUtils.toUri(this.uriPolicy.canonicalUri(uri)));
|
|
127
213
|
const docState = doc ? DocumentState[doc.state] : 'unknown (document not loaded)';
|
|
128
214
|
const lastPhase = this.lastPhaseMs > 0 ? `${Math.round(performance.now() - this.lastPhaseMs)}ms ago` : 'no phase observed';
|
|
129
|
-
return `current state: '${docState}', last phase: ${lastPhase}`;
|
|
215
|
+
return `current state: '${docState}', last phase: ${lastPhase}, active build: ${this.formatSession(this.activeSession)}`;
|
|
216
|
+
}
|
|
217
|
+
/** Render a session for a status line. `undefined` — no build in progress — reads as `none`. */
|
|
218
|
+
formatSession(session) {
|
|
219
|
+
if (!session) {
|
|
220
|
+
return 'none';
|
|
221
|
+
}
|
|
222
|
+
const id = session.traceId !== undefined ? `#${session.traceId}` : 'untimed';
|
|
223
|
+
return `${id} (${session.trigger}, ${Math.round(performance.now() - session.startMs)}ms in)`;
|
|
130
224
|
}
|
|
131
225
|
// ============================================================
|
|
132
226
|
// Bug-fixes (always on)
|
|
@@ -145,20 +239,36 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
145
239
|
*
|
|
146
240
|
* Replacing Langium's rejection with a wait makes the wait's liveness this
|
|
147
241
|
* class's responsibility: a listener can only fire if some build is still
|
|
148
|
-
* going to reach `state`.
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
* the
|
|
242
|
+
* going to reach `state`. So the wait re-queues the document whenever
|
|
243
|
+
* {@link isOrphaned} holds: once when it is armed, and again after every
|
|
244
|
+
* build that completes (see {@link buildDocuments}). The second check is
|
|
245
|
+
* the one a wait armed during a build needs, since only the build's end
|
|
246
|
+
* shows whether it left the document behind; Langium's `onBuildPhase` for
|
|
247
|
+
* `Validated` cannot serve, as it stays silent for a build that validates
|
|
248
|
+
* nothing, such as the workspace's initial one. A build that throws is
|
|
249
|
+
* checked once the lock drains instead (see {@link checkWaitsOnceDrained}):
|
|
250
|
+
* whatever cancelled it may build nothing. Re-queuing stops after
|
|
152
251
|
* {@link MAX_STALLED_REQUEUES} builds that fail to advance the document, so a
|
|
153
252
|
* document the builder will never carry to `state` degrades to a pending wait
|
|
154
253
|
* plus a warning rather than an endless build loop.
|
|
254
|
+
*
|
|
255
|
+
* A wait for `Validated` on a document that a validating build skips
|
|
256
|
+
* resolves once that build has indexed its references, without diagnostics:
|
|
257
|
+
* see {@link skipsValidation}. Waiting on would never end, and re-queuing
|
|
258
|
+
* would skip it again.
|
|
259
|
+
*
|
|
260
|
+
* A re-queued build takes the {@link WorkspaceLock} (see
|
|
261
|
+
* {@link requeueOrphaned}), so a caller that awaits this wait while it holds
|
|
262
|
+
* the lock, inside a read or write action, deadlocks on a document that needs
|
|
263
|
+
* a re-queue: the build waits for that action to end. Await it outside the
|
|
264
|
+
* lock.
|
|
155
265
|
*/
|
|
156
266
|
awaitDocumentState(state, uri, cancelToken) {
|
|
157
267
|
const document = this.langiumDocuments.getDocument(uri);
|
|
158
268
|
if (!document) {
|
|
159
269
|
return super.awaitDocumentState(state, uri, cancelToken);
|
|
160
270
|
}
|
|
161
|
-
if (document.state >= state) {
|
|
271
|
+
if (document.state >= state || (state === DocumentState.Validated && this.skipsValidation(document))) {
|
|
162
272
|
return Promise.resolve(uri);
|
|
163
273
|
}
|
|
164
274
|
return new Promise((resolve, reject) => {
|
|
@@ -194,34 +304,63 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
194
304
|
resolve(doc.uri);
|
|
195
305
|
}
|
|
196
306
|
}, 'awaitDocumentState'));
|
|
197
|
-
|
|
198
|
-
|
|
307
|
+
// The phase after which a validating build either validates the
|
|
308
|
+
// document or has skipped it.
|
|
309
|
+
const skipDisposable = state === DocumentState.Validated
|
|
310
|
+
? this.onDocumentPhase(DocumentState.IndexedReferences, labelPhaseListener((doc) => {
|
|
311
|
+
if (UriUtils.equals(doc.uri, uri) && this.skipsValidation(doc)) {
|
|
312
|
+
cleanup();
|
|
313
|
+
resolve(doc.uri);
|
|
314
|
+
}
|
|
315
|
+
}, 'awaitDocumentState.skipsValidation'))
|
|
316
|
+
: Disposable.create(() => undefined);
|
|
317
|
+
const buildEnded = (drained) => {
|
|
318
|
+
if (document.state >= state || (state === DocumentState.Validated && this.skipsValidation(document))) {
|
|
199
319
|
cleanup();
|
|
200
320
|
resolve(uri);
|
|
201
321
|
}
|
|
202
|
-
else {
|
|
203
|
-
//
|
|
204
|
-
|
|
322
|
+
else if (drained ? this.activeSession === undefined : this.isOrphaned(document, state)) {
|
|
323
|
+
// No build is left to carry the document to `state`. Either
|
|
324
|
+
// check fails only while an unlocked build still runs; that
|
|
325
|
+
// build carries the document or ends here too.
|
|
326
|
+
requeue(drained ? 'build ended early' : 'build ended short of the target');
|
|
205
327
|
}
|
|
206
|
-
}
|
|
328
|
+
};
|
|
329
|
+
this.buildEndedListeners.add(buildEnded);
|
|
330
|
+
const buildDisposable = Disposable.create(() => this.buildEndedListeners.delete(buildEnded));
|
|
207
331
|
const cancelDisposable = cancelToken.onCancellationRequested(() => {
|
|
208
332
|
cleanup();
|
|
209
333
|
reject(OperationCancelled);
|
|
210
334
|
});
|
|
211
335
|
const cleanup = () => {
|
|
212
336
|
phaseDisposable.dispose();
|
|
337
|
+
skipDisposable.dispose();
|
|
213
338
|
buildDisposable.dispose();
|
|
214
339
|
cancelDisposable.dispose();
|
|
215
340
|
};
|
|
216
341
|
// Orphaned BEFORE the wait was armed: the build that would have
|
|
217
|
-
// advanced this document has already finished, so
|
|
218
|
-
//
|
|
219
|
-
// the resulting build resolves this wait.
|
|
342
|
+
// advanced this document has already finished, so none of these
|
|
343
|
+
// listeners fires until some other build runs. Re-queue now — the listeners are
|
|
344
|
+
// registered, so the resulting build resolves this wait.
|
|
220
345
|
if (this.isOrphaned(document, state)) {
|
|
221
346
|
requeue('quiescent builder');
|
|
222
347
|
}
|
|
223
348
|
});
|
|
224
349
|
}
|
|
350
|
+
/**
|
|
351
|
+
* Whether the build that carries or last carried `document` has indexed its
|
|
352
|
+
* references, asks for validation, and still skips it, which is an override
|
|
353
|
+
* of `shouldValidate` excluding it. A build that does not ask for
|
|
354
|
+
* validation, such as the workspace's initial one, is not a skip: the next
|
|
355
|
+
* validating build validates the document. Nor is a document below
|
|
356
|
+
* `IndexedReferences`: the build writes its options before the first phase,
|
|
357
|
+
* so the document would pass for skipped before it is even parsed.
|
|
358
|
+
*/
|
|
359
|
+
skipsValidation(document) {
|
|
360
|
+
return (document.state >= DocumentState.IndexedReferences &&
|
|
361
|
+
Boolean(this.getBuildOptions(document).validation) &&
|
|
362
|
+
!this.shouldValidate(document));
|
|
363
|
+
}
|
|
225
364
|
/**
|
|
226
365
|
* Whether no build will advance `document` to `state`, so a wait on it can
|
|
227
366
|
* only be resolved by starting one.
|
|
@@ -239,7 +378,9 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
239
378
|
* `currentState` still advances to `Validated` (the validation phase runs
|
|
240
379
|
* over an empty document list). Any first read that wants diagnostics — a
|
|
241
380
|
* one-shot data-head read, a CLI query, `ModelService.validated` — lands
|
|
242
|
-
* here.
|
|
381
|
+
* here. A read that arrives while that build still runs finds `currentState`
|
|
382
|
+
* below `state`, so this holds for it only once the build has ended, which
|
|
383
|
+
* is why {@link awaitDocumentState} asks again then.
|
|
243
384
|
*/
|
|
244
385
|
isOrphaned(document, state) {
|
|
245
386
|
return document.state < state && this.currentState >= state;
|
|
@@ -250,13 +391,198 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
250
391
|
* notification, so awaiting here would invert the dependency. A rejection is
|
|
251
392
|
* logged rather than swallowed — it leaves the waiter pending until its own
|
|
252
393
|
* cancellation token fires, which is worth a line in the log.
|
|
394
|
+
*
|
|
395
|
+
* The build is a {@link scheduleUpdate}, entered from a {@link WorkspaceLock}
|
|
396
|
+
* read. The read waits until no write runs or is queued, so the build neither
|
|
397
|
+
* runs beside a locked one nor cancels the build a re-queue is fired from.
|
|
398
|
+
* Unlocked, it runs beside a locked build that cannot cancel it: both
|
|
399
|
+
* validate the same version and deliver it twice. Taking the write directly,
|
|
400
|
+
* without the read, cancels the running build and skips the rest of its
|
|
401
|
+
* build-phase listeners. The read must not await the write, which queues
|
|
402
|
+
* behind that read. A build scheduled in the gap between the read batch
|
|
403
|
+
* starting and this action running is still queued, so the re-queue merges
|
|
404
|
+
* into it rather than cancelling it.
|
|
405
|
+
*
|
|
406
|
+
* A write that ran while the read waited may have carried the document to
|
|
407
|
+
* `state` already, and a second build would deliver that version again; the
|
|
408
|
+
* read skips the write then.
|
|
253
409
|
*/
|
|
254
410
|
requeueOrphaned(document, state, reason) {
|
|
255
411
|
const tracer = this.tracer.withUri(document.uri.toString());
|
|
256
412
|
tracer.info(`Re-queuing orphaned document (at '${DocumentState[document.state]}', needs '${DocumentState[state]}'): ${reason}`);
|
|
257
|
-
this.
|
|
258
|
-
if (
|
|
259
|
-
|
|
413
|
+
void this.workspaceLock.read(() => {
|
|
414
|
+
if (document.state >= state) {
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
this.scheduleUpdate([document.uri], []).catch((err) => {
|
|
418
|
+
if (!isOperationCancelled(err)) {
|
|
419
|
+
tracer.error(`Re-queue build failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
// ============================================================
|
|
425
|
+
// Scheduled updates — one locked build for requests that coincide
|
|
426
|
+
// ============================================================
|
|
427
|
+
/**
|
|
428
|
+
* Build `changed` and `deleted` under the {@link WorkspaceLock}, as
|
|
429
|
+
* `workspaceLock.write(token => update(changed, deleted, token))` would,
|
|
430
|
+
* except where the build this method queued last already carries the
|
|
431
|
+
* request. The promise settles when the build that carries the request
|
|
432
|
+
* ends, completed or cancelled, as the lock's own promise does.
|
|
433
|
+
*
|
|
434
|
+
* Without it, requests that coincide cancel each other: each lock write
|
|
435
|
+
* cancels the one before it, after Langium's `update` has already reset the
|
|
436
|
+
* documents, scanned the workspace for relinking and called every
|
|
437
|
+
* `onUpdate` listener.
|
|
438
|
+
*
|
|
439
|
+
* - **Queued, not yet running:** the request merges into it, so nothing is
|
|
440
|
+
* cancelled. The later of a change and a deletion of one URI wins, so
|
|
441
|
+
* each URI reaches `update` in one list only: a file deleted and written
|
|
442
|
+
* again before the build starts is a change.
|
|
443
|
+
* - **Running:** the request joins it only when {@link canJoinRunningUpdate}
|
|
444
|
+
* holds, which keeps an edit made while it runs cancelling it.
|
|
445
|
+
* - **Otherwise,** or when anything else has cancelled that write since it
|
|
446
|
+
* was queued, a new write, which cancels the running build as any lock
|
|
447
|
+
* write does.
|
|
448
|
+
*
|
|
449
|
+
* `reason` is staged through {@link markNextReason} when the write runs. The
|
|
450
|
+
* latest reason of a merged request wins, as it does in the update
|
|
451
|
+
* handler's own debounced burst; a joining request's reason is dropped, since
|
|
452
|
+
* the build it joins has already started. A request without one leaves a
|
|
453
|
+
* reason staged by the caller in place.
|
|
454
|
+
*
|
|
455
|
+
* A caller that must run code of its own inside the write action takes the
|
|
456
|
+
* lock itself, and forgoes the sharing. A lock that is not a
|
|
457
|
+
* {@link HydraniumWorkspaceLock} cannot report a cancelled queued write, so
|
|
458
|
+
* every request then takes its own write.
|
|
459
|
+
*/
|
|
460
|
+
scheduleUpdate(changed, deleted, reason) {
|
|
461
|
+
const lock = this.workspaceLock;
|
|
462
|
+
if (!(lock instanceof HydraniumWorkspaceLock)) {
|
|
463
|
+
return lock.write(token => {
|
|
464
|
+
if (reason !== undefined) {
|
|
465
|
+
this.markNextReason(reason);
|
|
466
|
+
}
|
|
467
|
+
return this.update(changed, deleted, token);
|
|
468
|
+
});
|
|
469
|
+
}
|
|
470
|
+
const scheduled = this.scheduledUpdate;
|
|
471
|
+
if (scheduled && scheduled.cancellations === lock.writeCancellations) {
|
|
472
|
+
if (!scheduled.takenVersions) {
|
|
473
|
+
for (const uri of changed) {
|
|
474
|
+
scheduled.changed.set(uri.toString(), uri);
|
|
475
|
+
scheduled.deleted.delete(uri.toString());
|
|
476
|
+
}
|
|
477
|
+
for (const uri of deleted) {
|
|
478
|
+
scheduled.deleted.set(uri.toString(), uri);
|
|
479
|
+
scheduled.changed.delete(uri.toString());
|
|
480
|
+
}
|
|
481
|
+
scheduled.reason = reason ?? scheduled.reason;
|
|
482
|
+
return scheduled.promise;
|
|
483
|
+
}
|
|
484
|
+
if (this.canJoinRunningUpdate(scheduled, changed, deleted)) {
|
|
485
|
+
return scheduled.promise;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
// The action runs on a later tick, by which time `request` is assigned.
|
|
489
|
+
const promise = lock.write(token => this.runScheduledUpdate(request, token));
|
|
490
|
+
const request = {
|
|
491
|
+
changed: new Map(changed.map(uri => [uri.toString(), uri])),
|
|
492
|
+
deleted: new Map(deleted.map(uri => [uri.toString(), uri])),
|
|
493
|
+
reason,
|
|
494
|
+
cancellations: lock.writeCancellations,
|
|
495
|
+
promise
|
|
496
|
+
};
|
|
497
|
+
this.scheduledUpdate = request;
|
|
498
|
+
return promise;
|
|
499
|
+
}
|
|
500
|
+
/**
|
|
501
|
+
* Whether a request for `changed` and `deleted` is carried by the running
|
|
502
|
+
* `scheduled` build, whose write nothing has cancelled: the request deletes
|
|
503
|
+
* nothing, and each changed URI is one the build took, held by the text
|
|
504
|
+
* store at the version it had when the build started.
|
|
505
|
+
*
|
|
506
|
+
* Each condition keeps a request from joining a build that would miss its
|
|
507
|
+
* change. Text that moved since the start may be newer than what the build
|
|
508
|
+
* parsed; a URI the text store does not hold is read from its file, which
|
|
509
|
+
* may have changed after the build read it; and a deletion may concern a
|
|
510
|
+
* document the build has already built. A joined request is also absent
|
|
511
|
+
* from the running `update`'s `onUpdate` call, which reported the store as
|
|
512
|
+
* it was when the build started; at an unchanged version that is the store
|
|
513
|
+
* the request sees.
|
|
514
|
+
*/
|
|
515
|
+
canJoinRunningUpdate(scheduled, changed, deleted) {
|
|
516
|
+
const taken = scheduled.takenVersions;
|
|
517
|
+
if (!taken || deleted.length > 0) {
|
|
518
|
+
return false;
|
|
519
|
+
}
|
|
520
|
+
return changed.every(uri => taken.has(uri.toString()) && taken.get(uri.toString()) === this.textDocuments?.get(uri)?.version);
|
|
521
|
+
}
|
|
522
|
+
/**
|
|
523
|
+
* The write action of a {@link scheduleUpdate}: freeze the request, record
|
|
524
|
+
* what it takes, stage its reason and run `update`. Releases
|
|
525
|
+
* {@link scheduledUpdate} inside the lock, whatever throws, so a request
|
|
526
|
+
* arriving after the build ends starts a write of its own rather than
|
|
527
|
+
* joining a build that is over.
|
|
528
|
+
*/
|
|
529
|
+
async runScheduledUpdate(request, token) {
|
|
530
|
+
try {
|
|
531
|
+
const taken = new Map();
|
|
532
|
+
for (const [key, uri] of request.changed) {
|
|
533
|
+
const version = this.textDocuments?.get(uri)?.version;
|
|
534
|
+
if (version !== undefined) {
|
|
535
|
+
taken.set(key, version);
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
request.takenVersions = taken;
|
|
539
|
+
if (request.reason !== undefined) {
|
|
540
|
+
this.markNextReason(request.reason);
|
|
541
|
+
}
|
|
542
|
+
await this.update([...request.changed.values()], [...request.deleted.values()], token);
|
|
543
|
+
}
|
|
544
|
+
finally {
|
|
545
|
+
if (this.scheduledUpdate === request) {
|
|
546
|
+
this.scheduledUpdate = undefined;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
/**
|
|
551
|
+
* Tell the {@link buildEndedListeners} once every phase has run, which is
|
|
552
|
+
* the one point where a build that skipped a waited-on document can be seen
|
|
553
|
+
* to have ended. Langium's `onBuildPhase` for `Validated` is not: it stays
|
|
554
|
+
* silent when no document reached that phase, which is every build that
|
|
555
|
+
* validates nothing, the workspace's initial one among them.
|
|
556
|
+
*
|
|
557
|
+
* A build that throws, whether cancelled or failed, tells none of them
|
|
558
|
+
* here: `currentState` is then below `Validated`, so {@link isOrphaned}
|
|
559
|
+
* could hold for no wait. {@link checkWaitsOnceDrained} tells them instead.
|
|
560
|
+
*/
|
|
561
|
+
async buildDocuments(documents, options, cancelToken) {
|
|
562
|
+
await super.buildDocuments(documents, options, cancelToken);
|
|
563
|
+
for (const listener of [...this.buildEndedListeners]) {
|
|
564
|
+
listener(false);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
/**
|
|
568
|
+
* After a build that threw, tell the {@link buildEndedListeners}, with
|
|
569
|
+
* `drained` set, from a {@link WorkspaceLock} read: it runs once no write
|
|
570
|
+
* runs or is queued, so no locked build is left that could still carry a
|
|
571
|
+
* waited-on document. A cancelled build is usually followed by its
|
|
572
|
+
* canceller's, but a write that builds nothing, such as a last-close revert
|
|
573
|
+
* that finds its document reopened, leaves a wait armed during the build
|
|
574
|
+
* with nothing to resolve it, and so does a build that fails. One read
|
|
575
|
+
* serves every build that throws before it runs.
|
|
576
|
+
*/
|
|
577
|
+
checkWaitsOnceDrained() {
|
|
578
|
+
if (this.drainCheckQueued) {
|
|
579
|
+
return;
|
|
580
|
+
}
|
|
581
|
+
this.drainCheckQueued = true;
|
|
582
|
+
void this.workspaceLock.read(() => {
|
|
583
|
+
this.drainCheckQueued = false;
|
|
584
|
+
for (const listener of [...this.buildEndedListeners]) {
|
|
585
|
+
listener(true);
|
|
260
586
|
}
|
|
261
587
|
});
|
|
262
588
|
}
|
|
@@ -331,7 +657,22 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
331
657
|
this.ensureLanguageFileExtensions();
|
|
332
658
|
const changedURIs = changed.flatMap(uri => this.flattenAndAdaptURI(uri));
|
|
333
659
|
const deletedURIs = deleted.flatMap(uri => this.collectDeletedURIs(uri));
|
|
334
|
-
return
|
|
660
|
+
return this.runInSession({
|
|
661
|
+
kind: 'update',
|
|
662
|
+
trigger: this.buildTriggerLabel(changedURIs, deletedURIs),
|
|
663
|
+
triggerCountsDocs: changedURIs.length + deletedURIs.length !== 1,
|
|
664
|
+
changed: changedURIs,
|
|
665
|
+
deleted: deletedURIs
|
|
666
|
+
}, this.rebuildLabel(changedURIs, deletedURIs), () => super.update(changedURIs, deletedURIs, cancelToken));
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* The workspace-initialization entry point, bracketed by a session like
|
|
670
|
+
* {@link update}. Langium's `update` reaches `buildDocuments` directly rather
|
|
671
|
+
* than through here, so the two never nest.
|
|
672
|
+
*/
|
|
673
|
+
build(documents, options, cancelToken) {
|
|
674
|
+
const uris = documents.map(document => document.uri);
|
|
675
|
+
return this.runInSession({ kind: 'build', trigger: `${documents.length} docs`, triggerCountsDocs: true, changed: uris, deleted: [] }, `Build documents (${documents.length} docs)`, () => super.build(documents, options, cancelToken));
|
|
335
676
|
}
|
|
336
677
|
/**
|
|
337
678
|
* Refresh cross-document `ComputedScopes` derivations on cascade, when
|
|
@@ -528,6 +869,140 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
528
869
|
];
|
|
529
870
|
}
|
|
530
871
|
// ============================================================
|
|
872
|
+
// Build sessions — one rebuild as a correlated unit
|
|
873
|
+
// ============================================================
|
|
874
|
+
/**
|
|
875
|
+
* Open a session, run `body` inside it, and close it — the bracket every
|
|
876
|
+
* line of a rebuild is emitted within.
|
|
877
|
+
*
|
|
878
|
+
* The session is installed **synchronously**, before the timed body runs, so
|
|
879
|
+
* that state a subclass computed in {@link createBuildSession} is already
|
|
880
|
+
* readable by the time Langium's `update` consults `shouldRelink`.
|
|
881
|
+
*
|
|
882
|
+
* Teardown is preemption-correct, which is the reason this is framework code
|
|
883
|
+
* rather than a recipe. A build outside the workspace lock overlaps another:
|
|
884
|
+
* the later one installs itself as {@link activeSession} while the earlier
|
|
885
|
+
* one is still running, and the earlier one's `finally` runs LAST. Clearing
|
|
886
|
+
* unconditionally there would discard the later build's state mid-build.
|
|
887
|
+
* Only the session that is still current clears — and the check is
|
|
888
|
+
* reference equality on the session object,
|
|
889
|
+
* not on {@link BuildSession.traceId}, which is `undefined` for every build
|
|
890
|
+
* whenever the timing level is suppressed and would compare equal to itself
|
|
891
|
+
* across two different builds.
|
|
892
|
+
*
|
|
893
|
+
* Builds outside the lock are not hypothetical even without an adopter: the
|
|
894
|
+
* model service with `serializeBuilds` off starts one. Two locked builds
|
|
895
|
+
* never overlap, since the lock starts a write only once the write it
|
|
896
|
+
* cancelled has unwound.
|
|
897
|
+
*/
|
|
898
|
+
runInSession(context, label, body) {
|
|
899
|
+
// Read before installing the new session: the id being superseded belongs
|
|
900
|
+
// to the OUTGOING build, or — when the previous one already finished
|
|
901
|
+
// cancelled — to the id it parked for its successor.
|
|
902
|
+
const supersededId = this.activeSession?.traceId ?? this.lastCancelledTraceId;
|
|
903
|
+
this.lastCancelledTraceId = undefined;
|
|
904
|
+
const reason = this.pendingUpdateReason;
|
|
905
|
+
this.pendingUpdateReason = undefined;
|
|
906
|
+
const tags = [];
|
|
907
|
+
if (reason) {
|
|
908
|
+
tags.push(`event: ${reason}`);
|
|
909
|
+
}
|
|
910
|
+
if (supersededId !== undefined) {
|
|
911
|
+
tags.push(`cancels #${supersededId}`);
|
|
912
|
+
}
|
|
913
|
+
const session = this.createBuildSession(context);
|
|
914
|
+
this.activeSession = session;
|
|
915
|
+
// A phase's "since previous phase" must measure from the build's start,
|
|
916
|
+
// not from whenever the last build's final phase happened to land.
|
|
917
|
+
this.lastPhaseMs = session.startMs;
|
|
918
|
+
return this.tracer.time(label, async () => {
|
|
919
|
+
try {
|
|
920
|
+
await body();
|
|
921
|
+
}
|
|
922
|
+
catch (err) {
|
|
923
|
+
if (isOperationCancelled(err)) {
|
|
924
|
+
session.cancelled = true;
|
|
925
|
+
}
|
|
926
|
+
this.checkWaitsOnceDrained();
|
|
927
|
+
throw err;
|
|
928
|
+
}
|
|
929
|
+
finally {
|
|
930
|
+
this.endSession(session);
|
|
931
|
+
}
|
|
932
|
+
}, this.logLevel, {
|
|
933
|
+
logAfterMs: 0,
|
|
934
|
+
forceMemoryAboveMs: session.buffers ? session.detailThresholdMs : undefined,
|
|
935
|
+
captureId: id => {
|
|
936
|
+
session.traceId = id;
|
|
937
|
+
},
|
|
938
|
+
tags
|
|
939
|
+
});
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Construct the session for one build. Override to return a
|
|
943
|
+
* {@link BuildSession} subclass carrying adopter build-scoped state — it is
|
|
944
|
+
* called before the build body, so anything derived here is readable
|
|
945
|
+
* throughout it.
|
|
946
|
+
*/
|
|
947
|
+
createBuildSession(context) {
|
|
948
|
+
return new BuildSession(performance.now(), context.trigger, context.triggerCountsDocs, this.phaseDetailMs.value);
|
|
949
|
+
}
|
|
950
|
+
/**
|
|
951
|
+
* Close `session`: flush what it buffered, then release it if it is still the
|
|
952
|
+
* current one (see {@link runInSession} on why that check is conditional).
|
|
953
|
+
* The flush is unconditional — a preempted build's lines still describe work
|
|
954
|
+
* that happened.
|
|
955
|
+
*/
|
|
956
|
+
endSession(session) {
|
|
957
|
+
this.flushSession(session);
|
|
958
|
+
if (this.activeSession === session) {
|
|
959
|
+
this.activeSession = undefined;
|
|
960
|
+
if (session.cancelled) {
|
|
961
|
+
this.lastCancelledTraceId = session.traceId;
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
}
|
|
965
|
+
/**
|
|
966
|
+
* Emit the lines `session` held back, if it ran long enough to be worth the
|
|
967
|
+
* detail; drop them otherwise. Emits through {@link emit} rather than
|
|
968
|
+
* {@link log}, which would route them straight back into the buffer.
|
|
969
|
+
*/
|
|
970
|
+
flushSession(session) {
|
|
971
|
+
const elapsedMs = performance.now() - session.startMs;
|
|
972
|
+
if (elapsedMs >= session.detailThresholdMs) {
|
|
973
|
+
for (const line of session.bufferedLines) {
|
|
974
|
+
this.emit(line);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
session.bufferedLines.length = 0;
|
|
978
|
+
}
|
|
979
|
+
/** Label for the build's own log line. Override to customise wording. */
|
|
980
|
+
rebuildLabel(changed, deleted) {
|
|
981
|
+
if (changed.length === 0 && deleted.length === 0) {
|
|
982
|
+
return 'Rebuild documents (nothing to do)';
|
|
983
|
+
}
|
|
984
|
+
if (changed.length === 1 && deleted.length === 0) {
|
|
985
|
+
return `Rebuild document: ${this.formatUri(changed[0])}`;
|
|
986
|
+
}
|
|
987
|
+
if (changed.length === 0 && deleted.length === 1) {
|
|
988
|
+
return `Rebuild after delete: ${this.formatUri(deleted[0])}`;
|
|
989
|
+
}
|
|
990
|
+
return `Rebuild documents (${changed.length} changed, ${deleted.length} deleted)`;
|
|
991
|
+
}
|
|
992
|
+
/** Short description of what triggered the build, repeated on every phase line. Override to customise wording. */
|
|
993
|
+
buildTriggerLabel(changed, deleted) {
|
|
994
|
+
if (changed.length === 0 && deleted.length === 0) {
|
|
995
|
+
return 'nothing';
|
|
996
|
+
}
|
|
997
|
+
if (changed.length === 1 && deleted.length === 0) {
|
|
998
|
+
return this.formatUri(changed[0]);
|
|
999
|
+
}
|
|
1000
|
+
if (changed.length === 0 && deleted.length === 1) {
|
|
1001
|
+
return `deleted ${this.formatUri(deleted[0])}`;
|
|
1002
|
+
}
|
|
1003
|
+
return `${changed.length} changed, ${deleted.length} deleted`;
|
|
1004
|
+
}
|
|
1005
|
+
// ============================================================
|
|
531
1006
|
// Logging — phase-reached listeners
|
|
532
1007
|
// ============================================================
|
|
533
1008
|
registerPhaseListeners() {
|
|
@@ -540,15 +1015,37 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
540
1015
|
const now = performance.now();
|
|
541
1016
|
const elapsedMs = Math.round(now - this.lastPhaseMs);
|
|
542
1017
|
this.lastPhaseMs = now;
|
|
1018
|
+
// Counted before the line is formatted, so the formatter stays a pure
|
|
1019
|
+
// function of state a caller can also set up in a test.
|
|
1020
|
+
if (this.activeSession) {
|
|
1021
|
+
this.activeSession.phasesLogged++;
|
|
1022
|
+
}
|
|
543
1023
|
this.log(this.phaseReachedLine(state, documents, elapsedMs));
|
|
544
1024
|
}
|
|
545
|
-
/**
|
|
1025
|
+
/**
|
|
1026
|
+
* Format the phase-reached log line. Override to customise wording.
|
|
1027
|
+
*
|
|
1028
|
+
* Within a session the line names what triggered the build, so a phase read
|
|
1029
|
+
* in isolation still says which rebuild it belongs to. `elapsedMs` is ignored
|
|
1030
|
+
* for the FIRST phase of a session: it measures from the previous build's
|
|
1031
|
+
* last phase, an idle gap that says nothing about this build.
|
|
1032
|
+
*/
|
|
546
1033
|
phaseReachedLine(state, documents, elapsedMs) {
|
|
547
|
-
const
|
|
548
|
-
|
|
1034
|
+
const session = this.activeSession;
|
|
1035
|
+
let docInfo;
|
|
1036
|
+
if (session) {
|
|
1037
|
+
docInfo = session.triggerCountsDocs ? `building ${session.trigger}` : `building ${session.trigger}, ${documents.length} docs`;
|
|
1038
|
+
}
|
|
1039
|
+
else {
|
|
1040
|
+
docInfo = documents.length === 1 ? this.formatUri(documents[0].uri) : `${documents.length} docs`;
|
|
1041
|
+
}
|
|
1042
|
+
const elapsedInfo = session && session.phasesLogged <= 1
|
|
1043
|
+
? `${Math.round(performance.now() - session.startMs)}ms since build start`
|
|
1044
|
+
: `${elapsedMs}ms since previous phase`;
|
|
1045
|
+
return `Reached phase '${DocumentState[state]}' [${docInfo}, ${elapsedInfo}]`;
|
|
549
1046
|
}
|
|
550
1047
|
// ============================================================
|
|
551
|
-
//
|
|
1048
|
+
// notifyDocumentPhase — the delivery hook and the slow-listener breakdown
|
|
552
1049
|
// ============================================================
|
|
553
1050
|
async notifyDocumentPhase(document, state, cancelToken) {
|
|
554
1051
|
// Before the listeners, one of which is Langium's diagnostics publisher.
|
|
@@ -558,16 +1055,15 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
558
1055
|
// build settling inside that window therefore appends after this call has
|
|
559
1056
|
// already deduped, and the appended duplicate is published by the listener
|
|
560
1057
|
// of the build that deduped. Only `serializeBuilds` closes the window.
|
|
1058
|
+
//
|
|
1059
|
+
// Dedupe before rendering: rendering is deterministic, so it cannot
|
|
1060
|
+
// change which entries are structurally equal, and fewer survive to render.
|
|
561
1061
|
if (state === DocumentState.Validated) {
|
|
562
1062
|
this.dedupeDiagnostics(document);
|
|
563
|
-
|
|
564
|
-
if (this.logLevel === 'off') {
|
|
565
|
-
return super.notifyDocumentPhase(document, state, cancelToken);
|
|
1063
|
+
this.renderDiagnostics(document);
|
|
566
1064
|
}
|
|
567
1065
|
const listeners = this.documentPhaseListeners.get(state).slice();
|
|
568
|
-
|
|
569
|
-
return;
|
|
570
|
-
}
|
|
1066
|
+
const version = document.textDocument.version;
|
|
571
1067
|
const perListenerMs = [];
|
|
572
1068
|
let cancelledListeners = 0;
|
|
573
1069
|
const { elapsedMs: totalMs } = await this.clock.measure(async () => {
|
|
@@ -587,6 +1083,14 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
587
1083
|
perListenerMs.push(elapsedMs);
|
|
588
1084
|
}
|
|
589
1085
|
});
|
|
1086
|
+
if (cancelledListeners === 0) {
|
|
1087
|
+
for (const delivered of this.documentPhaseDeliveredListeners.get(state).slice()) {
|
|
1088
|
+
delivered(document, version);
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
if (this.logLevel === 'off' || listeners.length === 0) {
|
|
1092
|
+
return;
|
|
1093
|
+
}
|
|
590
1094
|
if (cancelledListeners > 0) {
|
|
591
1095
|
this.tracer
|
|
592
1096
|
.withUri(document.uri.toString())
|
|
@@ -718,11 +1222,83 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
718
1222
|
document.diagnostics = unique;
|
|
719
1223
|
}
|
|
720
1224
|
}
|
|
1225
|
+
/**
|
|
1226
|
+
* Render every diagnostic on `document` through the bound message renderer,
|
|
1227
|
+
* in ONE pass over the finished list.
|
|
1228
|
+
*
|
|
1229
|
+
* All three heads read `document.diagnostics` — the LSP publish,
|
|
1230
|
+
* `TransferEncoder.toTransferDiagnostic` and the GLSP validation path — so
|
|
1231
|
+
* one pass here is what keeps the render from happening per head. It is also
|
|
1232
|
+
* the only placement that covers lexer and parser errors, which Langium
|
|
1233
|
+
* pushes onto the document without routing them through `toDiagnostic`.
|
|
1234
|
+
*
|
|
1235
|
+
* Running here rather than from a `Validated` phase listener needs no
|
|
1236
|
+
* ordering assumption: Langium publishes from `addDiagnosticsHandler`, a free
|
|
1237
|
+
* function it registers as such a listener, which can only be outrun.
|
|
1238
|
+
*
|
|
1239
|
+
* **It inherits {@link dedupeDiagnostics}'s window, and therefore the same
|
|
1240
|
+
* precondition.** A build settling inside the listener window appends
|
|
1241
|
+
* diagnostics this pass never saw, and the publisher of the build that
|
|
1242
|
+
* rendered sends them — unrendered. `ModelServiceOptions.serializeBuilds`
|
|
1243
|
+
* closes it and defaults to `true`, so "every diagnostic is rendered" holds
|
|
1244
|
+
* by default and is an opt-out rather than a guarantee. Opting out accepts
|
|
1245
|
+
* unrendered diagnostics on exactly the terms it already accepts duplicates.
|
|
1246
|
+
*
|
|
1247
|
+
* Entries are REPLACED rather than mutated: `sendDiagnostics` passes the
|
|
1248
|
+
* array by reference and serialises later, so an in-place message mutation
|
|
1249
|
+
* reaches the wire even when it runs after the publisher — which would make
|
|
1250
|
+
* a test for the ordering pass in either state.
|
|
1251
|
+
*/
|
|
1252
|
+
renderDiagnostics(document) {
|
|
1253
|
+
const diagnostics = document.diagnostics;
|
|
1254
|
+
if (!diagnostics || diagnostics.length === 0) {
|
|
1255
|
+
return;
|
|
1256
|
+
}
|
|
1257
|
+
let changed = false;
|
|
1258
|
+
// No try/catch: `renderDiagnostic` carries a no-throw contract, because an
|
|
1259
|
+
// error escaping this phase strands the document at `Validated` with
|
|
1260
|
+
// Langium's publisher never invoked.
|
|
1261
|
+
const rendered = diagnostics.map(diagnostic => {
|
|
1262
|
+
const text = this.messageRenderer.renderDiagnostic(diagnostic);
|
|
1263
|
+
// Against the message's STRING FORM, not the field. `renderDiagnostic`
|
|
1264
|
+
// answers a `string` by contract, while `Diagnostic.message` is
|
|
1265
|
+
// `string | MarkupContent` since LSP 3.17 — so comparing the answer
|
|
1266
|
+
// against the field never matches for a markup message, and a pass
|
|
1267
|
+
// that replaced on mismatch flattened every un-identified markup
|
|
1268
|
+
// diagnostic to its own plain text. That is silent data loss on the
|
|
1269
|
+
// path whose whole job is to leave such entries alone.
|
|
1270
|
+
if (text === Diagnostic.getMessageString(diagnostic)) {
|
|
1271
|
+
return diagnostic;
|
|
1272
|
+
}
|
|
1273
|
+
changed = true;
|
|
1274
|
+
return { ...diagnostic, message: text };
|
|
1275
|
+
});
|
|
1276
|
+
if (changed) {
|
|
1277
|
+
document.diagnostics = rendered;
|
|
1278
|
+
}
|
|
1279
|
+
}
|
|
721
1280
|
// ============================================================
|
|
722
1281
|
// Internal helpers
|
|
723
1282
|
// ============================================================
|
|
724
|
-
/**
|
|
1283
|
+
/**
|
|
1284
|
+
* Dispatch a log line at the configured log level; a no-op when `logLevel ===
|
|
1285
|
+
* 'off'`.
|
|
1286
|
+
*
|
|
1287
|
+
* Held on the active session when it buffers, so the "was this build worth a
|
|
1288
|
+
* per-phase breakdown" decision — which needs the build's total duration, and
|
|
1289
|
+
* so cannot be taken by anything that runs while the lines are produced — is
|
|
1290
|
+
* deferred to {@link flushSession}.
|
|
1291
|
+
*/
|
|
725
1292
|
log(message) {
|
|
1293
|
+
const session = this.activeSession;
|
|
1294
|
+
if (session?.buffers) {
|
|
1295
|
+
session.bufferedLines.push(message);
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1298
|
+
this.emit(message);
|
|
1299
|
+
}
|
|
1300
|
+
/** Write a line out, bypassing session buffering. The single sink every framework log line reaches. */
|
|
1301
|
+
emit(message) {
|
|
726
1302
|
this.tracer.logAt(this.logLevel, message);
|
|
727
1303
|
}
|
|
728
1304
|
}
|