@hydranium/core 1.0.0-next.19 → 1.0.0-next.192
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 +6 -2
- package/lib/documents/ast-document-manager.d.ts +204 -62
- package/lib/documents/ast-document-manager.d.ts.map +1 -1
- package/lib/documents/ast-document-manager.js +249 -83
- 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 +523 -101
- package/lib/documents/hydranium-text-documents.d.ts.map +1 -1
- package/lib/documents/hydranium-text-documents.js +961 -177
- package/lib/documents/hydranium-text-documents.js.map +1 -1
- package/lib/documents/index.d.ts +5 -0
- package/lib/documents/index.d.ts.map +1 -1
- package/lib/documents/index.js +5 -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/model-ledger.d.ts +47 -0
- package/lib/documents/model-ledger.d.ts.map +1 -0
- package/lib/documents/model-ledger.js +30 -0
- package/lib/documents/model-ledger.js.map +1 -0
- 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/documents/version-sync-service.d.ts +134 -0
- package/lib/documents/version-sync-service.d.ts.map +1 -0
- package/lib/documents/version-sync-service.js +171 -0
- package/lib/documents/version-sync-service.js.map +1 -0
- 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-extension-service.d.ts.map +1 -1
- package/lib/langium/ast-extension/ast-extension-service.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 +32 -9
- package/lib/langium/bootstrap.js.map +1 -1
- package/lib/langium/build-phase-pass/build-phase-pass-service.d.ts.map +1 -1
- package/lib/langium/build-phase-pass/build-phase-pass-service.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/config/settings.js.map +1 -1
- package/lib/langium/diagnostics/hydranium-langium-profiler.d.ts.map +1 -1
- package/lib/langium/diagnostics/hydranium-langium-profiler.js.map +1 -1
- package/lib/langium/diagnostics/logger.d.ts +10 -3
- package/lib/langium/diagnostics/logger.d.ts.map +1 -1
- package/lib/langium/diagnostics/logger.js +12 -5
- package/lib/langium/diagnostics/logger.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 +56 -13
- package/lib/langium/diagnostics/lsp-logger.js.map +1 -1
- package/lib/langium/diagnostics/server-tracer.d.ts.map +1 -1
- package/lib/langium/diagnostics/server-tracer.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 +382 -29
- package/lib/langium/document-builder/document-builder.d.ts.map +1 -1
- package/lib/langium/document-builder/document-builder.js +659 -61
- 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/documentation/comment-provider.d.ts.map +1 -1
- package/lib/langium/documentation/comment-provider.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 +58 -13
- package/lib/langium/integrity/integrity-service.d.ts.map +1 -1
- package/lib/langium/integrity/integrity-service.js +204 -29
- 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/keys/positional-key-provider.d.ts.map +1 -1
- package/lib/langium/keys/positional-key-provider.js.map +1 -1
- package/lib/langium/labeling/label-provider.d.ts.map +1 -1
- package/lib/langium/labeling/label-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 +311 -0
- package/lib/langium/model-service/client-session.d.ts.map +1 -0
- package/lib/langium/model-service/client-session.js +398 -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 +353 -253
- package/lib/langium/model-service/model-service.d.ts.map +1 -1
- package/lib/langium/model-service/model-service.js +361 -408
- package/lib/langium/model-service/model-service.js.map +1 -1
- package/lib/langium/module.d.ts +150 -35
- package/lib/langium/module.d.ts.map +1 -1
- package/lib/langium/module.js +50 -35
- 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/project/abstract-project-manager.d.ts.map +1 -1
- package/lib/langium/project/abstract-project-manager.js +9 -2
- package/lib/langium/project/abstract-project-manager.js.map +1 -1
- package/lib/langium/project/project-change-event.d.ts +2 -2
- package/lib/langium/project/single-project-manager.d.ts.map +1 -1
- package/lib/langium/project/single-project-manager.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 +23 -57
- package/lib/langium/residency/cst-residency-service.js.map +1 -1
- package/lib/langium/scope/ast-node-description-provider.d.ts.map +1 -1
- package/lib/langium/scope/ast-node-description-provider.js.map +1 -1
- package/lib/langium/scope/hydranium-scope-computation.d.ts.map +1 -1
- package/lib/langium/scope/hydranium-scope-computation.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/scope/reference-builder.d.ts.map +1 -1
- package/lib/langium/scope/reference-builder.js.map +1 -1
- package/lib/langium/scope/reference-candidate-provider.d.ts.map +1 -1
- package/lib/langium/scope/reference-candidate-provider.js.map +1 -1
- package/lib/langium/scope/scope-extension-service.d.ts.map +1 -1
- package/lib/langium/scope/scope-extension-service.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/serialization/json-serializer.d.ts +1 -1
- package/lib/langium/serialization/json-serializer.d.ts.map +1 -1
- package/lib/langium/serialization/json-serializer.js.map +1 -1
- package/lib/langium/serialization/yaml-serializer.d.ts.map +1 -1
- package/lib/langium/serialization/yaml-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 +21 -4
- 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 +75 -23
- package/lib/langium/transfer/transfer-encoder.d.ts.map +1 -1
- package/lib/langium/transfer/transfer-encoder.js +44 -21
- 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/normalize-empty-strings.d.ts.map +1 -1
- package/lib/langium/update-rewrite/update-rewrite-service.d.ts.map +1 -1
- package/lib/langium/update-rewrite/update-rewrite-service.js.map +1 -1
- 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/validation/validation-contribution-collector.d.ts.map +1 -1
- package/lib/langium/validation/validation-contribution-collector.js.map +1 -1
- package/lib/langium/workspace/document-uri-policy.d.ts +17 -12
- package/lib/langium/workspace/document-uri-policy.d.ts.map +1 -1
- package/lib/langium/workspace/document-uri-policy.js +10 -9
- package/lib/langium/workspace/document-uri-policy.js.map +1 -1
- package/lib/langium/workspace/file-not-found.d.ts +17 -0
- package/lib/langium/workspace/file-not-found.d.ts.map +1 -0
- package/lib/langium/workspace/file-not-found.js +20 -0
- package/lib/langium/workspace/file-not-found.js.map +1 -0
- package/lib/langium/workspace/file-system-provider.d.ts +84 -8
- package/lib/langium/workspace/file-system-provider.d.ts.map +1 -1
- package/lib/langium/workspace/file-system-provider.js +93 -14
- package/lib/langium/workspace/file-system-provider.js.map +1 -1
- package/lib/langium/workspace/hydranium-langium-document-factory.d.ts +56 -1
- package/lib/langium/workspace/hydranium-langium-document-factory.d.ts.map +1 -1
- package/lib/langium/workspace/hydranium-langium-document-factory.js +79 -0
- package/lib/langium/workspace/hydranium-langium-document-factory.js.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-lock.d.ts +43 -1
- package/lib/langium/workspace/hydranium-workspace-lock.d.ts.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-lock.js +58 -1
- package/lib/langium/workspace/hydranium-workspace-lock.js.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-manager.d.ts +81 -8
- package/lib/langium/workspace/hydranium-workspace-manager.d.ts.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-manager.js +128 -10
- package/lib/langium/workspace/hydranium-workspace-manager.js.map +1 -1
- package/lib/langium/workspace/in-memory-file-system-provider.d.ts +25 -2
- package/lib/langium/workspace/in-memory-file-system-provider.d.ts.map +1 -1
- package/lib/langium/workspace/in-memory-file-system-provider.js +41 -15
- package/lib/langium/workspace/in-memory-file-system-provider.js.map +1 -1
- package/lib/langium/workspace/index-manager.d.ts.map +1 -1
- package/lib/langium/workspace/index-manager.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 +86 -17
- package/lib/langium/workspace/langium-documents.d.ts.map +1 -1
- package/lib/langium/workspace/langium-documents.js +101 -29
- package/lib/langium/workspace/langium-documents.js.map +1 -1
- package/lib/langium/workspace/persistent-file-system-provider.d.ts +0 -7
- package/lib/langium/workspace/persistent-file-system-provider.d.ts.map +1 -1
- package/lib/langium/workspace/persistent-file-system-provider.js +0 -7
- package/lib/langium/workspace/persistent-file-system-provider.js.map +1 -1
- package/lib/langium/workspace/virtual-document.d.ts +48 -15
- package/lib/langium/workspace/virtual-document.d.ts.map +1 -1
- package/lib/langium/workspace/virtual-document.js +78 -18
- package/lib/langium/workspace/virtual-document.js.map +1 -1
- package/lib/langium/workspace/write-lock-scope.d.ts +20 -10
- package/lib/langium/workspace/write-lock-scope.d.ts.map +1 -1
- package/lib/langium/workspace/write-lock-scope.js +12 -4
- 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 +153 -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/event-loop-monitor.js.map +1 -1
- 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/lint-grammar.js.map +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/memory-monitor.js.map +1 -1
- package/lib/node/node-file-system-provider.d.ts +39 -4
- package/lib/node/node-file-system-provider.d.ts.map +1 -1
- package/lib/node/node-file-system-provider.js +109 -49
- package/lib/node/node-file-system-provider.js.map +1 -1
- package/lib/node/process-memory.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/profile-digest.js.map +1 -1
- package/lib/node/profiling-run.d.ts +13 -3
- package/lib/node/profiling-run.d.ts.map +1 -1
- package/lib/node/profiling-run.js +17 -8
- 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/document-uri-policy-conformance.js.map +1 -1
- package/lib/testing/fake-description.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/index.d.ts +1 -1
- package/lib/testing/index.d.ts.map +1 -1
- package/lib/testing/index.js +2 -1
- package/lib/testing/index.js.map +1 -1
- package/lib/testing/langium-test-helpers.d.ts.map +1 -1
- package/lib/testing/langium-test-helpers.js +1 -0
- package/lib/testing/langium-test-helpers.js.map +1 -1
- package/lib/testing/make-noop-language-services.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 +69 -14
- package/lib/testing/make-test-services.d.ts.map +1 -1
- package/lib/testing/make-test-services.js +39 -10
- package/lib/testing/make-test-services.js.map +1 -1
- package/lib/testing/make-test-tracer.js.map +1 -1
- package/lib/testing/node/golden-corpus.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/browser-capture-bridge.js.map +1 -1
- package/lib/testing/playwright/e2e-profiling.js.map +1 -1
- 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 +24 -8
- package/lib/testing/playwright/server-log-capture.d.ts.map +1 -1
- package/lib/testing/playwright/server-log-capture.js +27 -6
- 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 +11 -9
- package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
- package/lib/testing/stub-ast-document-manager.js +23 -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 +97 -15
- package/lib/testing/stub-hydranium-text-documents.js.map +1 -1
- package/lib/testing/stub-index-manager.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/testing/stub-project-manager.js.map +1 -1
- package/lib/testing/stub-service-registry.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/lib/util/environment.d.ts.map +1 -1
- package/lib/util/environment.js.map +1 -1
- package/lib/util/registry.d.ts.map +1 -1
- package/package.json +35 -26
- package/src/documents/ast-document-manager.ts +377 -125
- 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 +1175 -225
- package/src/documents/index.ts +5 -0
- package/src/documents/language-client-text-shadow.ts +59 -11
- package/src/documents/model-ledger.ts +66 -0
- package/src/documents/self-save-registry.ts +52 -13
- package/src/documents/version-sync-service.ts +267 -0
- package/src/index.ts +6 -0
- package/src/langium/ast-extension/ast-node-builder.ts +66 -22
- package/src/langium/bootstrap.ts +32 -9
- package/src/langium/config/configuration-provider.ts +119 -0
- package/src/langium/config/index.ts +1 -0
- package/src/langium/diagnostics/logger.ts +12 -5
- package/src/langium/diagnostics/lsp-logger.ts +58 -12
- 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 +776 -59
- 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 +220 -30
- 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 +614 -0
- package/src/langium/model-service/index.ts +1 -0
- package/src/langium/model-service/model-service.ts +570 -433
- package/src/langium/module.ts +201 -64
- package/src/langium/naming/name-provider.ts +27 -5
- package/src/langium/naming/name-separator-validation.ts +34 -5
- package/src/langium/project/abstract-project-manager.ts +9 -1
- package/src/langium/project/project-change-event.ts +2 -2
- package/src/langium/residency/cst-residency-service.ts +46 -15
- 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 +25 -4
- package/src/langium/transfer/transfer-encoder.ts +102 -34
- 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 +17 -12
- package/src/langium/workspace/file-not-found.ts +23 -0
- package/src/langium/workspace/file-system-provider.ts +153 -16
- package/src/langium/workspace/hydranium-langium-document-factory.ts +117 -0
- package/src/langium/workspace/hydranium-workspace-lock.ts +86 -2
- package/src/langium/workspace/hydranium-workspace-manager.ts +153 -13
- package/src/langium/workspace/in-memory-file-system-provider.ts +47 -16
- package/src/langium/workspace/initialize-workspace.ts +43 -5
- package/src/langium/workspace/langium-documents.ts +124 -33
- package/src/langium/workspace/persistent-file-system-provider.ts +0 -7
- package/src/langium/workspace/virtual-document.ts +96 -19
- package/src/langium/workspace/write-lock-scope.ts +24 -11
- 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 +185 -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 +122 -51
- package/src/node/profile-capture.ts +8 -2
- package/src/node/profiling-run.ts +30 -8
- 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/index.ts +2 -1
- package/src/testing/langium-test-helpers.ts +1 -0
- package/src/testing/make-noop-shared-services.ts +50 -2
- package/src/testing/make-test-services.ts +120 -31
- 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 +45 -11
- 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 +37 -22
- package/src/testing/stub-document-builder.ts +83 -17
- package/src/testing/stub-hydranium-text-documents.ts +133 -23
- 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/src/util/environment.ts +9 -1
- 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
|
@@ -9,23 +9,33 @@
|
|
|
9
9
|
|
|
10
10
|
import { type Clock, type LogThreshold, type MaybeObservableValue, ObservableValue, type Tracer } from '@hydranium/protocol';
|
|
11
11
|
import {
|
|
12
|
+
type AstNode,
|
|
12
13
|
type BuildOptions,
|
|
13
14
|
DefaultDocumentBuilder,
|
|
14
15
|
type DocumentPhaseListener,
|
|
15
16
|
DocumentState,
|
|
16
17
|
type LangiumDocument,
|
|
18
|
+
MultiMap,
|
|
17
19
|
OperationCancelled,
|
|
18
|
-
|
|
20
|
+
URI,
|
|
19
21
|
UriUtils,
|
|
22
|
+
type WorkspaceLock,
|
|
20
23
|
interruptAndCheck,
|
|
21
24
|
isOperationCancelled
|
|
22
25
|
} from '@hydranium/langium';
|
|
23
|
-
|
|
26
|
+
// `Diagnostic` as a VALUE: `renderDiagnostics` needs its `getMessageString`
|
|
27
|
+
// namespace helper to read the `string | MarkupContent` union without
|
|
28
|
+
// restating it.
|
|
29
|
+
import { CancellationToken, Diagnostic, Disposable } from 'vscode-languageserver-protocol';
|
|
30
|
+
import { type VersionSyncService } from '../../documents/version-sync-service.js';
|
|
24
31
|
import { type LogNameOptions } from '../diagnostics/logger.js';
|
|
32
|
+
import type { MessageRenderer } from '../../messages/renderer.js';
|
|
25
33
|
import { CST_REHYDRATION_RESET_STATE, isCstShed } from '../residency/cst-residency-service.js';
|
|
26
34
|
import { type ExtendedServiceRegistry } from '../service-registry.js';
|
|
27
35
|
import { type ServerSharedServicesMinimal } from '../shared-services.js';
|
|
28
36
|
import { type DocumentUriPolicy } from '../workspace/document-uri-policy.js';
|
|
37
|
+
import { HydraniumWorkspaceLock } from '../workspace/hydranium-workspace-lock.js';
|
|
38
|
+
import { BuildSession, type BuildSessionContext } from './build-session.js';
|
|
29
39
|
import { type LabeledPhaseListener, labelPhaseListener } from './labeled-phase-listener.js';
|
|
30
40
|
|
|
31
41
|
/** Document states a phase-reached line is emitted for by default — every built phase. */
|
|
@@ -38,6 +48,20 @@ export const DEFAULT_LOGGED_PHASES: DocumentState[] = [
|
|
|
38
48
|
DocumentState.Validated
|
|
39
49
|
];
|
|
40
50
|
|
|
51
|
+
/**
|
|
52
|
+
* The build reasons the framework stages through
|
|
53
|
+
* {@link HydraniumDocumentBuilder.markNextReason}: the LSP events the update
|
|
54
|
+
* handler dispatches on, and `didClose` for the revert the text store runs
|
|
55
|
+
* after a last close. Exposed so a subclass layering reasons of its own keeps
|
|
56
|
+
* the names the framework emits.
|
|
57
|
+
*/
|
|
58
|
+
export const HYDRANIUM_BUILD_REASONS = Object.freeze({
|
|
59
|
+
didOpen: 'didOpen',
|
|
60
|
+
didChangeContent: 'didChangeContent',
|
|
61
|
+
didChangeWatchedFiles: 'didChangeWatchedFiles',
|
|
62
|
+
didClose: 'didClose'
|
|
63
|
+
} as const);
|
|
64
|
+
|
|
41
65
|
/**
|
|
42
66
|
* Consecutive re-queued builds that leave a waited-on document at the same state
|
|
43
67
|
* before {@link HydraniumDocumentBuilder.awaitDocumentState} stops re-queuing it.
|
|
@@ -78,6 +102,18 @@ export interface DocumentBuilderOptions extends LogNameOptions {
|
|
|
78
102
|
* logged. Default: `25`. Read per phase; accepts a {@link MaybeObservableValue}.
|
|
79
103
|
*/
|
|
80
104
|
readonly slowBuildMs?: MaybeObservableValue<number>;
|
|
105
|
+
/**
|
|
106
|
+
* Build duration at or above which a build's phase-reached and slow-listener
|
|
107
|
+
* lines are emitted; they are held for the duration of the build and dropped
|
|
108
|
+
* when it finishes faster. Default `0` — no buffering, every line emitted as
|
|
109
|
+
* it is produced, which is the only setting that keeps lines interleaved with
|
|
110
|
+
* the rest of the log in real time.
|
|
111
|
+
*
|
|
112
|
+
* Set it to make a fast rebuild log nothing but its one build line. The
|
|
113
|
+
* decision needs the build's TOTAL duration, so it cannot be made by any
|
|
114
|
+
* per-line hook. Read once per build; accepts a {@link MaybeObservableValue}.
|
|
115
|
+
*/
|
|
116
|
+
readonly phaseDetailMs?: MaybeObservableValue<number>;
|
|
81
117
|
/**
|
|
82
118
|
* Refresh cross-document `ComputedScopes` derivations when a referencing
|
|
83
119
|
* document is cascade-rebuilt (see
|
|
@@ -91,29 +127,72 @@ export interface DocumentBuilderOptions extends LogNameOptions {
|
|
|
91
127
|
readonly refreshCrossDocumentComputedScopes?: boolean;
|
|
92
128
|
}
|
|
93
129
|
|
|
130
|
+
/** Options for a {@link HydraniumDocumentBuilder.waitUntil} wait on one document. */
|
|
131
|
+
export interface WaitUntilOptions {
|
|
132
|
+
/**
|
|
133
|
+
* Reject once the builder gives up carrying the document to the target
|
|
134
|
+
* state. Without it, such a wait stays pending until its token is cancelled.
|
|
135
|
+
*/
|
|
136
|
+
readonly rejectWhenStuck?: boolean;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* One locked build {@link HydraniumDocumentBuilder.scheduleUpdate} queued,
|
|
141
|
+
* which later requests merge into while it waits and join while it runs.
|
|
142
|
+
*/
|
|
143
|
+
export interface ScheduledUpdate {
|
|
144
|
+
/** URIs to build, by URI string. Merged requests change it while the write is queued; fixed once it runs. */
|
|
145
|
+
readonly changed: Map<string, URI>;
|
|
146
|
+
/** URIs to delete, by URI string, under the same rule as {@link changed}. */
|
|
147
|
+
readonly deleted: Map<string, URI>;
|
|
148
|
+
/** The latest build reason any merged request gave; staged through {@link HydraniumDocumentBuilder.markNextReason} when the write runs. */
|
|
149
|
+
reason?: string;
|
|
150
|
+
/** The lock's {@link HydraniumWorkspaceLock.writeCancellations} right after this write was queued. */
|
|
151
|
+
readonly cancellations: number;
|
|
152
|
+
/**
|
|
153
|
+
* Set when the write starts to run, so its presence marks a running build:
|
|
154
|
+
* the text version of each changed URI the text store holds at that point.
|
|
155
|
+
*/
|
|
156
|
+
takenVersions?: Map<string, number>;
|
|
157
|
+
/** The lock's promise for this write: settles when the build completes or is cancelled. */
|
|
158
|
+
readonly promise: Promise<void>;
|
|
159
|
+
}
|
|
160
|
+
|
|
94
161
|
/**
|
|
95
162
|
* Extends Langium's {@link DefaultDocumentBuilder} with:
|
|
96
163
|
*
|
|
97
164
|
* - **Bug-fixes** (always on): an {@link awaitDocumentState} that waits where
|
|
98
|
-
* the default rejects,
|
|
165
|
+
* the default rejects (re-queuing, under the workspace lock, a document no
|
|
166
|
+
* build will carry), a {@link prepareBuild} that keeps a cancelled
|
|
99
167
|
* non-validating build from suppressing validation, and a
|
|
100
168
|
* {@link shouldRelink} that never judges a document unaffected on an index
|
|
101
169
|
* that does not describe it.
|
|
170
|
+
* - **Shared locked builds** ({@link scheduleUpdate}): build requests that
|
|
171
|
+
* coincide share one locked build instead of cancelling each other.
|
|
102
172
|
* - **URI handling** (always on): directory-aware flattening and cascade
|
|
103
173
|
* deletes in {@link update}, plus the CST-rehydration and cross-document
|
|
104
174
|
* refresh resets in {@link resetToState}.
|
|
105
175
|
* - **In-place rebuild helpers** — {@link reparse} and
|
|
106
176
|
* {@link reparseAndRelink} — for a build-phase listener that mutated a
|
|
107
177
|
* document's AST and must reconcile it within the same build.
|
|
108
|
-
* - **Diagnostic dedupe** at `Validated` ({@link dedupeDiagnostics})
|
|
178
|
+
* - **Diagnostic dedupe** at `Validated` ({@link dedupeDiagnostics}), followed
|
|
179
|
+
* by the **one server-side message render** every head inherits
|
|
180
|
+
* ({@link renderDiagnostics}).
|
|
181
|
+
* - **Build sessions** ({@link BuildSession}): each `update` / `build` call is
|
|
182
|
+
* one correlated unit carrying an id, a trigger label, a start time and
|
|
183
|
+
* cancellation lineage, so every line of a rebuild reads as belonging to it
|
|
184
|
+
* and a preempted build is distinguishable from the winner.
|
|
109
185
|
* - **Logging instrumentation** (default on, opt-out via `logLevel: 'off'`):
|
|
110
|
-
* phase-reached lines, slow-listener breakdowns on
|
|
111
|
-
* and slow-build-phase totals on `notifyBuildPhase`.
|
|
186
|
+
* a per-build line, phase-reached lines, slow-listener breakdowns on
|
|
187
|
+
* `notifyDocumentPhase`, and slow-build-phase totals on `notifyBuildPhase`.
|
|
112
188
|
*
|
|
113
189
|
* Adopters extend this class — the configuration knobs cover what most
|
|
114
190
|
* adopters need; the `format*Line` methods, `formatUri`, and
|
|
115
191
|
* `collectDeletedURIs` are protected so subclasses can customise wording or
|
|
116
|
-
* domain-aware cascades without re-implementing surrounding logic.
|
|
192
|
+
* domain-aware cascades without re-implementing surrounding logic. An adopter
|
|
193
|
+
* with build-scoped state of its own subclasses {@link BuildSession} and
|
|
194
|
+
* overrides {@link createBuildSession}, which puts that state under the same
|
|
195
|
+
* preemption-correct teardown rather than a reimplementation of it.
|
|
117
196
|
*/
|
|
118
197
|
export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
119
198
|
protected readonly tracer: Tracer;
|
|
@@ -127,8 +206,15 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
127
206
|
protected readonly slowListenerMs: ObservableValue<number>;
|
|
128
207
|
/** Live slow-build-phase-total threshold; read `.value` per phase. */
|
|
129
208
|
protected readonly slowBuildMs: ObservableValue<number>;
|
|
209
|
+
/** Live phase-detail buffering threshold; read `.value` once per build, onto the session. */
|
|
210
|
+
protected readonly phaseDetailMs: ObservableValue<number>;
|
|
130
211
|
protected readonly uriPolicy: DocumentUriPolicy;
|
|
131
212
|
protected readonly clock: Clock;
|
|
213
|
+
protected readonly messageRenderer: MessageRenderer;
|
|
214
|
+
/** The lock {@link scheduleUpdate} builds under. */
|
|
215
|
+
protected readonly workspaceLock: WorkspaceLock;
|
|
216
|
+
/** The latest write {@link scheduleUpdate} queued, until it ends; see {@link ScheduledUpdate}. */
|
|
217
|
+
protected scheduledUpdate?: ScheduledUpdate;
|
|
132
218
|
/** Narrower handle on the same registry as the inherited `serviceRegistry`, for {@link ExtendedServiceRegistry.registrations}. */
|
|
133
219
|
protected readonly languageRegistry: ExtendedServiceRegistry;
|
|
134
220
|
protected languageFileExtensions: string[] = [];
|
|
@@ -139,18 +225,46 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
139
225
|
protected readonly refreshCrossDocumentComputedScopes: boolean;
|
|
140
226
|
/** LSP event name (e.g. `'didChangeWatchedFiles'`) staged for the next `update()` call. */
|
|
141
227
|
protected pendingUpdateReason?: string;
|
|
228
|
+
/**
|
|
229
|
+
* The build currently in progress, or `undefined` between builds.
|
|
230
|
+
*
|
|
231
|
+
* A subclass carrying its own build-scoped state returns a {@link BuildSession}
|
|
232
|
+
* subclass from {@link createBuildSession} and narrows this with a typeguard
|
|
233
|
+
* where it reads that state — rather than redeclaring the field, whose
|
|
234
|
+
* initialiser would run after `super()` and clear a session opened during
|
|
235
|
+
* construction.
|
|
236
|
+
*/
|
|
237
|
+
protected activeSession?: BuildSession;
|
|
238
|
+
/**
|
|
239
|
+
* `traceId` of the last build that ended in cancellation, for the successor's
|
|
240
|
+
* "cancels #N" tag. Held here rather than on a session because the session
|
|
241
|
+
* that carries it is already gone by the time its successor is opened.
|
|
242
|
+
*/
|
|
243
|
+
protected lastCancelledTraceId?: number;
|
|
244
|
+
/** Registered through {@link onDocumentPhaseDelivered}, by phase. */
|
|
245
|
+
protected readonly documentPhaseDeliveredListeners = new MultiMap<DocumentState, (document: LangiumDocument, version: number) => void>();
|
|
246
|
+
/** Registered through {@link onBuildEnded}. */
|
|
247
|
+
protected readonly buildEndedListeners = new Set<(drained: boolean) => void>();
|
|
248
|
+
/** Set while the lock read {@link checkWaitsOnceDrained} queued has not run. */
|
|
249
|
+
protected drainCheckQueued = false;
|
|
250
|
+
/** Resolved per call: the sync service reaches this builder. */
|
|
251
|
+
protected readonly versionSyncService: () => VersionSyncService;
|
|
142
252
|
|
|
143
253
|
constructor(services: ServerSharedServicesMinimal, options: DocumentBuilderOptions = {}) {
|
|
144
254
|
super(services);
|
|
145
255
|
this.languageRegistry = services.ServiceRegistry;
|
|
146
256
|
this.uriPolicy = services.workspace.DocumentUriPolicy;
|
|
147
257
|
this.clock = services.Clock;
|
|
258
|
+
this.messageRenderer = services.MessageRenderer;
|
|
259
|
+
this.workspaceLock = services.workspace.WorkspaceLock;
|
|
260
|
+
this.versionSyncService = () => services.workspace.VersionSyncService;
|
|
148
261
|
this.tracer = services.Tracer.for(options.logName ?? 'DocumentBuilder').trace('instantiated');
|
|
149
262
|
this.logLevel = options.logLevel ?? 'debug';
|
|
150
263
|
this.loggedPhases = options.loggedPhases ?? DEFAULT_LOGGED_PHASES;
|
|
151
264
|
this.slowPhaseMs = ObservableValue.from(options.slowPhaseMs ?? 25);
|
|
152
265
|
this.slowListenerMs = ObservableValue.from(options.slowListenerMs ?? 5);
|
|
153
266
|
this.slowBuildMs = ObservableValue.from(options.slowBuildMs ?? 25);
|
|
267
|
+
this.phaseDetailMs = ObservableValue.from(options.phaseDetailMs ?? 0);
|
|
154
268
|
this.refreshCrossDocumentComputedScopes = options.refreshCrossDocumentComputedScopes ?? false;
|
|
155
269
|
if (this.logLevel !== 'off') {
|
|
156
270
|
this.registerPhaseListeners();
|
|
@@ -163,8 +277,8 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
163
277
|
|
|
164
278
|
/**
|
|
165
279
|
* Stage an LSP event name for the next `update()` call. Adopters call before
|
|
166
|
-
* the update fires; `HydraniumDocumentUpdateHandler` does it for the
|
|
167
|
-
*
|
|
280
|
+
* the update fires; `HydraniumDocumentUpdateHandler` does it for the LSP
|
|
281
|
+
* events, and the text store for the revert that follows a last close.
|
|
168
282
|
*
|
|
169
283
|
* The framework stages the value and never reads it back. The consumer is a
|
|
170
284
|
* subclass overriding the build logging, which takes
|
|
@@ -176,6 +290,38 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
176
290
|
this.pendingUpdateReason = reason;
|
|
177
291
|
}
|
|
178
292
|
|
|
293
|
+
/**
|
|
294
|
+
* Call `listener` with a document once every {@link onDocumentPhase}
|
|
295
|
+
* listener of `state` ran for it and none was skipped by cancellation, and
|
|
296
|
+
* with the text version the phase listeners were called at. A write during
|
|
297
|
+
* them moves the document's own version on, past what they saw.
|
|
298
|
+
*
|
|
299
|
+
* Only here is it known what the phase listeners delivered. Langium sets the
|
|
300
|
+
* document's state before it notifies, and a cancel between two listeners
|
|
301
|
+
* skips the rest, leaving the document at the phase with those listeners
|
|
302
|
+
* never run and nothing to run them later. A build-phase listener comes too
|
|
303
|
+
* late: a cancel after this document but before the batch ends skips it,
|
|
304
|
+
* although every listener of this document ran.
|
|
305
|
+
*/
|
|
306
|
+
onDocumentPhaseDelivered(state: DocumentState, listener: (document: LangiumDocument, version: number) => void): Disposable {
|
|
307
|
+
this.documentPhaseDeliveredListeners.add(state, listener);
|
|
308
|
+
return Disposable.create(() => this.documentPhaseDeliveredListeners.delete(state, listener));
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Call `listener` with `drained` false once a build has run every phase
|
|
313
|
+
* ({@link buildDocuments}), and true once the lock has drained after a
|
|
314
|
+
* build that threw ({@link checkWaitsOnceDrained}); builds that throw
|
|
315
|
+
* before that drain share one call, so this does not count builds. A
|
|
316
|
+
* listener runs synchronously, inside the build or inside that check's lock
|
|
317
|
+
* read. A throw fails the finished build; in the read it skips the
|
|
318
|
+
* listeners after it and surfaces only as an unhandled rejection.
|
|
319
|
+
*/
|
|
320
|
+
protected onBuildEnded(listener: (drained: boolean) => void): Disposable {
|
|
321
|
+
this.buildEndedListeners.add(listener);
|
|
322
|
+
return Disposable.create(() => this.buildEndedListeners.delete(listener));
|
|
323
|
+
}
|
|
324
|
+
|
|
179
325
|
/**
|
|
180
326
|
* Diagnostic snapshot for use in timeout/error messages around document
|
|
181
327
|
* state.
|
|
@@ -193,13 +339,40 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
193
339
|
const doc = this.langiumDocuments.getDocument(UriUtils.toUri(this.uriPolicy.canonicalUri(uri)));
|
|
194
340
|
const docState = doc ? DocumentState[doc.state] : 'unknown (document not loaded)';
|
|
195
341
|
const lastPhase = this.lastPhaseMs > 0 ? `${Math.round(performance.now() - this.lastPhaseMs)}ms ago` : 'no phase observed';
|
|
196
|
-
return `current state: '${docState}', last phase: ${lastPhase}`;
|
|
342
|
+
return `current state: '${docState}', last phase: ${lastPhase}, active build: ${this.formatSession(this.activeSession)}`;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/** Render a session for a status line. `undefined` — no build in progress — reads as `none`. */
|
|
346
|
+
protected formatSession(session: BuildSession | undefined): string {
|
|
347
|
+
if (!session) {
|
|
348
|
+
return 'none';
|
|
349
|
+
}
|
|
350
|
+
const id = session.traceId !== undefined ? `#${session.traceId}` : 'untimed';
|
|
351
|
+
return `${id} (${session.trigger}, ${Math.round(performance.now() - session.startMs)}ms in)`;
|
|
197
352
|
}
|
|
198
353
|
|
|
199
354
|
// ============================================================
|
|
200
355
|
// Bug-fixes (always on)
|
|
201
356
|
// ============================================================
|
|
202
357
|
|
|
358
|
+
/**
|
|
359
|
+
* Resolve once the document at `uri` reaches `state`, or without `uri`, once
|
|
360
|
+
* the workspace does. A wait on `uri` re-queues a document no build is
|
|
361
|
+
* carrying, as {@link awaitDocumentState} describes.
|
|
362
|
+
*/
|
|
363
|
+
override waitUntil(state: DocumentState, cancelToken?: CancellationToken): Promise<void>;
|
|
364
|
+
override waitUntil(state: DocumentState, uri?: URI, cancelToken?: CancellationToken, options?: WaitUntilOptions): Promise<URI>;
|
|
365
|
+
override waitUntil(
|
|
366
|
+
state: DocumentState,
|
|
367
|
+
uriOrToken?: URI | CancellationToken,
|
|
368
|
+
cancelToken?: CancellationToken,
|
|
369
|
+
options: WaitUntilOptions = {}
|
|
370
|
+
): Promise<URI | void> {
|
|
371
|
+
return URI.isUri(uriOrToken)
|
|
372
|
+
? this.awaitDocumentState(state, uriOrToken, cancelToken ?? CancellationToken.None, options)
|
|
373
|
+
: super.waitUntil(state, uriOrToken);
|
|
374
|
+
}
|
|
375
|
+
|
|
203
376
|
/**
|
|
204
377
|
* Two edge cases the default Langium implementation rejects on:
|
|
205
378
|
* - Document below target state with no build active (newly-created file):
|
|
@@ -214,20 +387,43 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
214
387
|
*
|
|
215
388
|
* Replacing Langium's rejection with a wait makes the wait's liveness this
|
|
216
389
|
* class's responsibility: a listener can only fire if some build is still
|
|
217
|
-
* going to reach `state`.
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
* the
|
|
390
|
+
* going to reach `state`. So the wait re-queues the document whenever
|
|
391
|
+
* {@link isOrphaned} holds: once when it is armed, and again after every
|
|
392
|
+
* build that completes (see {@link buildDocuments}). The second check is
|
|
393
|
+
* the one a wait armed during a build needs, since only the build's end
|
|
394
|
+
* shows whether it left the document behind; Langium's `onBuildPhase` for
|
|
395
|
+
* `Validated` cannot serve, as it stays silent for a build that validates
|
|
396
|
+
* nothing, such as the workspace's initial one. A build that throws is
|
|
397
|
+
* checked once the lock drains instead (see {@link checkWaitsOnceDrained}):
|
|
398
|
+
* whatever cancelled it may build nothing. Re-queuing stops after
|
|
221
399
|
* {@link MAX_STALLED_REQUEUES} builds that fail to advance the document, so a
|
|
222
400
|
* document the builder will never carry to `state` degrades to a pending wait
|
|
223
|
-
* plus a warning rather than an endless build loop.
|
|
401
|
+
* plus a warning rather than an endless build loop. With `rejectWhenStuck`,
|
|
402
|
+
* the wait rejects instead, both then and once
|
|
403
|
+
* `VersionSyncService.requestRecoveryBuild` gives up a re-queued build.
|
|
404
|
+
*
|
|
405
|
+
* A wait for `Validated` on a document that a validating build skips
|
|
406
|
+
* resolves once that build has indexed its references, without diagnostics:
|
|
407
|
+
* see {@link skipsValidation}. Waiting on would never end, and re-queuing
|
|
408
|
+
* would skip it again.
|
|
409
|
+
*
|
|
410
|
+
* A re-queued build takes the {@link WorkspaceLock} (see
|
|
411
|
+
* {@link requeueOrphaned}), so a caller that awaits this wait while it holds
|
|
412
|
+
* the lock, inside a read or write action, deadlocks on a document that needs
|
|
413
|
+
* a re-queue: the build waits for that action to end. Await it outside the
|
|
414
|
+
* lock.
|
|
224
415
|
*/
|
|
225
|
-
protected override awaitDocumentState(
|
|
416
|
+
protected override awaitDocumentState(
|
|
417
|
+
state: DocumentState,
|
|
418
|
+
uri: URI,
|
|
419
|
+
cancelToken: CancellationToken,
|
|
420
|
+
{ rejectWhenStuck = false }: WaitUntilOptions = {}
|
|
421
|
+
): Promise<URI> {
|
|
226
422
|
const document = this.langiumDocuments.getDocument(uri);
|
|
227
423
|
if (!document) {
|
|
228
424
|
return super.awaitDocumentState(state, uri, cancelToken);
|
|
229
425
|
}
|
|
230
|
-
if (document.state >= state) {
|
|
426
|
+
if (document.state >= state || (state === DocumentState.Validated && this.skipsValidation(document))) {
|
|
231
427
|
return Promise.resolve(uri);
|
|
232
428
|
}
|
|
233
429
|
return new Promise<URI>((resolve, reject) => {
|
|
@@ -240,15 +436,28 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
240
436
|
// land while a busy workspace keeps cancelling builds.
|
|
241
437
|
let stalledRequeues = 0;
|
|
242
438
|
let lastRequeueState: DocumentState | undefined;
|
|
439
|
+
const giveUp = (reason: string): void => {
|
|
440
|
+
cleanup();
|
|
441
|
+
reject(
|
|
442
|
+
new Error(
|
|
443
|
+
`Gave up building ${this.formatUri(uri)} to '${DocumentState[state]}' ` +
|
|
444
|
+
`(at '${DocumentState[document.state]}'): ${reason}`
|
|
445
|
+
)
|
|
446
|
+
);
|
|
447
|
+
};
|
|
243
448
|
const requeue = (reason: string): void => {
|
|
244
449
|
if (document.state === lastRequeueState) {
|
|
245
450
|
if (++stalledRequeues > MAX_STALLED_REQUEUES) {
|
|
451
|
+
const stalled = `${stalledRequeues} builds did not advance it`;
|
|
452
|
+
if (rejectWhenStuck) {
|
|
453
|
+
giveUp(stalled);
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
246
456
|
this.tracer
|
|
247
457
|
.withUri(uri.toString())
|
|
248
458
|
.warn(
|
|
249
459
|
`Giving up re-queuing ${this.formatUri(uri)}: stuck at '${DocumentState[document.state]}', needs ` +
|
|
250
|
-
`'${DocumentState[state]}' after ${
|
|
251
|
-
'The wait now depends on its cancellation token.'
|
|
460
|
+
`'${DocumentState[state]}' after ${stalled}. The wait now depends on its cancellation token.`
|
|
252
461
|
);
|
|
253
462
|
return;
|
|
254
463
|
}
|
|
@@ -256,7 +465,11 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
256
465
|
stalledRequeues = 0;
|
|
257
466
|
lastRequeueState = document.state;
|
|
258
467
|
}
|
|
259
|
-
this.requeueOrphaned(document, state, reason)
|
|
468
|
+
void this.requeueOrphaned(document, state, reason).then(built => {
|
|
469
|
+
if (!built && rejectWhenStuck) {
|
|
470
|
+
giveUp('its recovery build failed');
|
|
471
|
+
}
|
|
472
|
+
});
|
|
260
473
|
};
|
|
261
474
|
const phaseDisposable = this.onDocumentPhase(
|
|
262
475
|
state,
|
|
@@ -267,34 +480,71 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
267
480
|
}
|
|
268
481
|
}, 'awaitDocumentState')
|
|
269
482
|
);
|
|
270
|
-
|
|
271
|
-
|
|
483
|
+
// The phase after which a validating build either validates the
|
|
484
|
+
// document or has skipped it.
|
|
485
|
+
const skipDisposable =
|
|
486
|
+
state === DocumentState.Validated
|
|
487
|
+
? this.onDocumentPhase(
|
|
488
|
+
DocumentState.IndexedReferences,
|
|
489
|
+
labelPhaseListener((doc: LangiumDocument): void => {
|
|
490
|
+
if (UriUtils.equals(doc.uri, uri) && this.skipsValidation(doc)) {
|
|
491
|
+
cleanup();
|
|
492
|
+
resolve(doc.uri);
|
|
493
|
+
}
|
|
494
|
+
}, 'awaitDocumentState.skipsValidation')
|
|
495
|
+
)
|
|
496
|
+
: Disposable.create(() => undefined);
|
|
497
|
+
const buildEnded = (drained: boolean): void => {
|
|
498
|
+
if (document.state >= state || (state === DocumentState.Validated && this.skipsValidation(document))) {
|
|
272
499
|
cleanup();
|
|
273
500
|
resolve(uri);
|
|
274
|
-
} else {
|
|
275
|
-
//
|
|
276
|
-
|
|
501
|
+
} else if (drained ? this.activeSession === undefined : this.isOrphaned(document, state)) {
|
|
502
|
+
// No build is left to carry the document to `state`. Either
|
|
503
|
+
// check fails only while an unlocked build still runs; that
|
|
504
|
+
// build carries the document or ends here too.
|
|
505
|
+
requeue(drained ? 'build ended early' : 'build ended short of the target');
|
|
277
506
|
}
|
|
278
|
-
}
|
|
507
|
+
};
|
|
508
|
+
const buildDisposable = this.onBuildEnded(buildEnded);
|
|
279
509
|
const cancelDisposable = cancelToken.onCancellationRequested(() => {
|
|
280
510
|
cleanup();
|
|
281
511
|
reject(OperationCancelled);
|
|
282
512
|
});
|
|
283
513
|
const cleanup = (): void => {
|
|
284
514
|
phaseDisposable.dispose();
|
|
515
|
+
skipDisposable.dispose();
|
|
285
516
|
buildDisposable.dispose();
|
|
286
517
|
cancelDisposable.dispose();
|
|
287
518
|
};
|
|
288
519
|
// Orphaned BEFORE the wait was armed: the build that would have
|
|
289
|
-
// advanced this document has already finished, so
|
|
290
|
-
//
|
|
291
|
-
// the resulting build resolves this wait.
|
|
292
|
-
|
|
520
|
+
// advanced this document has already finished, so none of these
|
|
521
|
+
// listeners fires until some other build runs. Re-queue now — the listeners are
|
|
522
|
+
// registered, so the resulting build resolves this wait.
|
|
523
|
+
// With `rejectWhenStuck`, also a document a failed build left behind:
|
|
524
|
+
// no build ends to re-queue it, so the wait would never give up.
|
|
525
|
+
if (this.isOrphaned(document, state) || (rejectWhenStuck && this.activeSession === undefined)) {
|
|
293
526
|
requeue('quiescent builder');
|
|
294
527
|
}
|
|
295
528
|
});
|
|
296
529
|
}
|
|
297
530
|
|
|
531
|
+
/**
|
|
532
|
+
* Whether the build that carries or last carried `document` has indexed its
|
|
533
|
+
* references, asks for validation, and still skips it, which is an override
|
|
534
|
+
* of `shouldValidate` excluding it. A build that does not ask for
|
|
535
|
+
* validation, such as the workspace's initial one, is not a skip: the next
|
|
536
|
+
* validating build validates the document. Nor is a document below
|
|
537
|
+
* `IndexedReferences`: the build writes its options before the first phase,
|
|
538
|
+
* so the document would pass for skipped before it is even parsed.
|
|
539
|
+
*/
|
|
540
|
+
protected skipsValidation(document: LangiumDocument): boolean {
|
|
541
|
+
return (
|
|
542
|
+
document.state >= DocumentState.IndexedReferences &&
|
|
543
|
+
Boolean(this.getBuildOptions(document).validation) &&
|
|
544
|
+
!this.shouldValidate(document)
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
|
|
298
548
|
/**
|
|
299
549
|
* Whether no build will advance `document` to `state`, so a wait on it can
|
|
300
550
|
* only be resolved by starting one.
|
|
@@ -312,25 +562,203 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
312
562
|
* `currentState` still advances to `Validated` (the validation phase runs
|
|
313
563
|
* over an empty document list). Any first read that wants diagnostics — a
|
|
314
564
|
* one-shot data-head read, a CLI query, `ModelService.validated` — lands
|
|
315
|
-
* here.
|
|
565
|
+
* here. A read that arrives while that build still runs finds `currentState`
|
|
566
|
+
* below `state`, so this holds for it only once the build has ended, which
|
|
567
|
+
* is why {@link awaitDocumentState} asks again then.
|
|
316
568
|
*/
|
|
317
569
|
protected isOrphaned(document: LangiumDocument, state: DocumentState): boolean {
|
|
318
570
|
return document.state < state && this.currentState >= state;
|
|
319
571
|
}
|
|
320
572
|
|
|
321
573
|
/**
|
|
322
|
-
* Schedule a build for a document no in-flight build will advance
|
|
323
|
-
*
|
|
324
|
-
*
|
|
325
|
-
*
|
|
326
|
-
*
|
|
574
|
+
* Schedule a build for a document no in-flight build will advance, through
|
|
575
|
+
* `VersionSyncService.requestRecoveryBuild`: from a {@link WorkspaceLock} read, so
|
|
576
|
+
* the build neither runs beside a locked one nor cancels the build a
|
|
577
|
+
* re-queue is fired from, and skipped if a write that ran meanwhile carried
|
|
578
|
+
* the document to `state`. The waiter resolves off the resulting phase
|
|
579
|
+
* notification; the answer only tells it whether the build was given up.
|
|
327
580
|
*/
|
|
328
|
-
protected requeueOrphaned(document: LangiumDocument, state: DocumentState, reason: string):
|
|
581
|
+
protected requeueOrphaned(document: LangiumDocument, state: DocumentState, reason: string): Promise<boolean> {
|
|
329
582
|
const tracer = this.tracer.withUri(document.uri.toString());
|
|
330
583
|
tracer.info(`Re-queuing orphaned document (at '${DocumentState[document.state]}', needs '${DocumentState[state]}'): ${reason}`);
|
|
331
|
-
this.
|
|
332
|
-
|
|
333
|
-
|
|
584
|
+
return this.versionSyncService().requestRecoveryBuild(document.uri, {
|
|
585
|
+
// Skipped on purpose: a waiting caller is answered sooner, at the cost
|
|
586
|
+
// of a possible duplicate build once the debounce fires.
|
|
587
|
+
ignoreDeferred: true,
|
|
588
|
+
stillNeeded: () => document.state < state
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// ============================================================
|
|
593
|
+
// Scheduled updates — one locked build for requests that coincide
|
|
594
|
+
// ============================================================
|
|
595
|
+
|
|
596
|
+
/**
|
|
597
|
+
* Build `changed` and `deleted` under the {@link WorkspaceLock}, as
|
|
598
|
+
* `workspaceLock.write(token => update(changed, deleted, token))` would,
|
|
599
|
+
* except where the build this method queued last already carries the
|
|
600
|
+
* request. The promise settles when the build that carries the request
|
|
601
|
+
* ends, completed or cancelled, as the lock's own promise does.
|
|
602
|
+
*
|
|
603
|
+
* Without it, requests that coincide cancel each other: each lock write
|
|
604
|
+
* cancels the one before it, after Langium's `update` has already reset the
|
|
605
|
+
* documents, scanned the workspace for relinking and called every
|
|
606
|
+
* `onUpdate` listener.
|
|
607
|
+
*
|
|
608
|
+
* - **Queued, not yet running:** the request merges into it, so nothing is
|
|
609
|
+
* cancelled. The later of a change and a deletion of one URI wins, so
|
|
610
|
+
* each URI reaches `update` in one list only: a file deleted and written
|
|
611
|
+
* again before the build starts is a change.
|
|
612
|
+
* - **Running:** the request joins it only when {@link canJoinRunningUpdate}
|
|
613
|
+
* holds, which keeps an edit made while it runs cancelling it.
|
|
614
|
+
* - **Otherwise,** or when anything else has cancelled that write since it
|
|
615
|
+
* was queued, a new write, which cancels the running build as any lock
|
|
616
|
+
* write does.
|
|
617
|
+
*
|
|
618
|
+
* `reason` is staged through {@link markNextReason} when the write runs. The
|
|
619
|
+
* latest reason of a merged request wins, as it does in the update
|
|
620
|
+
* handler's own debounced burst; a joining request's reason is dropped, since
|
|
621
|
+
* the build it joins has already started. A request without one leaves a
|
|
622
|
+
* reason staged by the caller in place.
|
|
623
|
+
*
|
|
624
|
+
* A caller that must run code of its own inside the write action takes the
|
|
625
|
+
* lock itself, and forgoes the sharing. A lock that is not a
|
|
626
|
+
* {@link HydraniumWorkspaceLock} cannot report a cancelled queued write, so
|
|
627
|
+
* every request then takes its own write.
|
|
628
|
+
*/
|
|
629
|
+
scheduleUpdate(changed: URI[], deleted: URI[], reason?: string): Promise<void> {
|
|
630
|
+
const lock = this.workspaceLock;
|
|
631
|
+
if (!(lock instanceof HydraniumWorkspaceLock)) {
|
|
632
|
+
return lock.write(token => {
|
|
633
|
+
if (reason !== undefined) {
|
|
634
|
+
this.markNextReason(reason);
|
|
635
|
+
}
|
|
636
|
+
return this.update(changed, deleted, token);
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
const scheduled = this.scheduledUpdate;
|
|
640
|
+
if (scheduled && scheduled.cancellations === lock.writeCancellations) {
|
|
641
|
+
if (!scheduled.takenVersions) {
|
|
642
|
+
for (const uri of changed) {
|
|
643
|
+
scheduled.changed.set(uri.toString(), uri);
|
|
644
|
+
scheduled.deleted.delete(uri.toString());
|
|
645
|
+
}
|
|
646
|
+
for (const uri of deleted) {
|
|
647
|
+
scheduled.deleted.set(uri.toString(), uri);
|
|
648
|
+
scheduled.changed.delete(uri.toString());
|
|
649
|
+
}
|
|
650
|
+
scheduled.reason = reason ?? scheduled.reason;
|
|
651
|
+
return scheduled.promise;
|
|
652
|
+
}
|
|
653
|
+
if (this.canJoinRunningUpdate(scheduled, changed, deleted)) {
|
|
654
|
+
return scheduled.promise;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
// The action runs on a later tick, by which time `request` is assigned.
|
|
658
|
+
const promise = lock.write(token => this.runScheduledUpdate(request, token));
|
|
659
|
+
const request: ScheduledUpdate = {
|
|
660
|
+
changed: new Map(changed.map(uri => [uri.toString(), uri])),
|
|
661
|
+
deleted: new Map(deleted.map(uri => [uri.toString(), uri])),
|
|
662
|
+
reason,
|
|
663
|
+
cancellations: lock.writeCancellations,
|
|
664
|
+
promise
|
|
665
|
+
};
|
|
666
|
+
this.scheduledUpdate = request;
|
|
667
|
+
return promise;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
/**
|
|
671
|
+
* Whether a request for `changed` and `deleted` is carried by the running
|
|
672
|
+
* `scheduled` build, whose write nothing has cancelled: the request deletes
|
|
673
|
+
* nothing, and each changed URI is one the build took, held by the text
|
|
674
|
+
* store at the version it had when the build started.
|
|
675
|
+
*
|
|
676
|
+
* Each condition keeps a request from joining a build that would miss its
|
|
677
|
+
* change. Text that moved since the start may be newer than what the build
|
|
678
|
+
* parsed; a URI the text store does not hold is read from its file, which
|
|
679
|
+
* may have changed after the build read it; and a deletion may concern a
|
|
680
|
+
* document the build has already built. A joined request is also absent
|
|
681
|
+
* from the running `update`'s `onUpdate` call, which reported the store as
|
|
682
|
+
* it was when the build started; at an unchanged version that is the store
|
|
683
|
+
* the request sees.
|
|
684
|
+
*/
|
|
685
|
+
protected canJoinRunningUpdate(scheduled: ScheduledUpdate, changed: URI[], deleted: URI[]): boolean {
|
|
686
|
+
const taken = scheduled.takenVersions;
|
|
687
|
+
if (!taken || deleted.length > 0) {
|
|
688
|
+
return false;
|
|
689
|
+
}
|
|
690
|
+
return changed.every(uri => taken.has(uri.toString()) && taken.get(uri.toString()) === this.textDocuments?.get(uri)?.version);
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/**
|
|
694
|
+
* The write action of a {@link scheduleUpdate}: freeze the request, record
|
|
695
|
+
* what it takes, stage its reason and run `update`. Releases
|
|
696
|
+
* {@link scheduledUpdate} inside the lock, whatever throws, so a request
|
|
697
|
+
* arriving after the build ends starts a write of its own rather than
|
|
698
|
+
* joining a build that is over.
|
|
699
|
+
*/
|
|
700
|
+
protected async runScheduledUpdate(request: ScheduledUpdate, token: CancellationToken): Promise<void> {
|
|
701
|
+
try {
|
|
702
|
+
const taken = new Map<string, number>();
|
|
703
|
+
for (const [key, uri] of request.changed) {
|
|
704
|
+
const version = this.textDocuments?.get(uri)?.version;
|
|
705
|
+
if (version !== undefined) {
|
|
706
|
+
taken.set(key, version);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
request.takenVersions = taken;
|
|
710
|
+
if (request.reason !== undefined) {
|
|
711
|
+
this.markNextReason(request.reason);
|
|
712
|
+
}
|
|
713
|
+
await this.update([...request.changed.values()], [...request.deleted.values()], token);
|
|
714
|
+
} finally {
|
|
715
|
+
if (this.scheduledUpdate === request) {
|
|
716
|
+
this.scheduledUpdate = undefined;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* Tell the {@link buildEndedListeners} once every phase has run, which is
|
|
723
|
+
* the one point where a build that skipped a waited-on document can be seen
|
|
724
|
+
* to have ended. Langium's `onBuildPhase` for `Validated` is not: it stays
|
|
725
|
+
* silent when no document reached that phase, which is every build that
|
|
726
|
+
* validates nothing, the workspace's initial one among them.
|
|
727
|
+
*
|
|
728
|
+
* A build that throws, whether cancelled or failed, tells none of them
|
|
729
|
+
* here: `currentState` is then below `Validated`, so {@link isOrphaned}
|
|
730
|
+
* could hold for no wait. {@link checkWaitsOnceDrained} tells them instead.
|
|
731
|
+
*/
|
|
732
|
+
protected override async buildDocuments(
|
|
733
|
+
documents: LangiumDocument[],
|
|
734
|
+
options: BuildOptions,
|
|
735
|
+
cancelToken: CancellationToken
|
|
736
|
+
): Promise<void> {
|
|
737
|
+
await super.buildDocuments(documents, options, cancelToken);
|
|
738
|
+
for (const listener of [...this.buildEndedListeners]) {
|
|
739
|
+
listener(false);
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/**
|
|
744
|
+
* After a build that threw, tell the {@link buildEndedListeners}, with
|
|
745
|
+
* `drained` set, from a {@link WorkspaceLock} read: it runs once no write
|
|
746
|
+
* runs or is queued, so no locked build is left that could still carry a
|
|
747
|
+
* waited-on document. A cancelled build is usually followed by its
|
|
748
|
+
* canceller's, but a write that builds nothing, such as a last-close revert
|
|
749
|
+
* that finds its document reopened, leaves a wait armed during the build
|
|
750
|
+
* with nothing to resolve it, and so does a build that fails. One read
|
|
751
|
+
* serves every build that throws before it runs.
|
|
752
|
+
*/
|
|
753
|
+
protected checkWaitsOnceDrained(): void {
|
|
754
|
+
if (this.drainCheckQueued) {
|
|
755
|
+
return;
|
|
756
|
+
}
|
|
757
|
+
this.drainCheckQueued = true;
|
|
758
|
+
void this.workspaceLock.read(() => {
|
|
759
|
+
this.drainCheckQueued = false;
|
|
760
|
+
for (const listener of [...this.buildEndedListeners]) {
|
|
761
|
+
listener(true);
|
|
334
762
|
}
|
|
335
763
|
});
|
|
336
764
|
}
|
|
@@ -409,7 +837,35 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
409
837
|
this.ensureLanguageFileExtensions();
|
|
410
838
|
const changedURIs = changed.flatMap(uri => this.flattenAndAdaptURI(uri));
|
|
411
839
|
const deletedURIs = deleted.flatMap(uri => this.collectDeletedURIs(uri));
|
|
412
|
-
return
|
|
840
|
+
return this.runInSession(
|
|
841
|
+
{
|
|
842
|
+
kind: 'update',
|
|
843
|
+
trigger: this.buildTriggerLabel(changedURIs, deletedURIs),
|
|
844
|
+
triggerCountsDocs: changedURIs.length + deletedURIs.length !== 1,
|
|
845
|
+
changed: changedURIs,
|
|
846
|
+
deleted: deletedURIs
|
|
847
|
+
},
|
|
848
|
+
this.rebuildLabel(changedURIs, deletedURIs),
|
|
849
|
+
() => super.update(changedURIs, deletedURIs, cancelToken)
|
|
850
|
+
);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* The workspace-initialization entry point, bracketed by a session like
|
|
855
|
+
* {@link update}. Langium's `update` reaches `buildDocuments` directly rather
|
|
856
|
+
* than through here, so the two never nest.
|
|
857
|
+
*/
|
|
858
|
+
override build<T extends AstNode>(
|
|
859
|
+
documents: Array<LangiumDocument<T>>,
|
|
860
|
+
options?: BuildOptions,
|
|
861
|
+
cancelToken?: CancellationToken
|
|
862
|
+
): Promise<void> {
|
|
863
|
+
const uris = documents.map(document => document.uri);
|
|
864
|
+
return this.runInSession(
|
|
865
|
+
{ kind: 'build', trigger: `${documents.length} docs`, triggerCountsDocs: true, changed: uris, deleted: [] },
|
|
866
|
+
`Build documents (${documents.length} docs)`,
|
|
867
|
+
() => super.build(documents, options, cancelToken)
|
|
868
|
+
);
|
|
413
869
|
}
|
|
414
870
|
|
|
415
871
|
/**
|
|
@@ -556,13 +1012,25 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
556
1012
|
* documents*: the Node provider walks the real filesystem (a freshly added
|
|
557
1013
|
* directory or never-opened file still builds), while a browser / empty
|
|
558
1014
|
* provider yields nothing. `uriPolicy.loadUri` first maps the URI to its
|
|
559
|
-
* load identity
|
|
560
|
-
*
|
|
561
|
-
*
|
|
1015
|
+
* load identity, and a symlink resolves to its real path so the built
|
|
1016
|
+
* documents key the same way every other layer does.
|
|
1017
|
+
*
|
|
1018
|
+
* A URI with no on-disk content is dropped rather than read, unless the text
|
|
1019
|
+
* store or the document registry holds it, under its canonical URI, the key
|
|
1020
|
+
* both hold it by. A document created and not yet saved has text but no
|
|
1021
|
+
* file, and a policy that checks the disk reports it absent. A registered
|
|
1022
|
+
* document whose file has gone is kept too: its rebuild then fails on the
|
|
1023
|
+
* read, which is how the revert on last close learns to remove it rather
|
|
1024
|
+
* than leave it holding its last client's text.
|
|
562
1025
|
*/
|
|
563
1026
|
protected flattenAndAdaptURI(uri: URI): URI[] {
|
|
564
1027
|
const resolved = this.uriPolicy.loadUri(uri);
|
|
565
|
-
|
|
1028
|
+
if (resolved) {
|
|
1029
|
+
return this.collectLanguageFiles(resolved);
|
|
1030
|
+
}
|
|
1031
|
+
const canonical = UriUtils.toUri(this.uriPolicy.canonicalUri(uri));
|
|
1032
|
+
const held = this.textDocuments?.get(canonical) !== undefined || this.langiumDocuments.hasDocument(canonical);
|
|
1033
|
+
return held ? this.collectLanguageFiles(canonical) : [];
|
|
566
1034
|
}
|
|
567
1035
|
|
|
568
1036
|
/** Recurse `uri` through the `FileSystemProvider`, gathering registered
|
|
@@ -615,6 +1083,151 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
615
1083
|
];
|
|
616
1084
|
}
|
|
617
1085
|
|
|
1086
|
+
// ============================================================
|
|
1087
|
+
// Build sessions — one rebuild as a correlated unit
|
|
1088
|
+
// ============================================================
|
|
1089
|
+
|
|
1090
|
+
/**
|
|
1091
|
+
* Open a session, run `body` inside it, and close it — the bracket every
|
|
1092
|
+
* line of a rebuild is emitted within.
|
|
1093
|
+
*
|
|
1094
|
+
* The session is installed **synchronously**, before the timed body runs, so
|
|
1095
|
+
* that state a subclass computed in {@link createBuildSession} is already
|
|
1096
|
+
* readable by the time Langium's `update` consults `shouldRelink`.
|
|
1097
|
+
*
|
|
1098
|
+
* Teardown is preemption-correct, which is the reason this is framework code
|
|
1099
|
+
* rather than a recipe. A build outside the workspace lock overlaps another:
|
|
1100
|
+
* the later one installs itself as {@link activeSession} while the earlier
|
|
1101
|
+
* one is still running, and the earlier one's `finally` runs LAST. Clearing
|
|
1102
|
+
* unconditionally there would discard the later build's state mid-build.
|
|
1103
|
+
* Only the session that is still current clears — and the check is
|
|
1104
|
+
* reference equality on the session object,
|
|
1105
|
+
* not on {@link BuildSession.traceId}, which is `undefined` for every build
|
|
1106
|
+
* whenever the timing level is suppressed and would compare equal to itself
|
|
1107
|
+
* across two different builds.
|
|
1108
|
+
*
|
|
1109
|
+
* Builds outside the lock are not hypothetical even without an adopter: the
|
|
1110
|
+
* model service under `allowReentrantBuilds` starts one. Two locked builds
|
|
1111
|
+
* never overlap, since the lock starts a write only once the write it
|
|
1112
|
+
* cancelled has unwound.
|
|
1113
|
+
*/
|
|
1114
|
+
protected runInSession(context: BuildSessionContext, label: string, body: () => Promise<void>): Promise<void> {
|
|
1115
|
+
// Read before installing the new session: the id being superseded belongs
|
|
1116
|
+
// to the OUTGOING build, or — when the previous one already finished
|
|
1117
|
+
// cancelled — to the id it parked for its successor.
|
|
1118
|
+
const supersededId = this.activeSession?.traceId ?? this.lastCancelledTraceId;
|
|
1119
|
+
this.lastCancelledTraceId = undefined;
|
|
1120
|
+
const reason = this.pendingUpdateReason;
|
|
1121
|
+
this.pendingUpdateReason = undefined;
|
|
1122
|
+
const tags: string[] = [];
|
|
1123
|
+
if (reason) {
|
|
1124
|
+
tags.push(`event: ${reason}`);
|
|
1125
|
+
}
|
|
1126
|
+
if (supersededId !== undefined) {
|
|
1127
|
+
tags.push(`cancels #${supersededId}`);
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
const session = this.createBuildSession(context);
|
|
1131
|
+
this.activeSession = session;
|
|
1132
|
+
// A phase's "since previous phase" must measure from the build's start,
|
|
1133
|
+
// not from whenever the last build's final phase happened to land.
|
|
1134
|
+
this.lastPhaseMs = session.startMs;
|
|
1135
|
+
return this.tracer.time(
|
|
1136
|
+
label,
|
|
1137
|
+
async () => {
|
|
1138
|
+
try {
|
|
1139
|
+
await body();
|
|
1140
|
+
} catch (err: unknown) {
|
|
1141
|
+
if (isOperationCancelled(err)) {
|
|
1142
|
+
session.cancelled = true;
|
|
1143
|
+
}
|
|
1144
|
+
this.checkWaitsOnceDrained();
|
|
1145
|
+
throw err;
|
|
1146
|
+
} finally {
|
|
1147
|
+
this.endSession(session);
|
|
1148
|
+
}
|
|
1149
|
+
},
|
|
1150
|
+
this.logLevel,
|
|
1151
|
+
{
|
|
1152
|
+
logAfterMs: 0,
|
|
1153
|
+
forceMemoryAboveMs: session.buffers ? session.detailThresholdMs : undefined,
|
|
1154
|
+
captureId: id => {
|
|
1155
|
+
session.traceId = id;
|
|
1156
|
+
},
|
|
1157
|
+
tags
|
|
1158
|
+
}
|
|
1159
|
+
);
|
|
1160
|
+
}
|
|
1161
|
+
|
|
1162
|
+
/**
|
|
1163
|
+
* Construct the session for one build. Override to return a
|
|
1164
|
+
* {@link BuildSession} subclass carrying adopter build-scoped state — it is
|
|
1165
|
+
* called before the build body, so anything derived here is readable
|
|
1166
|
+
* throughout it.
|
|
1167
|
+
*/
|
|
1168
|
+
protected createBuildSession(context: BuildSessionContext): BuildSession {
|
|
1169
|
+
return new BuildSession(performance.now(), context.trigger, context.triggerCountsDocs, this.phaseDetailMs.value);
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
/**
|
|
1173
|
+
* Close `session`: flush what it buffered, then release it if it is still the
|
|
1174
|
+
* current one (see {@link runInSession} on why that check is conditional).
|
|
1175
|
+
* The flush is unconditional — a preempted build's lines still describe work
|
|
1176
|
+
* that happened.
|
|
1177
|
+
*/
|
|
1178
|
+
protected endSession(session: BuildSession): void {
|
|
1179
|
+
this.flushSession(session);
|
|
1180
|
+
if (this.activeSession === session) {
|
|
1181
|
+
this.activeSession = undefined;
|
|
1182
|
+
if (session.cancelled) {
|
|
1183
|
+
this.lastCancelledTraceId = session.traceId;
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
}
|
|
1187
|
+
|
|
1188
|
+
/**
|
|
1189
|
+
* Emit the lines `session` held back, if it ran long enough to be worth the
|
|
1190
|
+
* detail; drop them otherwise. Emits through {@link emit} rather than
|
|
1191
|
+
* {@link log}, which would route them straight back into the buffer.
|
|
1192
|
+
*/
|
|
1193
|
+
protected flushSession(session: BuildSession): void {
|
|
1194
|
+
const elapsedMs = performance.now() - session.startMs;
|
|
1195
|
+
if (elapsedMs >= session.detailThresholdMs) {
|
|
1196
|
+
for (const line of session.bufferedLines) {
|
|
1197
|
+
this.emit(line);
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
session.bufferedLines.length = 0;
|
|
1201
|
+
}
|
|
1202
|
+
|
|
1203
|
+
/** Label for the build's own log line. Override to customise wording. */
|
|
1204
|
+
protected rebuildLabel(changed: URI[], deleted: URI[]): string {
|
|
1205
|
+
if (changed.length === 0 && deleted.length === 0) {
|
|
1206
|
+
return 'Rebuild documents (nothing to do)';
|
|
1207
|
+
}
|
|
1208
|
+
if (changed.length === 1 && deleted.length === 0) {
|
|
1209
|
+
return `Rebuild document: ${this.formatUri(changed[0])}`;
|
|
1210
|
+
}
|
|
1211
|
+
if (changed.length === 0 && deleted.length === 1) {
|
|
1212
|
+
return `Rebuild after delete: ${this.formatUri(deleted[0])}`;
|
|
1213
|
+
}
|
|
1214
|
+
return `Rebuild documents (${changed.length} changed, ${deleted.length} deleted)`;
|
|
1215
|
+
}
|
|
1216
|
+
|
|
1217
|
+
/** Short description of what triggered the build, repeated on every phase line. Override to customise wording. */
|
|
1218
|
+
protected buildTriggerLabel(changed: URI[], deleted: URI[]): string {
|
|
1219
|
+
if (changed.length === 0 && deleted.length === 0) {
|
|
1220
|
+
return 'nothing';
|
|
1221
|
+
}
|
|
1222
|
+
if (changed.length === 1 && deleted.length === 0) {
|
|
1223
|
+
return this.formatUri(changed[0]);
|
|
1224
|
+
}
|
|
1225
|
+
if (changed.length === 0 && deleted.length === 1) {
|
|
1226
|
+
return `deleted ${this.formatUri(deleted[0])}`;
|
|
1227
|
+
}
|
|
1228
|
+
return `${changed.length} changed, ${deleted.length} deleted`;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
618
1231
|
// ============================================================
|
|
619
1232
|
// Logging — phase-reached listeners
|
|
620
1233
|
// ============================================================
|
|
@@ -630,17 +1243,39 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
630
1243
|
const now = performance.now();
|
|
631
1244
|
const elapsedMs = Math.round(now - this.lastPhaseMs);
|
|
632
1245
|
this.lastPhaseMs = now;
|
|
1246
|
+
// Counted before the line is formatted, so the formatter stays a pure
|
|
1247
|
+
// function of state a caller can also set up in a test.
|
|
1248
|
+
if (this.activeSession) {
|
|
1249
|
+
this.activeSession.phasesLogged++;
|
|
1250
|
+
}
|
|
633
1251
|
this.log(this.phaseReachedLine(state, documents, elapsedMs));
|
|
634
1252
|
}
|
|
635
1253
|
|
|
636
|
-
/**
|
|
1254
|
+
/**
|
|
1255
|
+
* Format the phase-reached log line. Override to customise wording.
|
|
1256
|
+
*
|
|
1257
|
+
* Within a session the line names what triggered the build, so a phase read
|
|
1258
|
+
* in isolation still says which rebuild it belongs to. `elapsedMs` is ignored
|
|
1259
|
+
* for the FIRST phase of a session: it measures from the previous build's
|
|
1260
|
+
* last phase, an idle gap that says nothing about this build.
|
|
1261
|
+
*/
|
|
637
1262
|
protected phaseReachedLine(state: DocumentState, documents: LangiumDocument[], elapsedMs: number): string {
|
|
638
|
-
const
|
|
639
|
-
|
|
1263
|
+
const session = this.activeSession;
|
|
1264
|
+
let docInfo: string;
|
|
1265
|
+
if (session) {
|
|
1266
|
+
docInfo = session.triggerCountsDocs ? `building ${session.trigger}` : `building ${session.trigger}, ${documents.length} docs`;
|
|
1267
|
+
} else {
|
|
1268
|
+
docInfo = documents.length === 1 ? this.formatUri(documents[0].uri) : `${documents.length} docs`;
|
|
1269
|
+
}
|
|
1270
|
+
const elapsedInfo =
|
|
1271
|
+
session && session.phasesLogged <= 1
|
|
1272
|
+
? `${Math.round(performance.now() - session.startMs)}ms since build start`
|
|
1273
|
+
: `${elapsedMs}ms since previous phase`;
|
|
1274
|
+
return `Reached phase '${DocumentState[state]}' [${docInfo}, ${elapsedInfo}]`;
|
|
640
1275
|
}
|
|
641
1276
|
|
|
642
1277
|
// ============================================================
|
|
643
|
-
//
|
|
1278
|
+
// notifyDocumentPhase — the delivery hook and the slow-listener breakdown
|
|
644
1279
|
// ============================================================
|
|
645
1280
|
|
|
646
1281
|
override async notifyDocumentPhase(document: LangiumDocument, state: DocumentState, cancelToken: CancellationToken): Promise<void> {
|
|
@@ -650,17 +1285,16 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
650
1285
|
// replacing it, and the publisher reads that array when it is invoked. A
|
|
651
1286
|
// build settling inside that window therefore appends after this call has
|
|
652
1287
|
// already deduped, and the appended duplicate is published by the listener
|
|
653
|
-
// of the build that deduped. Only
|
|
1288
|
+
// of the build that deduped. Only the write lock closes the window.
|
|
1289
|
+
//
|
|
1290
|
+
// Dedupe before rendering: rendering is deterministic, so it cannot
|
|
1291
|
+
// change which entries are structurally equal, and fewer survive to render.
|
|
654
1292
|
if (state === DocumentState.Validated) {
|
|
655
1293
|
this.dedupeDiagnostics(document);
|
|
656
|
-
|
|
657
|
-
if (this.logLevel === 'off') {
|
|
658
|
-
return super.notifyDocumentPhase(document, state, cancelToken);
|
|
1294
|
+
this.renderDiagnostics(document);
|
|
659
1295
|
}
|
|
660
1296
|
const listeners = this.documentPhaseListeners.get(state).slice();
|
|
661
|
-
|
|
662
|
-
return;
|
|
663
|
-
}
|
|
1297
|
+
const version = document.textDocument.version;
|
|
664
1298
|
const perListenerMs: number[] = [];
|
|
665
1299
|
let cancelledListeners = 0;
|
|
666
1300
|
const { elapsedMs: totalMs } = await this.clock.measure(async () => {
|
|
@@ -679,6 +1313,14 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
679
1313
|
perListenerMs.push(elapsedMs);
|
|
680
1314
|
}
|
|
681
1315
|
});
|
|
1316
|
+
if (cancelledListeners === 0) {
|
|
1317
|
+
for (const delivered of this.documentPhaseDeliveredListeners.get(state).slice()) {
|
|
1318
|
+
delivered(document, version);
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
if (this.logLevel === 'off' || listeners.length === 0) {
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
682
1324
|
if (cancelledListeners > 0) {
|
|
683
1325
|
this.tracer
|
|
684
1326
|
.withUri(document.uri.toString())
|
|
@@ -769,8 +1411,8 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
769
1411
|
* twice: Langium's validate appends to `document.diagnostics` when they are
|
|
770
1412
|
* already set — deliberately, so a category-partitioned pass keeps the earlier
|
|
771
1413
|
* category's findings — and a repeated FULL pass therefore doubles the list.
|
|
772
|
-
*
|
|
773
|
-
*
|
|
1414
|
+
* The write lock prevents that at the source; this is the net for builds
|
|
1415
|
+
* that skip it, as `ModelServiceOptions.allowReentrantBuilds` lets one do.
|
|
774
1416
|
*
|
|
775
1417
|
* Clearing the list before a pass is NOT an alternative: the append happens at
|
|
776
1418
|
* pass completion, so two interleaved passes both clear, both finish, and the
|
|
@@ -828,12 +1470,87 @@ export class HydraniumDocumentBuilder extends DefaultDocumentBuilder {
|
|
|
828
1470
|
}
|
|
829
1471
|
}
|
|
830
1472
|
|
|
1473
|
+
/**
|
|
1474
|
+
* Render every diagnostic on `document` through the bound message renderer,
|
|
1475
|
+
* in ONE pass over the finished list.
|
|
1476
|
+
*
|
|
1477
|
+
* All three heads read `document.diagnostics` — the LSP publish,
|
|
1478
|
+
* `TransferEncoder.toTransferDiagnostic` and the GLSP validation path — so
|
|
1479
|
+
* one pass here is what keeps the render from happening per head. It is also
|
|
1480
|
+
* the only placement that covers lexer and parser errors, which Langium
|
|
1481
|
+
* pushes onto the document without routing them through `toDiagnostic`.
|
|
1482
|
+
*
|
|
1483
|
+
* Running here rather than from a `Validated` phase listener needs no
|
|
1484
|
+
* ordering assumption: Langium publishes from `addDiagnosticsHandler`, a free
|
|
1485
|
+
* function it registers as such a listener, which can only be outrun.
|
|
1486
|
+
*
|
|
1487
|
+
* **It inherits {@link dedupeDiagnostics}'s window, and therefore the same
|
|
1488
|
+
* precondition.** A build settling inside the listener window appends
|
|
1489
|
+
* diagnostics this pass never saw, and the publisher of the build that
|
|
1490
|
+
* rendered sends them — unrendered. The write lock closes it, so "every
|
|
1491
|
+
* diagnostic is rendered" holds while
|
|
1492
|
+
* `ModelServiceOptions.allowReentrantBuilds` is `false`, its default.
|
|
1493
|
+
* Turning it on accepts unrendered diagnostics on exactly the terms it
|
|
1494
|
+
* already accepts duplicates.
|
|
1495
|
+
*
|
|
1496
|
+
* Entries are REPLACED rather than mutated: `sendDiagnostics` passes the
|
|
1497
|
+
* array by reference and serialises later, so an in-place message mutation
|
|
1498
|
+
* reaches the wire even when it runs after the publisher — which would make
|
|
1499
|
+
* a test for the ordering pass in either state.
|
|
1500
|
+
*/
|
|
1501
|
+
protected renderDiagnostics(document: LangiumDocument): void {
|
|
1502
|
+
const diagnostics = document.diagnostics;
|
|
1503
|
+
if (!diagnostics || diagnostics.length === 0) {
|
|
1504
|
+
return;
|
|
1505
|
+
}
|
|
1506
|
+
let changed = false;
|
|
1507
|
+
// No try/catch: `renderDiagnostic` carries a no-throw contract, because an
|
|
1508
|
+
// error escaping this phase strands the document at `Validated` with
|
|
1509
|
+
// Langium's publisher never invoked.
|
|
1510
|
+
const rendered = diagnostics.map(diagnostic => {
|
|
1511
|
+
const text = this.messageRenderer.renderDiagnostic(diagnostic);
|
|
1512
|
+
// Against the message's STRING FORM, not the field. `renderDiagnostic`
|
|
1513
|
+
// answers a `string` by contract, while `Diagnostic.message` is
|
|
1514
|
+
// `string | MarkupContent` since LSP 3.17 — so comparing the answer
|
|
1515
|
+
// against the field never matches for a markup message, and a pass
|
|
1516
|
+
// that replaced on mismatch flattened every un-identified markup
|
|
1517
|
+
// diagnostic to its own plain text. That is silent data loss on the
|
|
1518
|
+
// path whose whole job is to leave such entries alone.
|
|
1519
|
+
if (text === Diagnostic.getMessageString(diagnostic)) {
|
|
1520
|
+
return diagnostic;
|
|
1521
|
+
}
|
|
1522
|
+
changed = true;
|
|
1523
|
+
return { ...diagnostic, message: text };
|
|
1524
|
+
});
|
|
1525
|
+
if (changed) {
|
|
1526
|
+
document.diagnostics = rendered;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
|
|
831
1530
|
// ============================================================
|
|
832
1531
|
// Internal helpers
|
|
833
1532
|
// ============================================================
|
|
834
1533
|
|
|
835
|
-
/**
|
|
1534
|
+
/**
|
|
1535
|
+
* Dispatch a log line at the configured log level; a no-op when `logLevel ===
|
|
1536
|
+
* 'off'`.
|
|
1537
|
+
*
|
|
1538
|
+
* Held on the active session when it buffers, so the "was this build worth a
|
|
1539
|
+
* per-phase breakdown" decision — which needs the build's total duration, and
|
|
1540
|
+
* so cannot be taken by anything that runs while the lines are produced — is
|
|
1541
|
+
* deferred to {@link flushSession}.
|
|
1542
|
+
*/
|
|
836
1543
|
protected log(message: string): void {
|
|
1544
|
+
const session = this.activeSession;
|
|
1545
|
+
if (session?.buffers) {
|
|
1546
|
+
session.bufferedLines.push(message);
|
|
1547
|
+
return;
|
|
1548
|
+
}
|
|
1549
|
+
this.emit(message);
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1552
|
+
/** Write a line out, bypassing session buffering. The single sink every framework log line reaches. */
|
|
1553
|
+
protected emit(message: string): void {
|
|
837
1554
|
this.tracer.logAt(this.logLevel, message);
|
|
838
1555
|
}
|
|
839
1556
|
}
|