@hydranium/core 1.0.0-next.11 → 1.0.0-next.111
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/lib/documents/ast-document-manager.d.ts +75 -16
- package/lib/documents/ast-document-manager.d.ts.map +1 -1
- package/lib/documents/ast-document-manager.js +57 -19
- 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/hydranium-text-documents.d.ts +124 -36
- package/lib/documents/hydranium-text-documents.d.ts.map +1 -1
- package/lib/documents/hydranium-text-documents.js +191 -51
- package/lib/documents/hydranium-text-documents.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 +150 -7
- package/lib/langium/document-builder/document-builder.d.ts.map +1 -1
- package/lib/langium/document-builder/document-builder.js +298 -11
- 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-service.d.ts +16 -0
- package/lib/langium/integrity/integrity-service.d.ts.map +1 -1
- package/lib/langium/integrity/integrity-service.js +110 -2
- 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 +25 -0
- package/lib/langium/language-module.d.ts.map +1 -1
- package/lib/langium/language-module.js +14 -0
- package/lib/langium/language-module.js.map +1 -1
- package/lib/langium/model-service/model-service.d.ts +161 -10
- package/lib/langium/model-service/model-service.d.ts.map +1 -1
- package/lib/langium/model-service/model-service.js +174 -95
- package/lib/langium/model-service/model-service.js.map +1 -1
- package/lib/langium/module.d.ts +84 -15
- package/lib/langium/module.d.ts.map +1 -1
- package/lib/langium/module.js +26 -12
- package/lib/langium/module.js.map +1 -1
- package/lib/langium/naming/name-provider.d.ts +25 -4
- package/lib/langium/naming/name-provider.d.ts.map +1 -1
- package/lib/langium/naming/name-provider.js +2 -1
- package/lib/langium/naming/name-provider.js.map +1 -1
- package/lib/langium/naming/name-separator-validation.d.ts +23 -0
- package/lib/langium/naming/name-separator-validation.d.ts.map +1 -1
- package/lib/langium/naming/name-separator-validation.js +30 -1
- package/lib/langium/naming/name-separator-validation.js.map +1 -1
- package/lib/langium/residency/cst-residency-service.d.ts +31 -11
- package/lib/langium/residency/cst-residency-service.d.ts.map +1 -1
- package/lib/langium/residency/cst-residency-service.js +13 -56
- package/lib/langium/residency/cst-residency-service.js.map +1 -1
- package/lib/langium/scope/hydranium-scope-provider.d.ts +48 -13
- package/lib/langium/scope/hydranium-scope-provider.d.ts.map +1 -1
- package/lib/langium/scope/hydranium-scope-provider.js +56 -20
- package/lib/langium/scope/hydranium-scope-provider.js.map +1 -1
- package/lib/langium/serialization/abstract-serializer.d.ts +11 -20
- package/lib/langium/serialization/abstract-serializer.d.ts.map +1 -1
- package/lib/langium/serialization/abstract-serializer.js +12 -21
- package/lib/langium/serialization/abstract-serializer.js.map +1 -1
- package/lib/langium/service-registry.d.ts +15 -1
- package/lib/langium/service-registry.d.ts.map +1 -1
- package/lib/langium/service-registry.js +16 -0
- package/lib/langium/service-registry.js.map +1 -1
- package/lib/langium/shared-services.d.ts +15 -2
- package/lib/langium/shared-services.d.ts.map +1 -1
- package/lib/langium/shared-services.js.map +1 -1
- package/lib/langium/transfer/transfer-encoder.d.ts +60 -17
- package/lib/langium/transfer/transfer-encoder.d.ts.map +1 -1
- package/lib/langium/transfer/transfer-encoder.js +38 -16
- package/lib/langium/transfer/transfer-encoder.js.map +1 -1
- package/lib/langium/trivia/comment-preserver.d.ts +423 -0
- package/lib/langium/trivia/comment-preserver.d.ts.map +1 -0
- package/lib/langium/trivia/comment-preserver.js +906 -0
- package/lib/langium/trivia/comment-preserver.js.map +1 -0
- package/lib/langium/trivia/document-ending-preserver.d.ts +43 -0
- package/lib/langium/trivia/document-ending-preserver.d.ts.map +1 -0
- package/lib/langium/trivia/document-ending-preserver.js +48 -0
- package/lib/langium/trivia/document-ending-preserver.js.map +1 -0
- package/lib/langium/trivia/index.d.ts +14 -0
- package/lib/langium/trivia/index.d.ts.map +1 -0
- package/lib/langium/trivia/index.js +14 -0
- package/lib/langium/trivia/index.js.map +1 -0
- package/lib/langium/trivia/trivia-contribution.d.ts +37 -0
- package/lib/langium/trivia/trivia-contribution.d.ts.map +1 -0
- package/lib/langium/trivia/trivia-contribution.js +10 -0
- package/lib/langium/trivia/trivia-contribution.js.map +1 -0
- package/lib/langium/trivia/trivia-preserver.d.ts +50 -0
- package/lib/langium/trivia/trivia-preserver.d.ts.map +1 -0
- package/lib/langium/trivia/trivia-preserver.js +10 -0
- package/lib/langium/trivia/trivia-preserver.js.map +1 -0
- package/lib/langium/trivia/trivia-service.d.ts +70 -0
- package/lib/langium/trivia/trivia-service.d.ts.map +1 -0
- package/lib/langium/trivia/trivia-service.js +56 -0
- package/lib/langium/trivia/trivia-service.js.map +1 -0
- package/lib/langium/validation/document-validator.d.ts +294 -10
- package/lib/langium/validation/document-validator.d.ts.map +1 -1
- package/lib/langium/validation/document-validator.js +448 -5
- package/lib/langium/validation/document-validator.js.map +1 -1
- package/lib/langium/workspace/document-uri-policy.d.ts +3 -4
- package/lib/langium/workspace/document-uri-policy.d.ts.map +1 -1
- package/lib/langium/workspace/document-uri-policy.js +3 -4
- package/lib/langium/workspace/document-uri-policy.js.map +1 -1
- package/lib/langium/workspace/file-system-provider.d.ts +9 -1
- package/lib/langium/workspace/file-system-provider.d.ts.map +1 -1
- package/lib/langium/workspace/file-system-provider.js +40 -7
- package/lib/langium/workspace/file-system-provider.js.map +1 -1
- package/lib/langium/workspace/hydranium-langium-document-factory.d.ts +25 -0
- package/lib/langium/workspace/hydranium-langium-document-factory.d.ts.map +1 -1
- package/lib/langium/workspace/hydranium-langium-document-factory.js +25 -0
- package/lib/langium/workspace/hydranium-langium-document-factory.js.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-manager.d.ts +21 -1
- package/lib/langium/workspace/hydranium-workspace-manager.d.ts.map +1 -1
- package/lib/langium/workspace/hydranium-workspace-manager.js +28 -0
- package/lib/langium/workspace/hydranium-workspace-manager.js.map +1 -1
- package/lib/langium/workspace/in-memory-file-system-provider.d.ts +23 -0
- package/lib/langium/workspace/in-memory-file-system-provider.d.ts.map +1 -1
- package/lib/langium/workspace/in-memory-file-system-provider.js +47 -9
- package/lib/langium/workspace/in-memory-file-system-provider.js.map +1 -1
- package/lib/langium/workspace/initialize-workspace.d.ts +23 -2
- package/lib/langium/workspace/initialize-workspace.d.ts.map +1 -1
- package/lib/langium/workspace/initialize-workspace.js +13 -5
- package/lib/langium/workspace/initialize-workspace.js.map +1 -1
- package/lib/langium/workspace/langium-documents.d.ts +79 -17
- package/lib/langium/workspace/langium-documents.d.ts.map +1 -1
- package/lib/langium/workspace/langium-documents.js +83 -28
- package/lib/langium/workspace/langium-documents.js.map +1 -1
- package/lib/langium/workspace/virtual-document.d.ts +18 -3
- package/lib/langium/workspace/virtual-document.d.ts.map +1 -1
- package/lib/langium/workspace/virtual-document.js +19 -2
- package/lib/langium/workspace/virtual-document.js.map +1 -1
- package/lib/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.map +1 -1
- package/lib/lsp/hydranium-document-update-handler.js +10 -1
- 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/start-language-server.d.ts +5 -3
- package/lib/lsp/start-language-server.d.ts.map +1 -1
- package/lib/lsp/start-language-server.js +10 -3
- 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 +136 -0
- package/lib/messages/renderer.d.ts.map +1 -0
- package/lib/messages/renderer.js +159 -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/node-file-system-provider.d.ts +35 -1
- package/lib/node/node-file-system-provider.d.ts.map +1 -1
- package/lib/node/node-file-system-provider.js +140 -45
- package/lib/node/node-file-system-provider.js.map +1 -1
- package/lib/node/profile-capture.d.ts +8 -2
- package/lib/node/profile-capture.d.ts.map +1 -1
- package/lib/node/profile-capture.js.map +1 -1
- package/lib/node/profiling-run.d.ts +2 -2
- package/lib/node/profiling-run.js +1 -1
- package/lib/node/profiling-run.js.map +1 -1
- package/lib/node/rename-over-open-readers.d.ts +52 -0
- package/lib/node/rename-over-open-readers.d.ts.map +1 -0
- package/lib/node/rename-over-open-readers.js +66 -0
- package/lib/node/rename-over-open-readers.js.map +1 -0
- package/lib/node/socket-launcher.d.ts +15 -0
- package/lib/node/socket-launcher.d.ts.map +1 -1
- package/lib/node/socket-launcher.js +3 -2
- package/lib/node/socket-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 +45 -9
- package/lib/testing/make-test-services.d.ts.map +1 -1
- package/lib/testing/make-test-services.js +19 -3
- 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-server-connection.d.ts.map +1 -1
- package/lib/testing/node/lsp-server-connection.js +5 -6
- 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 +9 -4
- 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/stub-ast-document-manager.d.ts +5 -5
- package/lib/testing/stub-ast-document-manager.d.ts.map +1 -1
- package/lib/testing/stub-ast-document-manager.js +4 -6
- package/lib/testing/stub-ast-document-manager.js.map +1 -1
- package/lib/testing/stub-document-builder.d.ts +8 -0
- package/lib/testing/stub-document-builder.d.ts.map +1 -1
- package/lib/testing/stub-document-builder.js +22 -3
- package/lib/testing/stub-document-builder.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 +5 -4
- package/lib/testing/stub-model-service.d.ts.map +1 -1
- package/lib/testing/stub-model-service.js +2 -2
- 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 +129 -36
- package/src/documents/client-ids.ts +5 -22
- package/src/documents/hydranium-text-documents.ts +248 -75
- 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 +339 -11
- package/src/langium/document-builder/index.ts +1 -0
- package/src/langium/integration-services.ts +67 -6
- package/src/langium/integrity/integrity-service.ts +116 -2
- 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 +38 -0
- package/src/langium/model-service/model-service.ts +264 -32
- package/src/langium/module.ts +106 -21
- package/src/langium/naming/name-provider.ts +27 -5
- package/src/langium/naming/name-separator-validation.ts +34 -5
- package/src/langium/residency/cst-residency-service.ts +36 -14
- package/src/langium/scope/hydranium-scope-provider.ts +60 -22
- package/src/langium/serialization/abstract-serializer.ts +13 -32
- package/src/langium/service-registry.ts +19 -2
- package/src/langium/shared-services.ts +19 -2
- package/src/langium/transfer/transfer-encoder.ts +85 -24
- package/src/langium/trivia/comment-preserver.ts +1100 -0
- package/src/langium/trivia/document-ending-preserver.ts +55 -0
- package/src/langium/trivia/index.ts +14 -0
- package/src/langium/trivia/trivia-contribution.ts +39 -0
- package/src/langium/trivia/trivia-preserver.ts +54 -0
- package/src/langium/trivia/trivia-service.ts +99 -0
- package/src/langium/validation/document-validator.ts +537 -11
- package/src/langium/workspace/document-uri-policy.ts +3 -4
- package/src/langium/workspace/file-system-provider.ts +48 -8
- package/src/langium/workspace/hydranium-langium-document-factory.ts +34 -0
- package/src/langium/workspace/hydranium-workspace-manager.ts +30 -1
- package/src/langium/workspace/in-memory-file-system-provider.ts +53 -10
- package/src/langium/workspace/initialize-workspace.ts +35 -5
- package/src/langium/workspace/langium-documents.ts +106 -33
- package/src/langium/workspace/virtual-document.ts +21 -3
- package/src/locale/index.ts +10 -0
- package/src/locale/server-locale.ts +86 -0
- package/src/lsp/completion/hydranium-completion-provider.ts +82 -2
- package/src/lsp/connection-features.ts +67 -0
- package/src/lsp/diagnostics-connection.ts +56 -0
- package/src/lsp/hydranium-document-update-handler.ts +10 -1
- 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/start-language-server.ts +10 -3
- package/src/messages/carriers.ts +78 -0
- package/src/messages/index.ts +36 -0
- package/src/messages/renderer.ts +206 -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/node-file-system-provider.ts +154 -47
- package/src/node/profile-capture.ts +8 -2
- package/src/node/profiling-run.ts +3 -3
- package/src/node/rename-over-open-readers.ts +78 -0
- package/src/node/socket-launcher.ts +18 -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 +74 -18
- package/src/testing/node/index.ts +1 -0
- package/src/testing/node/lsp-server-connection.ts +5 -6
- package/src/testing/node/scratch-workspace.ts +9 -4
- 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/stub-ast-document-manager.ts +10 -14
- package/src/testing/stub-document-builder.ts +32 -3
- package/src/testing/stub-langium-documents.ts +3 -2
- package/src/testing/stub-model-service.ts +7 -6
- 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
|
|
|
@@ -17,6 +17,7 @@ import { type LogNameOptions } from '../diagnostics/logger.js';
|
|
|
17
17
|
import { type HydraniumTextDocuments } from '../../documents/hydranium-text-documents.js';
|
|
18
18
|
import { Registry } from '../../util/registry.js';
|
|
19
19
|
import { type ServerLanguageServices } from '../language-module.js';
|
|
20
|
+
import { isVirtualUri } from '../workspace/virtual-document.js';
|
|
20
21
|
import { type IntegrityRuleRegistry } from './integrity-contribution.js';
|
|
21
22
|
import { IntegrityPhase, type IntegrityRule, type IntegritySyncMode } from './integrity-rule.js';
|
|
22
23
|
|
|
@@ -75,6 +76,11 @@ export namespace IntegrityService {
|
|
|
75
76
|
* at `DocumentState.Validated` and delivered separately via `publishDiagnostics`
|
|
76
77
|
* or the `onModelUpdated` event.
|
|
77
78
|
*
|
|
79
|
+
* The AST is what this guarantees, not the text. For a closed document whose
|
|
80
|
+
* repair was STAGED rather than written (`'editor'` sync mode),
|
|
81
|
+
* `textDocument` still mirrors disk — read the repair off the AST, or from
|
|
82
|
+
* the staged content the next open consumes.
|
|
83
|
+
*
|
|
78
84
|
* Invariant: integrity rules only register at Parsed or Linked, so the build
|
|
79
85
|
* is guaranteed post-integrity once it advances past `onBuildPhase(Linked)`
|
|
80
86
|
* into `IndexedReferences`. {@link IntegrityService.register} enforces this at
|
|
@@ -310,24 +316,119 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
|
|
|
310
316
|
return;
|
|
311
317
|
}
|
|
312
318
|
const root = document.parseResult.value as TRoot;
|
|
313
|
-
|
|
319
|
+
// Extracted while `document` still holds the text being replaced — the
|
|
320
|
+
// resync that follows overwrites it with `newText`. Absent on a test
|
|
321
|
+
// stub that binds no trivia group; `createServerLanguageModule` always
|
|
322
|
+
// provides it, and an empty registry is already the no-op.
|
|
323
|
+
const trivia = this.services.trivia?.TriviaService;
|
|
324
|
+
const extracted = trivia?.extract(document);
|
|
325
|
+
const serialized = await this.services.serializer.Serializer.serializeAst(root);
|
|
326
|
+
const newText =
|
|
327
|
+
extracted === undefined ? serialized : trivia!.apply(serialized, extracted, UriUtils.toUri(document.textDocument.uri));
|
|
314
328
|
|
|
315
329
|
const oldText = document.textDocument.getText();
|
|
316
330
|
if (oldText === newText) {
|
|
317
331
|
return;
|
|
318
332
|
}
|
|
319
333
|
|
|
334
|
+
const version = document.textDocument.version;
|
|
335
|
+
// Commit into the store's own document when the URI is open there, rather
|
|
336
|
+
// than into whichever text-document object this build is holding. The two
|
|
337
|
+
// are the same on the LSP path and are NOT when the document was built for
|
|
338
|
+
// an already-open URI through `fromString`: repairing only the build's copy
|
|
339
|
+
// leaves the store — the server's authority on what an open document says —
|
|
340
|
+
// on the unrepaired text, and the reconciling re-parse then redefines
|
|
341
|
+
// `textDocument` onto the store's object and discards the repair with it.
|
|
342
|
+
//
|
|
343
|
+
// Compared against the CST's own text, not against `document.textDocument`.
|
|
344
|
+
// That object IS the store's on the LSP path, so asking it whether the
|
|
345
|
+
// store still agrees compares the store with itself and can only ever say
|
|
346
|
+
// yes — the guard would be vacuous exactly where an editor race can happen.
|
|
347
|
+
// The CST's `fullText` is the text that actually produced this AST, which
|
|
348
|
+
// is the only thing a repair derived from it is valid against. A document
|
|
349
|
+
// with no CST (built from a model rather than parsed) has no better answer
|
|
350
|
+
// than the text it is carrying.
|
|
351
|
+
const parsedFrom = document.parseResult.value.$cstNode?.root.fullText ?? oldText;
|
|
352
|
+
const commit = this.textDocuments.commitRepair(document.textDocument.uri, parsedFrom, newText);
|
|
353
|
+
if (commit.status === 'stale') {
|
|
354
|
+
// An edit landed after the parse this repair came from, so the repair
|
|
355
|
+
// describes text the store has already replaced. Abandon it rather than
|
|
356
|
+
// persist or stage it: that edit drives a build of its own, which
|
|
357
|
+
// re-runs these rules against what the document actually says.
|
|
358
|
+
//
|
|
359
|
+
// Abandoning the WRITE is only half of it. The build carries on to its
|
|
360
|
+
// settled phase with whatever AST is registered, and every settled
|
|
361
|
+
// consumer reads that AST rather than the store — so leaving the rule's
|
|
362
|
+
// mutation in place would answer questions about this document from a
|
|
363
|
+
// parse of text nobody has. Reconciling discards it by re-reading the
|
|
364
|
+
// store, which is what the document now has to agree with.
|
|
365
|
+
await this.reconcileDocument(document, cancelToken);
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
|
|
320
369
|
// Keep the same version so HydraniumTextDocuments doesn't reject subsequent client edits.
|
|
321
370
|
// Use manager.update so the `instanceof FullTextDocument` gate in the bare
|
|
322
371
|
// `TextDocument.update` doesn't trip on adopter-custom text-document types.
|
|
323
|
-
const textDocument =
|
|
372
|
+
const textDocument =
|
|
373
|
+
commit.status === 'committed' ? commit.document : this.textDocuments.update(document.textDocument, [{ text: newText }], version);
|
|
324
374
|
|
|
325
375
|
await this.syncCorrections(textDocument);
|
|
326
376
|
|
|
377
|
+
await this.reconcileDocument(document, cancelToken);
|
|
378
|
+
|
|
379
|
+
// Re-version against the REPAIRED text, after either branch. The repair is
|
|
380
|
+
// a content change the store has not seen: whatever reconciliation ran
|
|
381
|
+
// during the re-parse saw the text on disk, which in `'editor'` sync mode
|
|
382
|
+
// is the PRE-repair text. Leave the sequence describing that and the next
|
|
383
|
+
// open hashes the repair, finds a mismatch and steps the version again, so
|
|
384
|
+
// every based-on version taken from this build is stale before it is used.
|
|
385
|
+
// Falls back to the pre-re-parse number for a URI the store never tracked,
|
|
386
|
+
// where there is no sequence to advance; an OPEN document answers
|
|
387
|
+
// `undefined` and keeps the store's own version, which is not this
|
|
388
|
+
// method's to move.
|
|
389
|
+
//
|
|
390
|
+
// Deliberately NOT gated on cancellation, unlike the entry to this method:
|
|
391
|
+
// `syncCorrections` has already written or staged the repair by now, so a
|
|
392
|
+
// preempted build that skipped this would leave the sequence describing
|
|
393
|
+
// text that is no longer there.
|
|
394
|
+
//
|
|
395
|
+
// Gated on the document being closed, because the fallback restores a
|
|
396
|
+
// number this method captured off whatever object it started with — and
|
|
397
|
+
// for a separately created document that is its own seeded numbering, not
|
|
398
|
+
// the store's. Applying it to the store's document (which the re-parse has
|
|
399
|
+
// by then made `textDocument`) would roll the shared version backwards.
|
|
400
|
+
// The store's own answer for an open document is `undefined` either way.
|
|
401
|
+
if (!this.textDocuments.isOpen(document.textDocument.uri)) {
|
|
402
|
+
const reconciled = this.textDocuments.reconcileExternalContent(document.textDocument.uri, newText) ?? version;
|
|
403
|
+
if (document.textDocument.version !== reconciled) {
|
|
404
|
+
this.textDocuments.update(document.textDocument, [], reconciled);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/**
|
|
410
|
+
* Bring `document` back into agreement with the text it is supposed to
|
|
411
|
+
* describe, after a rule has mutated its AST.
|
|
412
|
+
*
|
|
413
|
+
* Used for a correction that was applied and for one that was abandoned,
|
|
414
|
+
* because the document is left inconsistent either way: applied, the text
|
|
415
|
+
* moved under the CST; abandoned, the AST carries a mutation the text never
|
|
416
|
+
* had. Both are the same question — re-read and re-derive — and the phase is
|
|
417
|
+
* what decides how far that has to go.
|
|
418
|
+
*/
|
|
419
|
+
protected async reconcileDocument(document: LangiumDocument, cancelToken?: CancellationToken): Promise<void> {
|
|
327
420
|
if (document.state <= DocumentState.Parsed) {
|
|
328
421
|
// Parsed-phase correction: re-parse only. The build pipeline still runs
|
|
329
422
|
// IndexedContent → ComputedScopes → Linked → … on the fresh AST afterwards,
|
|
330
423
|
// so the document reconciles naturally with no extra work here.
|
|
424
|
+
//
|
|
425
|
+
// Except for a closed document whose repair did not reach disk — `'editor'`
|
|
426
|
+
// sync mode stages it instead of writing it — where the re-parse is SKIPPED:
|
|
427
|
+
// Langium's factory gates the parse on the CST's `fullText`, which still
|
|
428
|
+
// equals the disk text the same call re-reads and redefines `textDocument`
|
|
429
|
+
// over. So `document.textDocument` is NOT post-integrity for such a
|
|
430
|
+
// document — it mirrors disk, and the AST is the only place the repair is
|
|
431
|
+
// legible, until an open consumes the staging.
|
|
331
432
|
await this.documentBuilder.reparse(document, cancelToken);
|
|
332
433
|
} else {
|
|
333
434
|
// Linked-phase (or later) correction. The rule mutated the AST in place but
|
|
@@ -364,6 +465,19 @@ export class DefaultIntegrityService<TRoot extends AstNode = AstNode> implements
|
|
|
364
465
|
return;
|
|
365
466
|
}
|
|
366
467
|
|
|
468
|
+
// A virtual document has no disk backing, so neither persisting nor
|
|
469
|
+
// staging applies: there is no file to write and no editor that could open
|
|
470
|
+
// one. `URI.fsPath` yields a path for any scheme, so handing this to the
|
|
471
|
+
// provider would address `<cwd>/<contributor>/<name>` — an unrelated
|
|
472
|
+
// location a disk-backed provider refuses outright, turning a repair that
|
|
473
|
+
// was never persistable into a build failure. The correction is already on
|
|
474
|
+
// the AST and in the text store, which is the whole of where a virtual
|
|
475
|
+
// document lives, so there is nothing further to propagate.
|
|
476
|
+
if (isVirtualUri(document.uri)) {
|
|
477
|
+
this.tracer.with(document.uri).debug('Virtual document: correction kept in memory, nothing to persist');
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
|
|
367
481
|
// Closed files, silent mode: write to disk directly.
|
|
368
482
|
if (this.syncMode === 'silent') {
|
|
369
483
|
// Async write so the integrity pass does not block the event loop on a slow filesystem.
|
|
@@ -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.
|
|
@@ -28,6 +28,10 @@ import { DefaultReferenceBuilder, type ReferenceBuilder } from './scope/referenc
|
|
|
28
28
|
import { type ScopeExtensionContribution } from './scope/scope-extension-contribution.js';
|
|
29
29
|
import { DefaultScopeExtensionService, type ScopeExtensionService } from './scope/scope-extension-service.js';
|
|
30
30
|
import { type Serializer } from './serialization/serializer.js';
|
|
31
|
+
import { type TriviaContribution } from './trivia/trivia-contribution.js';
|
|
32
|
+
import { type TriviaService, DefaultTriviaService } from './trivia/trivia-service.js';
|
|
33
|
+
import { CommentPreserverContribution } from './trivia/comment-preserver.js';
|
|
34
|
+
import { DocumentEndingPreserverContribution } from './trivia/document-ending-preserver.js';
|
|
31
35
|
import { type UpdateRewriteContribution } from './update-rewrite/update-rewrite-contribution.js';
|
|
32
36
|
import { DefaultUpdateRewriteService, type UpdateRewriteService } from './update-rewrite/update-rewrite-service.js';
|
|
33
37
|
import { HydraniumDocumentValidator } from './validation/document-validator.js';
|
|
@@ -181,6 +185,29 @@ export interface ServerAddedServices {
|
|
|
181
185
|
*/
|
|
182
186
|
rules: Record<string, IntegrityRuleContribution>;
|
|
183
187
|
};
|
|
188
|
+
trivia: {
|
|
189
|
+
/**
|
|
190
|
+
* Runs the registered trivia preservers around a write, so what a
|
|
191
|
+
* document carries that its model does not — its comments, the whitespace
|
|
192
|
+
* it ended with — survives being re-serialized from that model.
|
|
193
|
+
*
|
|
194
|
+
* A separate group from {@link Serializer} because a preserver needs the
|
|
195
|
+
* document being overwritten, which a serializer is never given:
|
|
196
|
+
* `serializeAst` could reach one through its model, but
|
|
197
|
+
* `serializeTransfer` receives a plain wire object with no document at
|
|
198
|
+
* all, so folding this in would carry trivia on one write path and
|
|
199
|
+
* silently not on the other.
|
|
200
|
+
*/
|
|
201
|
+
TriviaService: TriviaService;
|
|
202
|
+
/**
|
|
203
|
+
* Declarative {@link TriviaContribution} group. Distinct sub-keys
|
|
204
|
+
* accumulate across framework + adopter modules via Langium's deep-merge;
|
|
205
|
+
* binding one the framework already uses REPLACES it. The framework ships
|
|
206
|
+
* a sub-key per preserver, so an adopter replacing `comments` keeps
|
|
207
|
+
* `documentEnding` and whatever else ships beside it.
|
|
208
|
+
*/
|
|
209
|
+
preservers: Record<string, TriviaContribution>;
|
|
210
|
+
};
|
|
184
211
|
updateRewrite: {
|
|
185
212
|
/**
|
|
186
213
|
* Per-language runner for transfer-model rewrites applied on the
|
|
@@ -334,6 +361,17 @@ export function createServerLanguageModule(
|
|
|
334
361
|
serializer: {
|
|
335
362
|
Serializer: () => new UnboundSerializer()
|
|
336
363
|
},
|
|
364
|
+
// Bound with a sub-key per preserver so an adopter can replace one and
|
|
365
|
+
// keep the other. Adopters MUST avoid these two keys for their own
|
|
366
|
+
// contributions unless replacement is what they mean — Langium's
|
|
367
|
+
// deep-merge is last-wins on same-key leaves.
|
|
368
|
+
trivia: {
|
|
369
|
+
TriviaService: services => new DefaultTriviaService(services),
|
|
370
|
+
preservers: {
|
|
371
|
+
comments: services => new CommentPreserverContribution(services),
|
|
372
|
+
documentEnding: () => new DocumentEndingPreserverContribution()
|
|
373
|
+
}
|
|
374
|
+
},
|
|
337
375
|
// The per-URI serialise / re-parse path only fires when a rule mutates,
|
|
338
376
|
// so the no-op default is safe even before adopters bind a real
|
|
339
377
|
// serializer / parser.
|