@hydranium/core 1.0.0-next.17 → 1.0.0-next.173
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/lib/documents/ast-document-manager.d.ts +190 -29
- package/lib/documents/ast-document-manager.d.ts.map +1 -1
- package/lib/documents/ast-document-manager.js +235 -38
- package/lib/documents/ast-document-manager.js.map +1 -1
- package/lib/documents/client-ids.d.ts +5 -19
- package/lib/documents/client-ids.d.ts.map +1 -1
- package/lib/documents/client-ids.js +5 -19
- package/lib/documents/client-ids.js.map +1 -1
- package/lib/documents/client-session-errors.d.ts +15 -0
- package/lib/documents/client-session-errors.d.ts.map +1 -0
- package/lib/documents/client-session-errors.js +15 -0
- package/lib/documents/client-session-errors.js.map +1 -0
- package/lib/documents/client-session-registry.d.ts +138 -0
- package/lib/documents/client-session-registry.d.ts.map +1 -0
- package/lib/documents/client-session-registry.js +187 -0
- package/lib/documents/client-session-registry.js.map +1 -0
- package/lib/documents/file-system-task-queue.d.ts +49 -0
- package/lib/documents/file-system-task-queue.d.ts.map +1 -0
- package/lib/documents/file-system-task-queue.js +34 -0
- package/lib/documents/file-system-task-queue.js.map +1 -0
- package/lib/documents/hydranium-text-documents.d.ts +447 -82
- package/lib/documents/hydranium-text-documents.d.ts.map +1 -1
- package/lib/documents/hydranium-text-documents.js +780 -160
- package/lib/documents/hydranium-text-documents.js.map +1 -1
- package/lib/documents/index.d.ts +3 -0
- package/lib/documents/index.d.ts.map +1 -1
- package/lib/documents/index.js +3 -0
- package/lib/documents/index.js.map +1 -1
- package/lib/documents/language-client-text-shadow.d.ts +41 -9
- package/lib/documents/language-client-text-shadow.d.ts.map +1 -1
- package/lib/documents/language-client-text-shadow.js +56 -11
- package/lib/documents/language-client-text-shadow.js.map +1 -1
- package/lib/documents/self-save-registry.d.ts +37 -6
- package/lib/documents/self-save-registry.d.ts.map +1 -1
- package/lib/documents/self-save-registry.js +28 -15
- package/lib/documents/self-save-registry.js.map +1 -1
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -1
- package/lib/langium/ast-extension/ast-node-builder.d.ts +32 -9
- package/lib/langium/ast-extension/ast-node-builder.d.ts.map +1 -1
- package/lib/langium/ast-extension/ast-node-builder.js +60 -22
- package/lib/langium/ast-extension/ast-node-builder.js.map +1 -1
- package/lib/langium/bootstrap.d.ts.map +1 -1
- package/lib/langium/bootstrap.js +16 -9
- package/lib/langium/bootstrap.js.map +1 -1
- package/lib/langium/config/configuration-provider.d.ts +81 -0
- package/lib/langium/config/configuration-provider.d.ts.map +1 -0
- package/lib/langium/config/configuration-provider.js +112 -0
- package/lib/langium/config/configuration-provider.js.map +1 -0
- package/lib/langium/config/index.d.ts +1 -0
- package/lib/langium/config/index.d.ts.map +1 -1
- package/lib/langium/config/index.js +1 -0
- package/lib/langium/config/index.js.map +1 -1
- package/lib/langium/diagnostics/lsp-logger.d.ts +17 -0
- package/lib/langium/diagnostics/lsp-logger.d.ts.map +1 -1
- package/lib/langium/diagnostics/lsp-logger.js +40 -6
- package/lib/langium/diagnostics/lsp-logger.js.map +1 -1
- package/lib/langium/document-builder/build-pipeline-integration.d.ts +21 -1
- package/lib/langium/document-builder/build-pipeline-integration.d.ts.map +1 -1
- package/lib/langium/document-builder/build-pipeline-integration.js +32 -5
- package/lib/langium/document-builder/build-pipeline-integration.js.map +1 -1
- package/lib/langium/document-builder/build-session.d.ts +93 -0
- package/lib/langium/document-builder/build-session.d.ts.map +1 -0
- package/lib/langium/document-builder/build-session.js +72 -0
- package/lib/langium/document-builder/build-session.js.map +1 -0
- package/lib/langium/document-builder/document-builder.d.ts +368 -21
- package/lib/langium/document-builder/document-builder.d.ts.map +1 -1
- package/lib/langium/document-builder/document-builder.js +641 -47
- package/lib/langium/document-builder/document-builder.js.map +1 -1
- package/lib/langium/document-builder/index.d.ts +1 -0
- package/lib/langium/document-builder/index.d.ts.map +1 -1
- package/lib/langium/document-builder/index.js +1 -0
- package/lib/langium/document-builder/index.js.map +1 -1
- package/lib/langium/integration-services.d.ts +45 -1
- package/lib/langium/integration-services.d.ts.map +1 -1
- package/lib/langium/integration-services.js +10 -5
- package/lib/langium/integration-services.js.map +1 -1
- package/lib/langium/integrity/integrity-rule.d.ts +13 -5
- package/lib/langium/integrity/integrity-rule.d.ts.map +1 -1
- package/lib/langium/integrity/integrity-rule.js.map +1 -1
- package/lib/langium/integrity/integrity-service.d.ts +58 -13
- package/lib/langium/integrity/integrity-service.d.ts.map +1 -1
- package/lib/langium/integrity/integrity-service.js +213 -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/language-module.d.ts +27 -2
- package/lib/langium/language-module.d.ts.map +1 -1
- package/lib/langium/language-module.js +16 -2
- package/lib/langium/language-module.js.map +1 -1
- package/lib/langium/model-service/client-session.d.ts +307 -0
- package/lib/langium/model-service/client-session.d.ts.map +1 -0
- package/lib/langium/model-service/client-session.js +395 -0
- package/lib/langium/model-service/client-session.js.map +1 -0
- package/lib/langium/model-service/index.d.ts +1 -0
- package/lib/langium/model-service/index.d.ts.map +1 -1
- package/lib/langium/model-service/index.js +1 -0
- package/lib/langium/model-service/index.js.map +1 -1
- package/lib/langium/model-service/model-service.d.ts +276 -226
- package/lib/langium/model-service/model-service.d.ts.map +1 -1
- package/lib/langium/model-service/model-service.js +251 -375
- package/lib/langium/model-service/model-service.js.map +1 -1
- package/lib/langium/module.d.ts +144 -35
- package/lib/langium/module.d.ts.map +1 -1
- package/lib/langium/module.js +46 -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/residency/cst-residency-service.d.ts +31 -11
- package/lib/langium/residency/cst-residency-service.d.ts.map +1 -1
- package/lib/langium/residency/cst-residency-service.js +13 -56
- package/lib/langium/residency/cst-residency-service.js.map +1 -1
- package/lib/langium/scope/hydranium-scope-provider.d.ts +48 -13
- package/lib/langium/scope/hydranium-scope-provider.d.ts.map +1 -1
- package/lib/langium/scope/hydranium-scope-provider.js +56 -20
- package/lib/langium/scope/hydranium-scope-provider.js.map +1 -1
- package/lib/langium/serialization/abstract-serializer.d.ts +11 -20
- package/lib/langium/serialization/abstract-serializer.d.ts.map +1 -1
- package/lib/langium/serialization/abstract-serializer.js +12 -21
- package/lib/langium/serialization/abstract-serializer.js.map +1 -1
- package/lib/langium/service-registry.d.ts +15 -1
- package/lib/langium/service-registry.d.ts.map +1 -1
- package/lib/langium/service-registry.js +16 -0
- package/lib/langium/service-registry.js.map +1 -1
- package/lib/langium/shared-services.d.ts +15 -2
- package/lib/langium/shared-services.d.ts.map +1 -1
- package/lib/langium/shared-services.js.map +1 -1
- package/lib/langium/transfer/transfer-encoder.d.ts +60 -17
- package/lib/langium/transfer/transfer-encoder.d.ts.map +1 -1
- package/lib/langium/transfer/transfer-encoder.js +38 -16
- package/lib/langium/transfer/transfer-encoder.js.map +1 -1
- package/lib/langium/trivia/comment-preserver.d.ts +423 -0
- package/lib/langium/trivia/comment-preserver.d.ts.map +1 -0
- package/lib/langium/trivia/comment-preserver.js +906 -0
- package/lib/langium/trivia/comment-preserver.js.map +1 -0
- package/lib/langium/trivia/document-ending-preserver.d.ts +43 -0
- package/lib/langium/trivia/document-ending-preserver.d.ts.map +1 -0
- package/lib/langium/trivia/document-ending-preserver.js +48 -0
- package/lib/langium/trivia/document-ending-preserver.js.map +1 -0
- package/lib/langium/trivia/index.d.ts +14 -0
- package/lib/langium/trivia/index.d.ts.map +1 -0
- package/lib/langium/trivia/index.js +14 -0
- package/lib/langium/trivia/index.js.map +1 -0
- package/lib/langium/trivia/trivia-contribution.d.ts +37 -0
- package/lib/langium/trivia/trivia-contribution.d.ts.map +1 -0
- package/lib/langium/trivia/trivia-contribution.js +10 -0
- package/lib/langium/trivia/trivia-contribution.js.map +1 -0
- package/lib/langium/trivia/trivia-preserver.d.ts +50 -0
- package/lib/langium/trivia/trivia-preserver.d.ts.map +1 -0
- package/lib/langium/trivia/trivia-preserver.js +10 -0
- package/lib/langium/trivia/trivia-preserver.js.map +1 -0
- package/lib/langium/trivia/trivia-service.d.ts +70 -0
- package/lib/langium/trivia/trivia-service.d.ts.map +1 -0
- package/lib/langium/trivia/trivia-service.js +56 -0
- package/lib/langium/trivia/trivia-service.js.map +1 -0
- package/lib/langium/update-rewrite/update-rewrite.d.ts +1 -1
- package/lib/langium/validation/document-validator.d.ts +294 -10
- package/lib/langium/validation/document-validator.d.ts.map +1 -1
- package/lib/langium/validation/document-validator.js +448 -5
- package/lib/langium/validation/document-validator.js.map +1 -1
- package/lib/langium/workspace/document-uri-policy.d.ts +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 +25 -0
- package/lib/langium/workspace/hydranium-langium-document-factory.d.ts.map +1 -1
- package/lib/langium/workspace/hydranium-langium-document-factory.js +25 -0
- package/lib/langium/workspace/hydranium-langium-document-factory.js.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-lock.d.ts +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/initialize-workspace.d.ts +31 -2
- package/lib/langium/workspace/initialize-workspace.d.ts.map +1 -1
- package/lib/langium/workspace/initialize-workspace.js +13 -5
- package/lib/langium/workspace/initialize-workspace.js.map +1 -1
- package/lib/langium/workspace/langium-documents.d.ts +79 -17
- package/lib/langium/workspace/langium-documents.d.ts.map +1 -1
- package/lib/langium/workspace/langium-documents.js +91 -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 +152 -99
- package/lib/lsp/hydranium-document-update-handler.js.map +1 -1
- package/lib/lsp/index.d.ts +3 -1
- package/lib/lsp/index.d.ts.map +1 -1
- package/lib/lsp/index.js +3 -1
- package/lib/lsp/index.js.map +1 -1
- package/lib/lsp/lsp-latency.d.ts +39 -0
- package/lib/lsp/lsp-latency.d.ts.map +1 -0
- package/lib/lsp/lsp-latency.js +58 -0
- package/lib/lsp/lsp-latency.js.map +1 -0
- package/lib/lsp/semantic-token-provider.d.ts +34 -1
- package/lib/lsp/semantic-token-provider.d.ts.map +1 -1
- package/lib/lsp/semantic-token-provider.js +55 -8
- package/lib/lsp/semantic-token-provider.js.map +1 -1
- package/lib/lsp/shared-module.d.ts +4 -8
- package/lib/lsp/shared-module.d.ts.map +1 -1
- package/lib/lsp/shared-module.js.map +1 -1
- package/lib/lsp/start-language-server.d.ts +8 -7
- package/lib/lsp/start-language-server.d.ts.map +1 -1
- package/lib/lsp/start-language-server.js +13 -7
- package/lib/lsp/start-language-server.js.map +1 -1
- package/lib/messages/carriers.d.ts +54 -0
- package/lib/messages/carriers.d.ts.map +1 -0
- package/lib/messages/carriers.js +62 -0
- package/lib/messages/carriers.js.map +1 -0
- package/lib/messages/index.d.ts +25 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +25 -0
- package/lib/messages/index.js.map +1 -0
- package/lib/messages/renderer.d.ts +142 -0
- package/lib/messages/renderer.d.ts.map +1 -0
- package/lib/messages/renderer.js +165 -0
- package/lib/messages/renderer.js.map +1 -0
- package/lib/node/heap-ceiling.d.ts +61 -0
- package/lib/node/heap-ceiling.d.ts.map +1 -0
- package/lib/node/heap-ceiling.js +72 -0
- package/lib/node/heap-ceiling.js.map +1 -0
- package/lib/node/index.d.ts +1 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +1 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/latency-from-env.d.ts +1 -1
- package/lib/node/latency-from-env.js +1 -1
- package/lib/node/measure-memory.d.ts.map +1 -1
- package/lib/node/measure-memory.js +1 -0
- package/lib/node/measure-memory.js.map +1 -1
- package/lib/node/node-file-system-provider.d.ts +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/profile-capture.d.ts +8 -2
- package/lib/node/profile-capture.d.ts.map +1 -1
- package/lib/node/profile-capture.js.map +1 -1
- package/lib/node/profiling-run.d.ts +2 -2
- package/lib/node/profiling-run.js +1 -1
- package/lib/node/profiling-run.js.map +1 -1
- package/lib/node/rename-over-open-readers.d.ts +52 -0
- package/lib/node/rename-over-open-readers.d.ts.map +1 -0
- package/lib/node/rename-over-open-readers.js +66 -0
- package/lib/node/rename-over-open-readers.js.map +1 -0
- package/lib/node/socket-launcher.d.ts +16 -1
- package/lib/node/socket-launcher.d.ts.map +1 -1
- package/lib/node/socket-launcher.js +4 -3
- package/lib/node/socket-launcher.js.map +1 -1
- package/lib/node/stdio-launcher.d.ts +1 -1
- package/lib/node/stdio-launcher.d.ts.map +1 -1
- package/lib/node/stdio-launcher.js +1 -1
- package/lib/node/stdio-launcher.js.map +1 -1
- package/lib/testing/fake-document.d.ts +16 -4
- package/lib/testing/fake-document.d.ts.map +1 -1
- package/lib/testing/fake-document.js +18 -3
- package/lib/testing/fake-document.js.map +1 -1
- package/lib/testing/make-noop-shared-services.d.ts +14 -0
- package/lib/testing/make-noop-shared-services.d.ts.map +1 -1
- package/lib/testing/make-noop-shared-services.js +28 -2
- package/lib/testing/make-noop-shared-services.js.map +1 -1
- package/lib/testing/make-test-services.d.ts +62 -14
- package/lib/testing/make-test-services.d.ts.map +1 -1
- package/lib/testing/make-test-services.js +30 -9
- package/lib/testing/make-test-services.js.map +1 -1
- package/lib/testing/node/index.d.ts +1 -0
- package/lib/testing/node/index.d.ts.map +1 -1
- package/lib/testing/node/index.js +1 -0
- package/lib/testing/node/index.js.map +1 -1
- package/lib/testing/node/lsp-harness.d.ts.map +1 -1
- package/lib/testing/node/lsp-harness.js +2 -0
- package/lib/testing/node/lsp-harness.js.map +1 -1
- package/lib/testing/node/lsp-server-connection.d.ts +11 -3
- package/lib/testing/node/lsp-server-connection.d.ts.map +1 -1
- package/lib/testing/node/lsp-server-connection.js +42 -9
- package/lib/testing/node/lsp-server-connection.js.map +1 -1
- package/lib/testing/node/scratch-workspace.d.ts.map +1 -1
- package/lib/testing/node/scratch-workspace.js +10 -5
- package/lib/testing/node/scratch-workspace.js.map +1 -1
- package/lib/testing/node/spawned-server.d.ts +14 -0
- package/lib/testing/node/spawned-server.d.ts.map +1 -1
- package/lib/testing/node/spawned-server.js +33 -1
- package/lib/testing/node/spawned-server.js.map +1 -1
- package/lib/testing/node/unhandled-rejections.d.ts +20 -0
- package/lib/testing/node/unhandled-rejections.d.ts.map +1 -0
- package/lib/testing/node/unhandled-rejections.js +32 -0
- package/lib/testing/node/unhandled-rejections.js.map +1 -0
- package/lib/testing/playwright/flaky-network-proxy.d.ts +76 -0
- package/lib/testing/playwright/flaky-network-proxy.d.ts.map +1 -0
- package/lib/testing/playwright/flaky-network-proxy.js +164 -0
- package/lib/testing/playwright/flaky-network-proxy.js.map +1 -0
- package/lib/testing/playwright/index.d.ts +1 -0
- package/lib/testing/playwright/index.d.ts.map +1 -1
- package/lib/testing/playwright/index.js +1 -0
- package/lib/testing/playwright/index.js.map +1 -1
- package/lib/testing/playwright/server-log-capture.d.ts +14 -4
- package/lib/testing/playwright/server-log-capture.d.ts.map +1 -1
- package/lib/testing/playwright/server-log-capture.js +21 -4
- package/lib/testing/playwright/server-log-capture.js.map +1 -1
- package/lib/testing/playwright/server-log-rename-reporter.d.ts.map +1 -1
- package/lib/testing/playwright/server-log-rename-reporter.js +10 -1
- package/lib/testing/playwright/server-log-rename-reporter.js.map +1 -1
- package/lib/testing/run-update-pipeline.d.ts +4 -4
- package/lib/testing/run-update-pipeline.d.ts.map +1 -1
- package/lib/testing/stub-ast-document-manager.d.ts +10 -9
- package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
- package/lib/testing/stub-ast-document-manager.js +17 -9
- package/lib/testing/stub-ast-document-manager.js.map +1 -1
- package/lib/testing/stub-document-builder.d.ts +26 -11
- package/lib/testing/stub-document-builder.d.ts.map +1 -1
- package/lib/testing/stub-document-builder.js +57 -4
- package/lib/testing/stub-document-builder.js.map +1 -1
- package/lib/testing/stub-hydranium-text-documents.d.ts +22 -7
- package/lib/testing/stub-hydranium-text-documents.d.ts.map +1 -1
- package/lib/testing/stub-hydranium-text-documents.js +92 -15
- package/lib/testing/stub-hydranium-text-documents.js.map +1 -1
- package/lib/testing/stub-langium-documents.d.ts +3 -2
- package/lib/testing/stub-langium-documents.d.ts.map +1 -1
- package/lib/testing/stub-langium-documents.js.map +1 -1
- package/lib/testing/stub-model-service.d.ts +7 -6
- package/lib/testing/stub-model-service.d.ts.map +1 -1
- package/lib/testing/stub-model-service.js +4 -4
- package/lib/testing/stub-model-service.js.map +1 -1
- package/lib/util/connection-liveness.d.ts +7 -6
- package/lib/util/connection-liveness.d.ts.map +1 -1
- package/lib/util/connection-liveness.js +35 -14
- package/lib/util/connection-liveness.js.map +1 -1
- package/package.json +17 -8
- package/src/documents/ast-document-manager.ts +348 -64
- 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 +971 -202
- package/src/documents/index.ts +3 -0
- package/src/documents/language-client-text-shadow.ts +59 -11
- package/src/documents/self-save-registry.ts +52 -13
- package/src/index.ts +6 -0
- package/src/langium/ast-extension/ast-node-builder.ts +66 -22
- package/src/langium/bootstrap.ts +16 -9
- package/src/langium/config/configuration-provider.ts +119 -0
- package/src/langium/config/index.ts +1 -0
- package/src/langium/diagnostics/lsp-logger.ts +41 -6
- package/src/langium/document-builder/build-pipeline-integration.ts +50 -5
- package/src/langium/document-builder/build-session.ts +87 -0
- package/src/langium/document-builder/document-builder.ts +724 -46
- 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 +229 -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 +606 -0
- package/src/langium/model-service/index.ts +1 -0
- package/src/langium/model-service/model-service.ts +418 -399
- package/src/langium/module.ts +193 -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 +36 -14
- package/src/langium/scope/hydranium-scope-provider.ts +60 -22
- package/src/langium/serialization/abstract-serializer.ts +13 -32
- package/src/langium/service-registry.ts +19 -2
- package/src/langium/shared-services.ts +19 -2
- package/src/langium/transfer/transfer-encoder.ts +85 -24
- package/src/langium/trivia/comment-preserver.ts +1100 -0
- package/src/langium/trivia/document-ending-preserver.ts +55 -0
- package/src/langium/trivia/index.ts +14 -0
- package/src/langium/trivia/trivia-contribution.ts +39 -0
- package/src/langium/trivia/trivia-preserver.ts +54 -0
- package/src/langium/trivia/trivia-service.ts +99 -0
- package/src/langium/update-rewrite/update-rewrite.ts +1 -1
- package/src/langium/validation/document-validator.ts +537 -11
- package/src/langium/workspace/document-uri-policy.ts +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 +34 -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 +113 -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 +182 -106
- package/src/lsp/index.ts +3 -1
- package/src/lsp/lsp-latency.ts +62 -0
- package/src/lsp/semantic-token-provider.ts +74 -7
- package/src/lsp/shared-module.ts +4 -8
- package/src/lsp/start-language-server.ts +13 -7
- package/src/messages/carriers.ts +78 -0
- package/src/messages/index.ts +36 -0
- package/src/messages/renderer.ts +212 -0
- package/src/node/heap-ceiling.ts +108 -0
- package/src/node/index.ts +1 -0
- package/src/node/latency-from-env.ts +1 -1
- package/src/node/measure-memory.ts +1 -0
- package/src/node/node-file-system-provider.ts +122 -51
- package/src/node/profile-capture.ts +8 -2
- package/src/node/profiling-run.ts +3 -3
- package/src/node/rename-over-open-readers.ts +78 -0
- package/src/node/socket-launcher.ts +19 -4
- package/src/node/stdio-launcher.ts +1 -2
- package/src/testing/fake-document.ts +24 -5
- package/src/testing/make-noop-shared-services.ts +50 -2
- package/src/testing/make-test-services.ts +106 -30
- package/src/testing/node/index.ts +1 -0
- package/src/testing/node/lsp-harness.ts +2 -0
- package/src/testing/node/lsp-server-connection.ts +61 -11
- package/src/testing/node/scratch-workspace.ts +10 -5
- package/src/testing/node/spawned-server.ts +35 -1
- package/src/testing/node/unhandled-rejections.ts +31 -0
- package/src/testing/playwright/flaky-network-proxy.ts +240 -0
- package/src/testing/playwright/index.ts +1 -0
- package/src/testing/playwright/server-log-capture.ts +24 -5
- package/src/testing/playwright/server-log-rename-reporter.ts +12 -1
- package/src/testing/run-update-pipeline.ts +4 -4
- package/src/testing/stub-ast-document-manager.ts +28 -21
- package/src/testing/stub-document-builder.ts +83 -17
- package/src/testing/stub-hydranium-text-documents.ts +127 -22
- package/src/testing/stub-langium-documents.ts +3 -2
- package/src/testing/stub-model-service.ts +9 -8
- package/src/util/connection-liveness.ts +37 -14
- package/lib/lsp/instrument-connection.d.ts +0 -36
- package/lib/lsp/instrument-connection.d.ts.map +0 -1
- package/lib/lsp/instrument-connection.js +0 -62
- package/lib/lsp/instrument-connection.js.map +0 -1
- package/src/lsp/instrument-connection.ts +0 -66
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
-
import { inject, type Module } from '@hydranium/langium';
|
|
10
|
+
import { type DeepPartial, inject, type Module } from '@hydranium/langium';
|
|
11
11
|
import {
|
|
12
12
|
createDefaultModule,
|
|
13
13
|
createDefaultSharedModule,
|
|
@@ -98,6 +98,31 @@ export interface IntegrationServicesOptions<
|
|
|
98
98
|
* it is silently inert.
|
|
99
99
|
*/
|
|
100
100
|
extra?: ReadonlyArray<Module<TShared, PartialLangiumSharedServices>>;
|
|
101
|
+
/**
|
|
102
|
+
* Shared modules composed LAST — after `adopter` — and partial over
|
|
103
|
+
* `TShared` rather than over Langium's shared services.
|
|
104
|
+
*
|
|
105
|
+
* Both differences are the point, and neither is served by
|
|
106
|
+
* {@link extra}. Most framework shared services are constructed with
|
|
107
|
+
* no options (`ModelService: services => new DefaultModelService(services)`),
|
|
108
|
+
* so rebinding the slot is the only way to boot one configured
|
|
109
|
+
* differently; a caller that needs that is usually a test, and the slot
|
|
110
|
+
* it needs is as often a framework ADDITION (`Clock`, `Tracer`,
|
|
111
|
+
* `ProjectManager`) as a Langium one. `extra` can express neither: it
|
|
112
|
+
* is typed `DeepPartial<LangiumSharedServices>`, and it loses to
|
|
113
|
+
* `adopter` on every slot the adopter binds.
|
|
114
|
+
*
|
|
115
|
+
* Kept separate rather than widening `extra` because `extra` is the
|
|
116
|
+
* protocol-head tier, and a head must NOT outrank the adopter. Widening
|
|
117
|
+
* it also does not typecheck — `Module<I, T>` puts `T` in factory
|
|
118
|
+
* return position, so a head module declaring Langium slot types stops
|
|
119
|
+
* being assignable once `T` becomes `DeepPartial<TShared>`.
|
|
120
|
+
*
|
|
121
|
+
* Composing last means an override wins over everything, including the
|
|
122
|
+
* adopter. That is what makes it usable for the slots an adopter binds
|
|
123
|
+
* itself, and why production code should not reach for it.
|
|
124
|
+
*/
|
|
125
|
+
overrides?: ReadonlyArray<Module<TShared, DeepPartial<TShared>>>;
|
|
101
126
|
};
|
|
102
127
|
|
|
103
128
|
/**
|
|
@@ -134,6 +159,23 @@ export interface IntegrationServicesOptions<
|
|
|
134
159
|
* still win over heads.
|
|
135
160
|
*/
|
|
136
161
|
extra?: ReadonlyArray<Module<TLanguage, PartialLangiumServices>>;
|
|
162
|
+
/**
|
|
163
|
+
* Modules composed LAST, after `adopter`, and partial over `TLanguage`
|
|
164
|
+
* rather than over Langium's per-language services. The language-tier
|
|
165
|
+
* twin of {@link IntegrationServicesOptions.sharedModules}'s
|
|
166
|
+
* `overrides`, and both differences carry the same weight they do
|
|
167
|
+
* there.
|
|
168
|
+
*
|
|
169
|
+
* A per-language framework service is constructed by the framework's
|
|
170
|
+
* own module with no options
|
|
171
|
+
* (`IntegrityService: services => new DefaultIntegrityService(services)`),
|
|
172
|
+
* so booting one configured differently means rebinding the slot.
|
|
173
|
+
* {@link extra} serves neither half of that: it composes BEFORE
|
|
174
|
+
* `adopter` and so loses every slot the adopter binds, and it is typed
|
|
175
|
+
* `PartialLangiumServices`, which cannot express a framework ADDITION
|
|
176
|
+
* like `IntegrityService` or `AstExtensionService` at all.
|
|
177
|
+
*/
|
|
178
|
+
overrides?: ReadonlyArray<Module<TLanguage, DeepPartial<TLanguage>>>;
|
|
137
179
|
};
|
|
138
180
|
|
|
139
181
|
/**
|
|
@@ -197,6 +239,8 @@ export interface AdditionalLanguageModules<
|
|
|
197
239
|
adopter?: (shared: TShared) => Module<TLanguage, PartialLangiumServices>;
|
|
198
240
|
/** Protocol-head modules for this language. Defaults to the primary language's. */
|
|
199
241
|
extra?: ReadonlyArray<Module<TLanguage, PartialLangiumServices>>;
|
|
242
|
+
/** Last-composed overrides for this language. Defaults to the primary language's. */
|
|
243
|
+
overrides?: ReadonlyArray<Module<TLanguage, DeepPartial<TLanguage>>>;
|
|
200
244
|
}
|
|
201
245
|
|
|
202
246
|
/**
|
|
@@ -247,7 +291,9 @@ export function createIntegrationServices<
|
|
|
247
291
|
sharedModules.generated,
|
|
248
292
|
sharedModule,
|
|
249
293
|
...(sharedModules.extra ?? []),
|
|
250
|
-
sharedModules.adopter
|
|
294
|
+
sharedModules.adopter,
|
|
295
|
+
// Last, so an override outranks the adopter too — see `overrides`.
|
|
296
|
+
...((sharedModules.overrides ?? []) as ReadonlyArray<Module<TShared, PartialLangiumSharedServices>>)
|
|
251
297
|
) as unknown as TShared;
|
|
252
298
|
|
|
253
299
|
// Each language gets its OWN `createDefaultModule({ shared })` — the
|
|
@@ -256,19 +302,34 @@ export function createIntegrationServices<
|
|
|
256
302
|
const composeLanguage = (
|
|
257
303
|
generated: Module<TLanguage, PartialLangiumServices>,
|
|
258
304
|
adopter: (shared: TShared) => Module<TLanguage, PartialLangiumServices>,
|
|
259
|
-
extra: ReadonlyArray<Module<TLanguage, PartialLangiumServices
|
|
305
|
+
extra: ReadonlyArray<Module<TLanguage, PartialLangiumServices>>,
|
|
306
|
+
overrides: ReadonlyArray<Module<TLanguage, DeepPartial<TLanguage>>>
|
|
260
307
|
): TLanguage => {
|
|
261
308
|
const defaultLanguageModule = createDefaultModule({ shared }) as unknown as Module<TLanguage, PartialLangiumServices>;
|
|
262
309
|
const serverLanguageModule = createServerLanguageModule(context) as unknown as Module<TLanguage, PartialLangiumServices>;
|
|
263
|
-
return inject(
|
|
310
|
+
return inject(
|
|
311
|
+
defaultLanguageModule,
|
|
312
|
+
generated,
|
|
313
|
+
serverLanguageModule,
|
|
314
|
+
...extra,
|
|
315
|
+
adopter(shared),
|
|
316
|
+
// Last, so an override outranks the adopter too — see `overrides`.
|
|
317
|
+
...(overrides as ReadonlyArray<Module<TLanguage, PartialLangiumServices>>)
|
|
318
|
+
) as unknown as TLanguage;
|
|
264
319
|
};
|
|
265
320
|
|
|
266
321
|
const primaryExtra = (languageModules.extra ?? []) as ReadonlyArray<Module<TLanguage, PartialLangiumServices>>;
|
|
267
|
-
const
|
|
322
|
+
const primaryOverrides = languageModules.overrides ?? [];
|
|
323
|
+
const language = composeLanguage(languageModules.generated, languageModules.adopter, primaryExtra, primaryOverrides);
|
|
268
324
|
const languages = [
|
|
269
325
|
language,
|
|
270
326
|
...additionalLanguages.map(additional =>
|
|
271
|
-
composeLanguage(
|
|
327
|
+
composeLanguage(
|
|
328
|
+
additional.generated,
|
|
329
|
+
additional.adopter ?? languageModules.adopter,
|
|
330
|
+
additional.extra ?? primaryExtra,
|
|
331
|
+
additional.overrides ?? primaryOverrides
|
|
332
|
+
)
|
|
272
333
|
)
|
|
273
334
|
];
|
|
274
335
|
|
|
@@ -49,14 +49,22 @@ export namespace IntegrityPhase {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
/**
|
|
52
|
-
* Controls how integrity corrections are persisted for
|
|
53
|
-
* mode does not reach
|
|
54
|
-
*
|
|
52
|
+
* Controls how integrity corrections are persisted for files no editor holds.
|
|
53
|
+
* The mode does not reach a file open in the language client: the correction
|
|
54
|
+
* is delivered to the editor, which shows it as an unsaved change.
|
|
55
55
|
*
|
|
56
|
-
* - `silent`: write to disk immediately; no editor involvement.
|
|
56
|
+
* - `silent`: write to disk immediately; no editor involvement. For a file
|
|
57
|
+
* held only through the data or GLSP head, only while disk still holds the
|
|
58
|
+
* text the correction was computed from and the text store still holds the
|
|
59
|
+
* correction. Otherwise — the holder has unsaved edits, disk changed behind
|
|
60
|
+
* the server, or disk cannot be read — the correction waits in the text
|
|
61
|
+
* store for the next save.
|
|
57
62
|
* - `editor`: open the file dirty via `applyEdit`. If the user closes without
|
|
58
63
|
* saving, the correction is suppressed until the file changes or the
|
|
59
|
-
* workspace reloads.
|
|
64
|
+
* workspace reloads. A file held only through the data or GLSP head gets
|
|
65
|
+
* neither: the correction stays in the text store, and since those heads
|
|
66
|
+
* mark only their own edits unsaved, nothing shows that store and disk
|
|
67
|
+
* differ until a save or the last close.
|
|
60
68
|
*/
|
|
61
69
|
export type IntegritySyncMode = 'silent' | 'editor';
|
|
62
70
|
|
|
@@ -8,8 +8,16 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
10
|
import { isPromiseLike, Logger, type ProfileSession, type Tracer } from '@hydranium/protocol';
|
|
11
|
-
import {
|
|
12
|
-
|
|
11
|
+
import {
|
|
12
|
+
type AstNode,
|
|
13
|
+
AstUtils,
|
|
14
|
+
DocumentState,
|
|
15
|
+
interruptAndCheck,
|
|
16
|
+
isOperationCancelled,
|
|
17
|
+
type LangiumDocument,
|
|
18
|
+
UriUtils
|
|
19
|
+
} from '@hydranium/langium';
|
|
20
|
+
import { CancellationToken, type Disposable } from 'vscode-languageserver';
|
|
13
21
|
import { type HydraniumDocumentBuilder } from '../document-builder/document-builder.js';
|
|
14
22
|
import { type TextDocument } from 'vscode-languageserver-textdocument';
|
|
15
23
|
import { type WritableFileSystemProvider } from '../../documents/ast-document-manager.js';
|
|
@@ -17,6 +25,7 @@ import { type LogNameOptions } from '../diagnostics/logger.js';
|
|
|
17
25
|
import { type HydraniumTextDocuments } from '../../documents/hydranium-text-documents.js';
|
|
18
26
|
import { Registry } from '../../util/registry.js';
|
|
19
27
|
import { type ServerLanguageServices } from '../language-module.js';
|
|
28
|
+
import { isVirtualUri } from '../workspace/virtual-document.js';
|
|
20
29
|
import { type IntegrityRuleRegistry } from './integrity-contribution.js';
|
|
21
30
|
import { IntegrityPhase, type IntegrityRule, type IntegritySyncMode } from './integrity-rule.js';
|
|
22
31
|
|
|
@@ -75,6 +84,11 @@ export namespace IntegrityService {
|
|
|
75
84
|
* at `DocumentState.Validated` and delivered separately via `publishDiagnostics`
|
|
76
85
|
* or the `onModelUpdated` event.
|
|
77
86
|
*
|
|
87
|
+
* The AST is what this guarantees, not the text. For a closed document whose
|
|
88
|
+
* repair was STAGED rather than written (`'editor'` sync mode),
|
|
89
|
+
* `textDocument` still mirrors disk — read the repair off the AST, or from
|
|
90
|
+
* the staged content the next open consumes.
|
|
91
|
+
*
|
|
78
92
|
* Invariant: integrity rules only register at Parsed or Linked, so the build
|
|
79
93
|
* is guaranteed post-integrity once it advances past `onBuildPhase(Linked)`
|
|
80
94
|
* into `IndexedReferences`. {@link IntegrityService.register} enforces this at
|
|
@@ -194,7 +208,8 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
|
|
|
194
208
|
const changed = await this.enforceIntegrity(document, phase, cancelToken, session);
|
|
195
209
|
if (changed) {
|
|
196
210
|
mutatedCount++;
|
|
197
|
-
|
|
211
|
+
// Not cancellable: see `resyncDocument`.
|
|
212
|
+
await this.resyncDocument(document, CancellationToken.None);
|
|
198
213
|
}
|
|
199
214
|
await interruptAndCheck(cancelToken);
|
|
200
215
|
}
|
|
@@ -255,8 +270,10 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
|
|
|
255
270
|
* full rule sweep) — coarser than per (node × rule) to avoid a microtask
|
|
256
271
|
* per inner iteration, finer than per-document so a long-running rule set
|
|
257
272
|
* on a large file can still interrupt mid-stream. Throws
|
|
258
|
-
* `OperationCancelled` when the token is cancelled
|
|
259
|
-
* pipeline absorbs the throw at the lock-holder.
|
|
273
|
+
* `OperationCancelled` when the token is cancelled before any rule mutated
|
|
274
|
+
* the AST; Langium's build pipeline absorbs the throw at the lock-holder.
|
|
275
|
+
* After a mutation it stops the sweep and returns `true` instead, so the
|
|
276
|
+
* caller can resync what was mutated before the cancellation unwinds.
|
|
260
277
|
*/
|
|
261
278
|
async enforceIntegrity(
|
|
262
279
|
document: LangiumDocument,
|
|
@@ -290,7 +307,14 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
|
|
|
290
307
|
}
|
|
291
308
|
}
|
|
292
309
|
if (cancelToken !== undefined) {
|
|
293
|
-
|
|
310
|
+
try {
|
|
311
|
+
await interruptAndCheck(cancelToken);
|
|
312
|
+
} catch (err: unknown) {
|
|
313
|
+
if (changed && isOperationCancelled(err)) {
|
|
314
|
+
return true;
|
|
315
|
+
}
|
|
316
|
+
throw err;
|
|
317
|
+
}
|
|
294
318
|
}
|
|
295
319
|
}
|
|
296
320
|
return changed;
|
|
@@ -300,34 +324,129 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
|
|
|
300
324
|
* Re-serialise the document text after AST mutations, propagate corrections,
|
|
301
325
|
* and re-parse at Parsed phase (safe because linking hasn't occurred yet).
|
|
302
326
|
*
|
|
303
|
-
*
|
|
304
|
-
*
|
|
305
|
-
*
|
|
306
|
-
* a natural interruption point.
|
|
327
|
+
* Runs to the end whatever `cancelToken` says: the AST is already mutated,
|
|
328
|
+
* and skipping the resync leaves it against unchanged text that the next
|
|
329
|
+
* build does not re-parse. `cancelToken` reaches only the re-parse.
|
|
307
330
|
*/
|
|
308
331
|
protected async resyncDocument(document: LangiumDocument, cancelToken?: CancellationToken): Promise<void> {
|
|
309
|
-
if (cancelToken?.isCancellationRequested) {
|
|
310
|
-
return;
|
|
311
|
-
}
|
|
312
332
|
const root = document.parseResult.value as TRoot;
|
|
313
|
-
|
|
333
|
+
// Extracted while `document` still holds the text being replaced — the
|
|
334
|
+
// resync that follows overwrites it with `newText`. Absent on a test
|
|
335
|
+
// stub that binds no trivia group; `createServerLanguageModule` always
|
|
336
|
+
// provides it, and an empty registry is already the no-op.
|
|
337
|
+
const trivia = this.services.trivia?.TriviaService;
|
|
338
|
+
const extracted = trivia?.extract(document);
|
|
339
|
+
const serialized = await this.services.serializer.Serializer.serializeAst(root);
|
|
340
|
+
const newText =
|
|
341
|
+
extracted === undefined ? serialized : trivia!.apply(serialized, extracted, UriUtils.toUri(document.textDocument.uri));
|
|
314
342
|
|
|
315
343
|
const oldText = document.textDocument.getText();
|
|
316
344
|
if (oldText === newText) {
|
|
317
345
|
return;
|
|
318
346
|
}
|
|
319
347
|
|
|
320
|
-
|
|
321
|
-
//
|
|
322
|
-
//
|
|
323
|
-
|
|
348
|
+
const version = document.textDocument.version;
|
|
349
|
+
// Commit into the store's own document when the URI is open there, rather
|
|
350
|
+
// than into whichever text-document object this build is holding. The two
|
|
351
|
+
// are the same on the LSP path and are NOT when the document was built for
|
|
352
|
+
// an already-open URI through `fromString`: repairing only the build's copy
|
|
353
|
+
// leaves the store — the server's authority on what an open document says —
|
|
354
|
+
// on the unrepaired text, and the reconciling re-parse then redefines
|
|
355
|
+
// `textDocument` onto the store's object and discards the repair with it.
|
|
356
|
+
//
|
|
357
|
+
// Compared against the CST's own text, not against `document.textDocument`.
|
|
358
|
+
// That object IS the store's on the LSP path, so asking it whether the
|
|
359
|
+
// store still agrees compares the store with itself and can only ever say
|
|
360
|
+
// yes — the guard would be vacuous exactly where an editor race can happen.
|
|
361
|
+
// The CST's `fullText` is the text that actually produced this AST, which
|
|
362
|
+
// is the only thing a repair derived from it is valid against. A document
|
|
363
|
+
// with no CST (built from a model rather than parsed) has no better answer
|
|
364
|
+
// than the text it is carrying.
|
|
365
|
+
const parsedFrom = document.parseResult.value.$cstNode?.root.fullText ?? oldText;
|
|
366
|
+
const commit = this.textDocuments.commitRepair(document.textDocument.uri, parsedFrom, newText);
|
|
367
|
+
if (commit.status === 'stale') {
|
|
368
|
+
// An edit landed after the parse this repair came from, so the repair
|
|
369
|
+
// describes text the store has already replaced. Abandon it rather than
|
|
370
|
+
// hand it to `syncCorrections`: an override that persists from there
|
|
371
|
+
// would write a correction over the edit that superseded it. That edit
|
|
372
|
+
// drives a build of its own, which re-runs these rules against what the
|
|
373
|
+
// document actually says.
|
|
374
|
+
//
|
|
375
|
+
// Abandoning the WRITE is only half of it. The build carries on to its
|
|
376
|
+
// settled phase with whatever AST is registered, and every settled
|
|
377
|
+
// consumer reads that AST rather than the store — so leaving the rule's
|
|
378
|
+
// mutation in place would answer questions about this document from a
|
|
379
|
+
// parse of text nobody has. Reconciling discards it by re-reading the
|
|
380
|
+
// store, which is what the document now has to agree with.
|
|
381
|
+
await this.reconcileDocument(document, cancelToken);
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
// A committed repair is a new version; a document no client has open keeps
|
|
386
|
+
// its number here, and the re-versioning below moves it once the build
|
|
387
|
+
// has reconciled. Through the store's `update`, so the `instanceof
|
|
388
|
+
// FullTextDocument` gate in the bare `TextDocument.update` does not trip
|
|
389
|
+
// on adopter-custom text-document types.
|
|
390
|
+
const textDocument =
|
|
391
|
+
commit.status === 'committed' ? commit.document : this.textDocuments.update(document.textDocument, [{ text: newText }], version);
|
|
324
392
|
|
|
325
|
-
await this.syncCorrections(textDocument);
|
|
393
|
+
await this.syncCorrections(textDocument, parsedFrom);
|
|
326
394
|
|
|
395
|
+
await this.reconcileDocument(document, cancelToken);
|
|
396
|
+
|
|
397
|
+
// Re-version against the REPAIRED text, after either branch. The repair is
|
|
398
|
+
// a content change the store has not seen: whatever reconciliation ran
|
|
399
|
+
// during the re-parse saw the text on disk, which in `'editor'` sync mode
|
|
400
|
+
// is the PRE-repair text. Leave the sequence describing that and the next
|
|
401
|
+
// open hashes the repair, finds a mismatch and steps the version again, so
|
|
402
|
+
// every based-on version taken from this build is stale before it is used.
|
|
403
|
+
// Falls back to the pre-re-parse number for a URI the store never tracked,
|
|
404
|
+
// where there is no sequence to advance; an OPEN document answers
|
|
405
|
+
// `undefined` and keeps the store's own version, which is not this
|
|
406
|
+
// method's to move.
|
|
407
|
+
//
|
|
408
|
+
// Deliberately NOT gated on cancellation, unlike the entry to this method:
|
|
409
|
+
// `syncCorrections` has already written or staged the repair by now, so a
|
|
410
|
+
// preempted build that skipped this would leave the sequence describing
|
|
411
|
+
// text that is no longer there.
|
|
412
|
+
//
|
|
413
|
+
// Gated on the document being closed, because the fallback restores a
|
|
414
|
+
// number this method captured off whatever object it started with — and
|
|
415
|
+
// for a separately created document that is its own seeded numbering, not
|
|
416
|
+
// the store's. Applying it to the store's document (which the re-parse has
|
|
417
|
+
// by then made `textDocument`) would roll the shared version backwards.
|
|
418
|
+
// The store's own answer for an open document is `undefined` either way.
|
|
419
|
+
if (!this.textDocuments.isOpen(document.textDocument.uri)) {
|
|
420
|
+
const reconciled = this.textDocuments.reconcileExternalContent(document.textDocument.uri, newText) ?? version;
|
|
421
|
+
if (document.textDocument.version !== reconciled) {
|
|
422
|
+
this.textDocuments.update(document.textDocument, [], reconciled);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Bring `document` back into agreement with the text it is supposed to
|
|
429
|
+
* describe, after a rule has mutated its AST.
|
|
430
|
+
*
|
|
431
|
+
* Used for a correction that was applied and for one that was abandoned,
|
|
432
|
+
* because the document is left inconsistent either way: applied, the text
|
|
433
|
+
* moved under the CST; abandoned, the AST carries a mutation the text never
|
|
434
|
+
* had. Both are the same question — re-read and re-derive — and the phase is
|
|
435
|
+
* what decides how far that has to go.
|
|
436
|
+
*/
|
|
437
|
+
protected async reconcileDocument(document: LangiumDocument, cancelToken?: CancellationToken): Promise<void> {
|
|
327
438
|
if (document.state <= DocumentState.Parsed) {
|
|
328
439
|
// Parsed-phase correction: re-parse only. The build pipeline still runs
|
|
329
440
|
// IndexedContent → ComputedScopes → Linked → … on the fresh AST afterwards,
|
|
330
441
|
// so the document reconciles naturally with no extra work here.
|
|
442
|
+
//
|
|
443
|
+
// Except for a closed document whose repair did not reach disk — `'editor'`
|
|
444
|
+
// sync mode stages it instead of writing it — where the re-parse is SKIPPED:
|
|
445
|
+
// Langium's factory gates the parse on the CST's `fullText`, which still
|
|
446
|
+
// equals the disk text the same call re-reads and redefines `textDocument`
|
|
447
|
+
// over. So `document.textDocument` is NOT post-integrity for such a
|
|
448
|
+
// document — it mirrors disk, and the AST is the only place the repair is
|
|
449
|
+
// legible, until an open consumes the staging.
|
|
331
450
|
await this.documentBuilder.reparse(document, cancelToken);
|
|
332
451
|
} else {
|
|
333
452
|
// Linked-phase (or later) correction. The rule mutated the AST in place but
|
|
@@ -347,27 +466,66 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
|
|
|
347
466
|
* already in the synced store (in-place in {@link resyncDocument}); this
|
|
348
467
|
* method routes the out-of-band part by document registration:
|
|
349
468
|
*
|
|
350
|
-
* - **Open in the language client** → nothing to push here. The AST
|
|
351
|
-
* rode the current build, so `ModelService.syncToLanguageClient`
|
|
352
|
-
* persistent integrity-settled listener) mirrors
|
|
353
|
-
*
|
|
354
|
-
*
|
|
469
|
+
* - **Open in the language client** → nothing to push here. The AST
|
|
470
|
+
* mutation rode the current build, so `ModelService.syncToLanguageClient`
|
|
471
|
+
* (the persistent integrity-settled listener) mirrors it to the client by
|
|
472
|
+
* *content* (shadow diff), and the editor shows it as an unsaved change.
|
|
473
|
+
* - **Held only through the data or GLSP head**, or waiting out the revert
|
|
474
|
+
* grace after its last client's connection was lost → the store is the
|
|
475
|
+
* authority, and those heads read the correction from the settled build.
|
|
476
|
+
* In silent mode it is also written to disk when the text it was computed
|
|
477
|
+
* from is what disk holds, since the repair is then the only difference;
|
|
478
|
+
* otherwise it waits for the next save. Editor mode always waits, and the
|
|
479
|
+
* repair leaves the document dirty until a save.
|
|
355
480
|
* - **Closed, silent mode** → write to disk directly (disk is authoritative).
|
|
356
481
|
* - **Closed, editor mode** → stage so the next open picks it up via applyEdit.
|
|
482
|
+
*
|
|
483
|
+
* A held URI is not closed. Writing it as one persists the holder's unsaved
|
|
484
|
+
* edits with the repair, and staging it leaves text no open reads, because
|
|
485
|
+
* only a first open consumes the stage.
|
|
486
|
+
*
|
|
487
|
+
* `parsedFrom` is the text the repaired AST was parsed from. Without it a
|
|
488
|
+
* held URI's repair is left to the next save.
|
|
357
489
|
*/
|
|
358
|
-
protected async syncCorrections(document: TextDocument): Promise<void> {
|
|
359
|
-
//
|
|
360
|
-
//
|
|
361
|
-
//
|
|
362
|
-
// open under a symlinked path still answers `true`.
|
|
490
|
+
protected async syncCorrections(document: TextDocument, parsedFrom?: string): Promise<void> {
|
|
491
|
+
// Only the open/closed question is asked, so no reverse address
|
|
492
|
+
// resolution is needed: a file open under a symlinked path still answers
|
|
493
|
+
// `true`.
|
|
363
494
|
if (this.textDocuments.isOpenInLanguageClient(document.uri)) {
|
|
364
495
|
return;
|
|
365
496
|
}
|
|
366
497
|
|
|
498
|
+
// A virtual document has no disk backing, so neither persisting nor
|
|
499
|
+
// staging applies: there is no file to write and no editor that could open
|
|
500
|
+
// one. `URI.fsPath` yields a path for any scheme, so handing this to the
|
|
501
|
+
// provider would address `<cwd>/<contributor>/<name>` — an unrelated
|
|
502
|
+
// location a disk-backed provider refuses outright, turning a repair that
|
|
503
|
+
// was never persistable into a build failure. The correction is already on
|
|
504
|
+
// the AST and in the text store, which is the whole of where a virtual
|
|
505
|
+
// document lives, so there is nothing further to propagate.
|
|
506
|
+
if (isVirtualUri(document.uri)) {
|
|
507
|
+
this.tracer.with(document.uri).debug('Virtual document: correction kept in memory, nothing to persist');
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
// A document waiting out the revert grace still holds its lost client's
|
|
512
|
+
// unsaved text, so writing it as a closed file would persist that text.
|
|
513
|
+
if (this.textDocuments.isOpenInAnyClient(document.uri) || this.textDocuments.isRevertPending(document.uri)) {
|
|
514
|
+
if (this.syncMode === 'silent' && parsedFrom !== undefined) {
|
|
515
|
+
await this.persistIfDiskMatches(document, parsedFrom);
|
|
516
|
+
}
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
|
|
367
520
|
// Closed files, silent mode: write to disk directly.
|
|
368
521
|
if (this.syncMode === 'silent') {
|
|
522
|
+
const repaired = document.getText();
|
|
369
523
|
// Async write so the integrity pass does not block the event loop on a slow filesystem.
|
|
370
|
-
|
|
524
|
+
// In the file's task queue, behind any save already queued: written
|
|
525
|
+
// beside one, the older repair can land last and stay on disk.
|
|
526
|
+
await this.services.shared.workspace.FileSystemTaskQueue.enqueue(document.uri, () =>
|
|
527
|
+
this.fileSystemProvider.writeFile(UriUtils.toUri(document.uri), repaired)
|
|
528
|
+
);
|
|
371
529
|
return;
|
|
372
530
|
}
|
|
373
531
|
|
|
@@ -375,6 +533,47 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
|
|
|
375
533
|
this.textDocuments.stagePendingContent(document.uri, document.getText());
|
|
376
534
|
}
|
|
377
535
|
|
|
536
|
+
/**
|
|
537
|
+
* Write the repair in `document` to disk when disk still holds `parsedFrom`,
|
|
538
|
+
* the text the repair was computed from — so the write carries the repair
|
|
539
|
+
* and nothing a holder could still discard.
|
|
540
|
+
*
|
|
541
|
+
* The read, the compare and the write run as one task in the file's task
|
|
542
|
+
* queue, so no save of the file lands between them. The store is compared
|
|
543
|
+
* again once the read returns, and the write is skipped if it no longer
|
|
544
|
+
* holds the repair: an edit does not wait for the queue, and writing the
|
|
545
|
+
* older repair then puts text on disk that no participant holds. The
|
|
546
|
+
* skipped repair loses nothing: the edit drives a build of its own, and a
|
|
547
|
+
* save writes the store's text. A file that cannot be read is left alone
|
|
548
|
+
* too: there is no evidence it matches.
|
|
549
|
+
*/
|
|
550
|
+
protected async persistIfDiskMatches(document: TextDocument, parsedFrom: string): Promise<void> {
|
|
551
|
+
const uri = UriUtils.toUri(document.uri);
|
|
552
|
+
const repaired = document.getText();
|
|
553
|
+
await this.services.shared.workspace.FileSystemTaskQueue.enqueue(document.uri, async () => {
|
|
554
|
+
let onDisk: string;
|
|
555
|
+
try {
|
|
556
|
+
onDisk = await this.fileSystemProvider.readFile(uri);
|
|
557
|
+
} catch (error: unknown) {
|
|
558
|
+
this.tracer.with(document.uri).debug(`Held document unreadable on disk, repair left to the next save: ${String(error)}`);
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
// The file itself, not the store's disk baseline: the baseline moves
|
|
562
|
+
// only when the server hears of a change, so it can still hold the
|
|
563
|
+
// parsed text after another process rewrote the file and before the
|
|
564
|
+
// watcher reports it, and this write would then replace that change.
|
|
565
|
+
if (onDisk !== parsedFrom) {
|
|
566
|
+
return;
|
|
567
|
+
}
|
|
568
|
+
if (this.textDocuments.get(document.uri)?.getText() !== repaired) {
|
|
569
|
+
this.tracer.with(document.uri).debug('Held document changed while disk was read, repair left to that change');
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
await this.fileSystemProvider.writeFile(uri, repaired);
|
|
573
|
+
this.textDocuments.updateDiskBaseline(document.uri, repaired);
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
|
|
378
577
|
/**
|
|
379
578
|
* Format a rule's name for inclusion in user-facing diagnostic strings
|
|
380
579
|
* (error messages thrown during registration). Defaults to
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (c) 2026 CrossBreeze, EclipseSource and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the MIT License which is available in the project root.
|
|
6
|
+
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
********************************************************************************/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Containment-array maintenance for callers that build or delete AST nodes
|
|
12
|
+
* programmatically — a GLSP operation handler being the usual one.
|
|
13
|
+
*
|
|
14
|
+
* **These live beside the key provider because the constraint is the key
|
|
15
|
+
* provider's.** `NameBasedKeyProvider` keys a node the `NameProvider` gives no
|
|
16
|
+
* name from its position, as `` `${$containerProperty}@${$containerIndex}` ``,
|
|
17
|
+
* so a node appended with a bare `array.push` carries neither and
|
|
18
|
+
* `getElementKey` answers `undefined` — the element has no key at all, and the
|
|
19
|
+
* GLSP index cannot address it. Deleting from the middle of such a list must
|
|
20
|
+
* renumber the survivors, or an id derived later in the same command names the
|
|
21
|
+
* wrong node. Shipping the constraint's statement without the code that
|
|
22
|
+
* discharges it leaves every adopter in that position re-deriving thirty lines
|
|
23
|
+
* from prose, and both failures are silent.
|
|
24
|
+
*
|
|
25
|
+
* The population is narrower than "anyone creating elements from a diagram": it
|
|
26
|
+
* takes a grammar with UNNAMED element types, programmatic creation or deletion
|
|
27
|
+
* of them, and this key provider. A grammar whose diagram elements are all
|
|
28
|
+
* named never reaches it, and the two ways out are named on the provider —
|
|
29
|
+
* give the type a name, or bind a provider whose fallback is content-derived.
|
|
30
|
+
*
|
|
31
|
+
* **Free functions, and deliberately not a step on the AST builder.** Building a
|
|
32
|
+
* node detached and appending it later is legitimate, so a containment step
|
|
33
|
+
* cannot be mandatory; and an optional fluent step could not check the index
|
|
34
|
+
* against the array unless it were handed the array, at which point it is these
|
|
35
|
+
* signatures with more ceremony. `AstNodeInit` already accepts the three fields
|
|
36
|
+
* for a caller who has them, which is the case these cover: it is the INDEX that
|
|
37
|
+
* cannot be known without reading the array.
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
import type { AstNode } from '@hydranium/langium';
|
|
41
|
+
import type { Mutable } from '@hydranium/protocol';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Append `child` to `children`, stamping the Langium containment plumbing
|
|
45
|
+
* (`$container`, `$containerProperty`, `$containerIndex`) so a positional key
|
|
46
|
+
* can address it.
|
|
47
|
+
*
|
|
48
|
+
* `property` and `children` are separate parameters rather than one property
|
|
49
|
+
* name the function dereferences: the array is what the index is derived from,
|
|
50
|
+
* so taking it directly is what makes the two agree by construction instead of
|
|
51
|
+
* by a lookup that a typo could point elsewhere.
|
|
52
|
+
*
|
|
53
|
+
* @returns `child`, so a caller can append and use it in one expression.
|
|
54
|
+
*/
|
|
55
|
+
export function appendChild<TChild extends AstNode>(container: AstNode, property: string, children: TChild[], child: TChild): TChild {
|
|
56
|
+
const mutable = child as Mutable<TChild>;
|
|
57
|
+
mutable.$container = container;
|
|
58
|
+
mutable.$containerProperty = property;
|
|
59
|
+
mutable.$containerIndex = children.length;
|
|
60
|
+
children.push(child);
|
|
61
|
+
return child;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Remove every entry of `children` that is in `toRemove`, then renumber the
|
|
66
|
+
* survivors' `$containerIndex`.
|
|
67
|
+
*
|
|
68
|
+
* Mutates `children` in place rather than returning a new array, because the
|
|
69
|
+
* caller's array IS the AST's containment list — replacing the reference would
|
|
70
|
+
* leave the parent pointing at the old one.
|
|
71
|
+
*
|
|
72
|
+
* @returns how many entries were removed, so a caller can tell a no-op delete
|
|
73
|
+
* from one that changed the model without comparing lengths itself.
|
|
74
|
+
*/
|
|
75
|
+
export function removeChildren<TChild extends AstNode>(children: TChild[], toRemove: ReadonlySet<TChild>): number {
|
|
76
|
+
if (toRemove.size === 0) {
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
const survivors = children.filter(child => !toRemove.has(child));
|
|
80
|
+
const removed = children.length - survivors.length;
|
|
81
|
+
children.length = 0;
|
|
82
|
+
for (const [index, child] of survivors.entries()) {
|
|
83
|
+
(child as Mutable<TChild>).$containerIndex = index;
|
|
84
|
+
children.push(child);
|
|
85
|
+
}
|
|
86
|
+
return removed;
|
|
87
|
+
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
+
export * from './containment.js';
|
|
10
11
|
export * from './element-key-provider.js';
|
|
11
12
|
export * from './name-based-key-provider.js';
|
|
12
13
|
export * from './positional-key-provider.js';
|
|
@@ -55,6 +55,10 @@ import { type NameProvider } from '../naming/name-provider.js';
|
|
|
55
55
|
* - After a removal, surviving siblings need their `$containerIndex`
|
|
56
56
|
* renumbered, or a key derived afterwards addresses the wrong node.
|
|
57
57
|
*
|
|
58
|
+
* {@link appendChild} and {@link removeChildren} discharge both, and ship
|
|
59
|
+
* beside this provider because the constraint is this provider's rather than
|
|
60
|
+
* any caller's.
|
|
61
|
+
*
|
|
58
62
|
* Adopters that need insert / delete stability for unnamed types should
|
|
59
63
|
* give those types a name in the grammar, or bind a key provider whose
|
|
60
64
|
* fallback is content-derived rather than positional.
|