@hydranium/core 1.0.0-next.25 → 1.0.0-next.28
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/langium/integration-services.d.ts +26 -1
- package/lib/langium/integration-services.d.ts.map +1 -1
- package/lib/langium/integration-services.js +3 -1
- package/lib/langium/integration-services.js.map +1 -1
- package/lib/langium/naming/name-separator-validation.d.ts +1 -0
- package/lib/langium/naming/name-separator-validation.d.ts.map +1 -1
- package/lib/langium/naming/name-separator-validation.js +8 -1
- package/lib/langium/naming/name-separator-validation.js.map +1 -1
- package/lib/langium/transfer/transfer-encoder.d.ts +4 -1
- package/lib/langium/transfer/transfer-encoder.d.ts.map +1 -1
- package/lib/langium/transfer/transfer-encoder.js +13 -2
- package/lib/langium/transfer/transfer-encoder.js.map +1 -1
- package/lib/langium/workspace/in-memory-file-system-provider.d.ts +8 -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 +11 -2
- package/lib/langium/workspace/in-memory-file-system-provider.js.map +1 -1
- package/lib/langium/workspace/langium-documents.d.ts +9 -0
- package/lib/langium/workspace/langium-documents.d.ts.map +1 -1
- package/lib/langium/workspace/langium-documents.js +11 -1
- package/lib/langium/workspace/langium-documents.js.map +1 -1
- package/lib/messages/carriers.d.ts +46 -0
- package/lib/messages/carriers.d.ts.map +1 -0
- package/lib/messages/carriers.js +51 -0
- package/lib/messages/carriers.js.map +1 -0
- package/lib/messages/index.d.ts +22 -0
- package/lib/messages/index.d.ts.map +1 -0
- package/lib/messages/index.js +22 -0
- package/lib/messages/index.js.map +1 -0
- package/package.json +13 -5
- package/src/langium/integration-services.ts +29 -2
- package/src/langium/naming/name-separator-validation.ts +12 -5
- package/src/langium/transfer/transfer-encoder.ts +13 -2
- package/src/langium/workspace/in-memory-file-system-provider.ts +13 -3
- package/src/langium/workspace/langium-documents.ts +12 -1
- package/src/messages/carriers.ts +68 -0
- package/src/messages/index.ts +24 -0
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
-
import { type Module } from '@hydranium/langium';
|
|
9
|
+
import { type DeepPartial, type Module } from '@hydranium/langium';
|
|
10
10
|
import { type LangiumServices, type LangiumSharedServices, type PartialLangiumServices, type PartialLangiumSharedServices } from '@hydranium/langium/lsp';
|
|
11
11
|
import { type ServerModuleContext } from './module.js';
|
|
12
12
|
import type { ServerSharedServicesMinimal } from './shared-services.js';
|
|
@@ -82,6 +82,31 @@ export interface IntegrationServicesOptions<TContext extends ServerModuleContext
|
|
|
82
82
|
* it is silently inert.
|
|
83
83
|
*/
|
|
84
84
|
extra?: ReadonlyArray<Module<TShared, PartialLangiumSharedServices>>;
|
|
85
|
+
/**
|
|
86
|
+
* Shared modules composed LAST — after `adopter` — and partial over
|
|
87
|
+
* `TShared` rather than over Langium's shared services.
|
|
88
|
+
*
|
|
89
|
+
* Both differences are the point, and neither is served by
|
|
90
|
+
* {@link extra}. Most framework shared services are constructed with
|
|
91
|
+
* no options (`ModelService: services => new ModelService(services)`),
|
|
92
|
+
* so rebinding the slot is the only way to boot one configured
|
|
93
|
+
* differently; a caller that needs that is usually a test, and the slot
|
|
94
|
+
* it needs is as often a framework ADDITION (`Clock`, `Tracer`,
|
|
95
|
+
* `ProjectManager`) as a Langium one. `extra` can express neither: it
|
|
96
|
+
* is typed `DeepPartial<LangiumSharedServices>`, and it loses to
|
|
97
|
+
* `adopter` on every slot the adopter binds.
|
|
98
|
+
*
|
|
99
|
+
* Kept separate rather than widening `extra` because `extra` is the
|
|
100
|
+
* protocol-head tier, and a head must NOT outrank the adopter. Widening
|
|
101
|
+
* it also does not typecheck — `Module<I, T>` puts `T` in factory
|
|
102
|
+
* return position, so a head module declaring Langium slot types stops
|
|
103
|
+
* being assignable once `T` becomes `DeepPartial<TShared>`.
|
|
104
|
+
*
|
|
105
|
+
* Composing last means an override wins over everything, including the
|
|
106
|
+
* adopter. That is what makes it usable for the slots an adopter binds
|
|
107
|
+
* itself, and why production code should not reach for it.
|
|
108
|
+
*/
|
|
109
|
+
overrides?: ReadonlyArray<Module<TShared, DeepPartial<TShared>>>;
|
|
85
110
|
};
|
|
86
111
|
/**
|
|
87
112
|
* Language-services module trio: generated, adopter, and optional
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-services.d.ts","sourceRoot":"","sources":["../../src/langium/integration-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAU,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"integration-services.d.ts","sourceRoot":"","sources":["../../src/langium/integration-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,WAAW,EAAU,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EAGJ,KAAK,eAAe,EACpB,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,4BAA4B,EACnC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAA4B,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACjF,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,sBAAsB,CAAC;AAExE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,0BAA0B,CACxC,QAAQ,SAAS,mBAAmB,EACpC,OAAO,SAAS,qBAAqB,GAAG,2BAA2B,EACnE,SAAS,SAAS,eAAe;IAEjC;;;;;;;;;OASG;IACH,OAAO,EAAE,QAAQ,CAAC;IAElB;;;;;;;;;OASG;IACH,aAAa,EAAE;QACZ;;;;;;;;;;;;;;WAcG;QACH,SAAS,EAAE,MAAM,CAAC,OAAO,EAAE,4BAA4B,CAAC,CAAC;QACzD,kGAAkG;QAClG,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,4BAA4B,CAAC,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E,sBAAsB,CAAC,CAAC,CAAC;CACnE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,yBAAyB,CACtC,QAAQ,SAAS,mBAAmB,EACpC,OAAO,SAAS,qBAAqB,GAAG,2BAA2B,EACnE,SAAS,SAAS,eAAe,EAEjC,OAAO,EAAE,0BAA0B,CAAC,QAAQ,EAAE,OAAO,EAAE,SAAS,CAAC,GACjE;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,QAAQ,EAAE,SAAS,CAAC;IAAC,SAAS,EAAE,aAAa,CAAC,SAAS,CAAC,CAAA;CAAE,CA0D/E"}
|
|
@@ -41,7 +41,9 @@ export function createIntegrationServices(options) {
|
|
|
41
41
|
// every adopter doesn't repeat it.
|
|
42
42
|
const sharedModule = createServerSharedModule(context);
|
|
43
43
|
const defaultSharedModule = createDefaultSharedModule(context);
|
|
44
|
-
const shared = inject(defaultSharedModule, sharedModules.generated, sharedModule, ...(sharedModules.extra ?? []), sharedModules.adopter
|
|
44
|
+
const shared = inject(defaultSharedModule, sharedModules.generated, sharedModule, ...(sharedModules.extra ?? []), sharedModules.adopter,
|
|
45
|
+
// Last, so an override outranks the adopter too — see `overrides`.
|
|
46
|
+
...(sharedModules.overrides ?? []));
|
|
45
47
|
// Each language gets its OWN `createDefaultModule({ shared })` — the
|
|
46
48
|
// baseline module is per-language state (parser, lexer, linker), so it
|
|
47
49
|
// cannot be shared between the grammars even though `shared` is.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integration-services.js","sourceRoot":"","sources":["../../src/langium/integration-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,
|
|
1
|
+
{"version":3,"file":"integration-services.js","sourceRoot":"","sources":["../../src/langium/integration-services.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAoB,MAAM,EAAe,MAAM,oBAAoB,CAAC;AAC3E,OAAO,EACJ,mBAAmB,EACnB,yBAAyB,EAK3B,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,MAAM,CAAC,CAAyB,CAAC;IAC5H,CAAC,CAAC;IAEF,MAAM,YAAY,GAAG,CAAC,eAAe,CAAC,KAAK,IAAI,EAAE,CAA6D,CAAC;IAC/G,MAAM,QAAQ,GAAG,eAAe,CAAC,eAAe,CAAC,SAAS,EAAE,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACnG,MAAM,SAAS,GAAG;QACf,QAAQ;QACR,GAAG,mBAAmB,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CACrC,eAAe,CAAC,UAAU,CAAC,SAAS,EAAE,UAAU,CAAC,OAAO,IAAI,eAAe,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,IAAI,YAAY,CAAC,CACxH;KACH,CAAC;IAEF,mEAAmE;IACnE,gEAAgE;IAChE,mCAAmC;IACnC,yBAAyB,CAAC,MAAM,EAAE,SAAS,EAAE,0BAA0B,CAAC,CAAC;IAEzE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;AAC1C,CAAC"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { type AstNode, type ValidationAcceptor } from '@hydranium/langium';
|
|
10
|
+
export declare const SEPARATOR_IN_NAME: import("@hydranium/protocol").MessageDefinition<"Name '{name}' contains the configured name separator '{separator}', which is reserved for qualified-name composition — use a different character.">;
|
|
10
11
|
import { type ServerLanguageServices } from '../language-module.js';
|
|
11
12
|
import { type ValidationCheckContribution, type ValidationCheckRegistry } from '../validation/validation-contribution.js';
|
|
12
13
|
import type { NameProvider } from './name-provider.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name-separator-validation.d.ts","sourceRoot":"","sources":["../../../src/langium/naming/name-separator-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,kBAAkB,EAAyB,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"name-separator-validation.d.ts","sourceRoot":"","sources":["../../../src/langium/naming/name-separator-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,kBAAkB,EAAyB,MAAM,oBAAoB,CAAC;AAIlG,eAAO,MAAM,iBAAiB,sMAG7B,CAAC;AACF,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,KAAK,2BAA2B,EAAE,KAAK,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAC1H,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAelH;AAED;;;;;;;;;GASG;AACH,qBAAa,8BAA+B,YAAW,2BAA2B;IAC/E,SAAS,CAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;gBAElC,QAAQ,EAAE,sBAAsB;IAI5C,wBAAwB,CAAC,QAAQ,EAAE,uBAAuB,GAAG,IAAI;CAMnE"}
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
+
import { defineMessage } from '@hydranium/protocol';
|
|
10
|
+
import { acceptMessage } from '../../messages/carriers.js';
|
|
11
|
+
export const SEPARATOR_IN_NAME = defineMessage('hydranium/core/separator-in-name', "Name '{name}' contains the configured name separator '{separator}', which is reserved for qualified-name composition — use a different character.");
|
|
9
12
|
/**
|
|
10
13
|
* Per-node validation check: flag name-bearing AST nodes whose name
|
|
11
14
|
* value contains the configured name separator. Such values produce
|
|
@@ -32,7 +35,11 @@ export function nameSeparatorCheck(nameProvider) {
|
|
|
32
35
|
}
|
|
33
36
|
const separator = nameProvider.nameSeparator;
|
|
34
37
|
if (ownName.includes(separator)) {
|
|
35
|
-
|
|
38
|
+
// `{ node }` rather than `{ node, property: 'name' }`: moving the
|
|
39
|
+
// squiggle onto the name property is a behaviour change to the one
|
|
40
|
+
// diagnostic every adopter receives by default, so it is decided on its
|
|
41
|
+
// own merits rather than carried in by a mechanical migration.
|
|
42
|
+
acceptMessage(accept, 'error', SEPARATOR_IN_NAME, { node }, { name: ownName, separator });
|
|
36
43
|
}
|
|
37
44
|
};
|
|
38
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"name-separator-validation.js","sourceRoot":"","sources":["../../../src/langium/naming/name-separator-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;
|
|
1
|
+
{"version":3,"file":"name-separator-validation.js","sourceRoot":"","sources":["../../../src/langium/naming/name-separator-validation.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAGlF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAE3D,MAAM,CAAC,MAAM,iBAAiB,GAAG,aAAa,CAC3C,kCAAkC,EAClC,mJAAmJ,CACrJ,CAAC;AAKF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,kBAAkB,CAAC,YAA0B;IAC1D,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE;QACrB,MAAM,OAAO,GAAG,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvD,OAAO;QACV,CAAC;QACD,MAAM,SAAS,GAAG,YAAY,CAAC,aAAa,CAAC;QAC7C,IAAI,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC;YAC/B,kEAAkE;YAClE,mEAAmE;YACnE,wEAAwE;YACxE,+DAA+D;YAC/D,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,iBAAiB,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC,CAAC;QAC7F,CAAC;IACJ,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,OAAO,8BAA8B;IACrB,YAAY,CAAe;IAE9C,YAAY,QAAgC;QACzC,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,UAAU,CAAC,YAAY,CAAC;IACxD,CAAC;IAED,wBAAwB,CAAC,QAAiC;QACvD,MAAM,MAAM,GAA2C;YACpD,OAAO,EAAE,kBAAkB,CAAC,IAAI,CAAC,YAAY,CAAC;SAChD,CAAC;QACF,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;CACH"}
|
|
@@ -275,7 +275,10 @@ export declare class TransferEncoder<TTransferMap = Record<string, TransferEleme
|
|
|
275
275
|
* LSP severity enum to the wire string union, discriminates the
|
|
276
276
|
* diagnostic type from Langium's `data.code` (`'lexing-error'` /
|
|
277
277
|
* `'parsing-error'` else `'validation-error'`), passes through
|
|
278
|
-
* message / element / property / code
|
|
278
|
+
* message / element / property / code, and lifts the framework message
|
|
279
|
+
* params out of `data` so a translating surface can render a
|
|
280
|
+
* parameterised diagnostic rather than a template with its placeholders
|
|
281
|
+
* left standing. Adopters whose validator
|
|
279
282
|
* doesn't decorate diagnostics with `element` still get a valid
|
|
280
283
|
* `TransferDiagnostic` — the field falls back to `''`.
|
|
281
284
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer-encoder.d.ts","sourceRoot":"","sources":["../../../src/langium/transfer/transfer-encoder.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,
|
|
1
|
+
{"version":3,"file":"transfer-encoder.d.ts","sourceRoot":"","sources":["../../../src/langium/transfer/transfer-enco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O,CAAC,EAAE,QAAQ,EAAE,aAAa,GAAG,IAAI;IAI9G;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,kBAAkB,CAAC,IAAI,SAAS,OAAO,EACpC,eAAe,EAAE,eAAe,GAChC,gBAAgB,CAAC,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,WAAW,CAAC;IAerE;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,wBAAwB,CAAC,IAAI,SAAS,OAAO,EACpD,MAAM,EAAE,sBAAsB,CAAC,WAAW,CAAC,EAC3C,IAAI,EAAE,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,GACzC,gBAAgB,CAAC,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,WAAW,CAAC;IASrE;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,6BAA6B,CAAC,IAAI,SAAS,OAAO,EAC/C,QAAQ,EAAE,WAAW,CAAC,IAAI,EAAE,WAAW,GAAG,qBAAqB,CAAC,GAChE,gBAAgB,CAAC,eAAe,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,WAAW,CAAC;IAKrE;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,oBAAoB,CAAC,UAAU,EAAE,qBAAqB,GAAG,WAAW;IA0BpE;;;;;OAKG;IACH,SAAS,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,GAAG,OAAO;CAY5E"}
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
+
import { hasMessageIdentity } from '@hydranium/protocol';
|
|
9
10
|
import { AstUtils, DocumentCache, DocumentState, isAstNode, isReference } from '@hydranium/langium';
|
|
10
11
|
import { Diagnostic, DiagnosticSeverity } from 'vscode-languageserver-protocol';
|
|
11
12
|
/**
|
|
@@ -282,7 +283,10 @@ export class TransferEncoder {
|
|
|
282
283
|
* LSP severity enum to the wire string union, discriminates the
|
|
283
284
|
* diagnostic type from Langium's `data.code` (`'lexing-error'` /
|
|
284
285
|
* `'parsing-error'` else `'validation-error'`), passes through
|
|
285
|
-
* message / element / property / code
|
|
286
|
+
* message / element / property / code, and lifts the framework message
|
|
287
|
+
* params out of `data` so a translating surface can render a
|
|
288
|
+
* parameterised diagnostic rather than a template with its placeholders
|
|
289
|
+
* left standing. Adopters whose validator
|
|
286
290
|
* doesn't decorate diagnostics with `element` still get a valid
|
|
287
291
|
* `TransferDiagnostic` — the field falls back to `''`.
|
|
288
292
|
*
|
|
@@ -291,6 +295,12 @@ export class TransferEncoder {
|
|
|
291
295
|
*/
|
|
292
296
|
toTransferDiagnostic(diagnostic) {
|
|
293
297
|
const langiumCode = diagnostic.data?.code;
|
|
298
|
+
// The same `data` the Langium code comes out of also carries the framework
|
|
299
|
+
// message identity, under its own key so the two conventions co-exist.
|
|
300
|
+
// Taking the params from there rather than from `code` is what lets a
|
|
301
|
+
// translating surface render a PARAMETERISED diagnostic: `code` survives on
|
|
302
|
+
// its own and yields a template with its placeholders left standing.
|
|
303
|
+
const identity = hasMessageIdentity(diagnostic.data) ? diagnostic.data.hydranium : undefined;
|
|
294
304
|
const result = {
|
|
295
305
|
type: langiumCode === 'lexing-error' ? 'lexing-error' : langiumCode === 'parsing-error' ? 'parsing-error' : 'validation-error',
|
|
296
306
|
element: diagnostic.element ?? '',
|
|
@@ -302,7 +312,8 @@ export class TransferEncoder {
|
|
|
302
312
|
: diagnostic.severity === DiagnosticSeverity.Warning
|
|
303
313
|
? 'warning'
|
|
304
314
|
: 'info',
|
|
305
|
-
code: typeof diagnostic.code === 'number' || typeof diagnostic.code === 'string' ? diagnostic.code : langiumCode
|
|
315
|
+
code: typeof diagnostic.code === 'number' || typeof diagnostic.code === 'string' ? diagnostic.code : langiumCode,
|
|
316
|
+
params: identity?.params
|
|
306
317
|
};
|
|
307
318
|
return result;
|
|
308
319
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer-encoder.js","sourceRoot":"","sources":["../../../src/langium/transfer/transfer-encoder.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;
|
|
1
|
+
{"version":3,"file":"transfer-encoder.js","sourceRoot":"","sources":["../../../src/langium/transfer/transfer-encoder.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,kBAAkB,EAMpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,QAAQ,EAAgB,aAAa,EAAE,aAAa,EAAE,SAAS,EAAE,WAAW,EAAwB,MAAM,oBAAoB,CAAC;AACxI,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAgEhF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,MAAM,OAAO,eAAe;IAiCH;IAzBH,MAAM,CAAS;IAElC;;;;;;;;;;;;;OAaG;IACgB,SAAS,CAAiC;IAE7D,uEAAuE;IACvE,4EAA4E;IAC5E,yDAAyD;IACzD,wEAAwE;IACxE,6EAA6E;IAC7E,8DAA8D;IAC9D,YACsB,QAAqC,EACxD,UAA0B,EAAE;QADT,aAAQ,GAAR,QAAQ,CAA6B;QAGxD,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,iBAAiB,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC9F,IAAI,CAAC,SAAS,GAAG,IAAI,aAAa,CAAkB,QAAQ,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACvF,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACO,YAAY,CAAC,OAAsB;QAC1C,OAAO,OAAO,CAAC,IAAI,CAAC;IACvB,CAAC;IAED;;;;;;;;;OASG;IACH,UAAU,CAAoB,GAAM,EAAE,OAAqB,MAAM;QAC9D,sEAAsE;QACtE,sEAAsE;QACtE,uEAAuE;QACvE,uDAAuD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AC,gBAAgB,CAAC,UAAU,CAAC;YAChD,QAAQ,EACL,UAAU,CAAC,QAAQ,KAAK,kBAAkB,CAAC,KAAK;gBAC7C,CAAC,CAAC,OAAO;gBACT,CAAC,CAAC,UAAU,CAAC,QAAQ,KAAK,kBAAkB,CAAC,OAAO;oBAClD,CAAC,CAAC,SAAS;oBACX,CAAC,CAAC,MAAM;YAChB,IAAI,EAAE,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW;YAChH,MAAM,EAAE,QAAQ,EAAE,MAAM;SAC1B,CAAC;QACF,OAAO,MAAqB,CAAC;IAChC,CAAC;IAED;;;;;OAKG;IACO,eAAe,CAAC,KAAc,EAAE,OAAsB;QAC7D,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;QACvE,CAAC;QACD,IAAI,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,OAAO,KAAK,CAAC,QAAQ,CAAC;QACzB,CAAC;QACD,IAAI,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,KAAK,CAAC;IAChB,CAAC;CACH"}
|
|
@@ -11,6 +11,14 @@ import { type Tracer } from '@hydranium/protocol';
|
|
|
11
11
|
import { type WritableFileSystemProvider } from '../../documents/ast-document-manager.js';
|
|
12
12
|
import { type LogNameOptions } from '../diagnostics/logger.js';
|
|
13
13
|
import { type ServerSharedServicesMinimal } from '../shared-services.js';
|
|
14
|
+
/**
|
|
15
|
+
* The browser host's spelling of "the document is not there". Its Node
|
|
16
|
+
* counterpart is `NO_LOADABLE_CONTENT`: this provider has no `realpath`, so the
|
|
17
|
+
* URI policy cannot answer the existence question ahead of the read and the miss
|
|
18
|
+
* surfaces here instead.
|
|
19
|
+
*/
|
|
20
|
+
export declare const NO_SUCH_FILE: import("@hydranium/protocol").MessageDefinition<"No such file: {uri}">;
|
|
21
|
+
export declare const NO_SUCH_PATH: import("@hydranium/protocol").MessageDefinition<"No such file or directory: {uri}">;
|
|
14
22
|
/**
|
|
15
23
|
* File content keyed by path, for seeding an {@link InMemoryFileSystemProvider}.
|
|
16
24
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory-file-system-provider.d.ts","sourceRoot":"","sources":["../../../src/langium/workspace/in-memory-file-system-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,cAAc,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,
|
|
1
|
+
{"version":3,"file":"in-memory-file-system-provider.d.ts","sourceRoot":"","sources":["../../../src/langium/workspace/in-memory-file-system-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,cAAc,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,KAAK,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAC1F,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAuB,KAAK,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AAG9F;;;;;GAKG;AACH,eAAO,MAAM,YAAY,wEAAsE,CAAC;AAEhG,eAAO,MAAM,YAAY,qFAAmF,CAAC;AAE7G;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA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AG,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAIlD,iBAAiB,CAAC,GAAG,EAAE,GAAG,GAAG,cAAc,EAAE;IAqB7C;;;;;;;;;OASG;IACH,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,MAAM;IAI5C,SAAS,CAAC,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAS9C;AAYD;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG;IAC1E,kBAAkB,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,0BAA0B,CAAC;CACxE,CAIA"}
|
|
@@ -7,8 +7,17 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { URI } from '@hydranium/langium';
|
|
10
|
+
import { defineMessage } from '@hydranium/protocol';
|
|
10
11
|
import { serverSharedFactory } from '../shared-services.js';
|
|
11
12
|
import { serveVirtualDocument } from './virtual-document.js';
|
|
13
|
+
/**
|
|
14
|
+
* The browser host's spelling of "the document is not there". Its Node
|
|
15
|
+
* counterpart is `NO_LOADABLE_CONTENT`: this provider has no `realpath`, so the
|
|
16
|
+
* URI policy cannot answer the existence question ahead of the read and the miss
|
|
17
|
+
* surfaces here instead.
|
|
18
|
+
*/
|
|
19
|
+
export const NO_SUCH_FILE = defineMessage('hydranium/core/no-such-file', 'No such file: {uri}');
|
|
20
|
+
export const NO_SUCH_PATH = defineMessage('hydranium/core/no-such-path', 'No such file or directory: {uri}');
|
|
12
21
|
/**
|
|
13
22
|
* A writable filesystem held in a `Map`, for a host with no disk — a browser
|
|
14
23
|
* worker, or a test that needs the workspace walk to find real content.
|
|
@@ -94,7 +103,7 @@ export class InMemoryFileSystemProvider {
|
|
|
94
103
|
}
|
|
95
104
|
const content = this.files.get(normalize(uri));
|
|
96
105
|
if (content === undefined) {
|
|
97
|
-
throw new Error(
|
|
106
|
+
throw new Error(NO_SUCH_FILE.format({ uri: uri.toString() }));
|
|
98
107
|
}
|
|
99
108
|
return content;
|
|
100
109
|
}
|
|
@@ -115,7 +124,7 @@ export class InMemoryFileSystemProvider {
|
|
|
115
124
|
if (this.hasChildren(path)) {
|
|
116
125
|
return { isFile: false, isDirectory: true, uri };
|
|
117
126
|
}
|
|
118
|
-
throw new Error(
|
|
127
|
+
throw new Error(NO_SUCH_PATH.format({ uri: uri.toString() }));
|
|
119
128
|
}
|
|
120
129
|
exists(uri) {
|
|
121
130
|
return Promise.resolve(this.existsSync(uri));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"in-memory-file-system-provider.js","sourceRoot":"","sources":["../../../src/langium/workspace/in-memory-file-system-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAuB,GAAG,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"in-memory-file-system-provider.js","sourceRoot":"","sources":["../../../src/langium/workspace/in-memory-file-system-provider.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAuB,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAe,MAAM,qBAAqB,CAAC;AAGjE,OAAO,EAAE,mBAAmB,EAAoC,MAAM,uBAAuB,CAAC;AAC9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC,6BAA6B,EAAE,qBAAqB,CAAC,CAAC;AAEhG,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAC,6BAA6B,EAAE,kCAAkC,CAAC,CAAC;AAuB7G;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,OAAO,0BAA0B;IAKd;IAJH,KAAK,GAAG,IAAI,GAAG,EAAkB,CAAC;IAClC,MAAM,CAAS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O;QACJ,kBAAkB,EAAE,mBAAmB,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,0BAA0B,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;KACxG,CAAC;AACL,CAAC"}
|
|
@@ -9,6 +9,15 @@
|
|
|
9
9
|
import { type AstNode, DefaultLangiumDocuments, type LangiumDocument, type LangiumDocuments, type URI } from '@hydranium/langium';
|
|
10
10
|
import { type ServerSharedServicesMinimal } from '../shared-services.js';
|
|
11
11
|
import { type DocumentUriPolicy } from './document-uri-policy.js';
|
|
12
|
+
/**
|
|
13
|
+
* The document a caller asked to load is not there.
|
|
14
|
+
*
|
|
15
|
+
* User-facing, and the Node host's spelling of it: `loadUri` returns `undefined`
|
|
16
|
+
* exactly when the URI policy's `realpath` reports the path absent. A host whose
|
|
17
|
+
* provider has no `realpath` never reaches this — the miss surfaces from the
|
|
18
|
+
* provider instead, so the same condition has one declaration per host.
|
|
19
|
+
*/
|
|
20
|
+
export declare const NO_LOADABLE_CONTENT: import("@hydranium/protocol").MessageDefinition<"No loadable content for {uri}">;
|
|
12
21
|
/**
|
|
13
22
|
* The registry surface the framework adds on top of Langium's
|
|
14
23
|
* {@link LangiumDocuments}. Declared separately from the implementing class so
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langium-documents.d.ts","sourceRoot":"","sources":["../../../src/langium/workspace/langium-documents.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,OAAO,EAAE,uBAAuB,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"langium-documents.d.ts","sourceRoot":"","sources":["../../../src/langium/workspace/langium-documents.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAE,KAAK,OAAO,EAAE,uBAAuB,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAElI,OAAO,EAAE,KAAK,2BAA2B,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,kFAAuF,CAAC;AAExH;;;;;;GAMG;AACH,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IAChE,mBAAmB,CAAC,GAAG,EAAE,GAAG,GAAG,eAAe,CAAC,OAAO,CAAC,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,yBAA0B,SAAQ,uBAAwB,YAAW,yBAAyB;uBAIhE,QAAQ,EAAE,2BAA2B;IAH7E,sFAAsF;IACtF,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,iBAAiB,CAAC;gBAER,QAAQ,EAAE,2BAA2B;IAK7E;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,mBAAmB,CAAC,GAAG,EAAE,GAAG,GAAG,eAAe,CAAC,OAAO,CAAC;IAMxC,mBAAmB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;CAgCjF"}
|
|
@@ -7,6 +7,16 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
import { DefaultLangiumDocuments } from '@hydranium/langium';
|
|
10
|
+
import { defineMessage } from '@hydranium/protocol';
|
|
11
|
+
/**
|
|
12
|
+
* The document a caller asked to load is not there.
|
|
13
|
+
*
|
|
14
|
+
* User-facing, and the Node host's spelling of it: `loadUri` returns `undefined`
|
|
15
|
+
* exactly when the URI policy's `realpath` reports the path absent. A host whose
|
|
16
|
+
* provider has no `realpath` never reaches this — the miss surfaces from the
|
|
17
|
+
* provider instead, so the same condition has one declaration per host.
|
|
18
|
+
*/
|
|
19
|
+
export const NO_LOADABLE_CONTENT = defineMessage('hydranium/core/no-loadable-content', 'No loadable content for {uri}');
|
|
10
20
|
/**
|
|
11
21
|
* Default `LangiumDocuments` for `@hydranium/core` consumers, extending
|
|
12
22
|
* Langium's {@link DefaultLangiumDocuments} with:
|
|
@@ -96,7 +106,7 @@ export class HydraniumLangiumDocuments extends DefaultLangiumDocuments {
|
|
|
96
106
|
}
|
|
97
107
|
// The seam reports no loadable content, so there is nothing to read and
|
|
98
108
|
// no error from a read to carry.
|
|
99
|
-
throw new Error(
|
|
109
|
+
throw new Error(NO_LOADABLE_CONTENT.format({ uri: uri.toString() }));
|
|
100
110
|
}
|
|
101
111
|
}
|
|
102
112
|
//# sourceMappingURL=langium-documents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"langium-documents.js","sourceRoot":"","sources":["../../../src/langium/workspace/langium-documents.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAgB,uBAAuB,EAAyD,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"langium-documents.js","sourceRoot":"","sources":["../../../src/langium/workspace/langium-documents.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAAgB,uBAAuB,EAAyD,MAAM,oBAAoB,CAAC;AAClI,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIpD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAAC,oCAAoC,EAAE,+BAA+B,CAAC,CAAC;AAaxH;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,OAAO,yBAA0B,SAAQ,uBAAuB;IAI3B;IAHxC,sFAAsF;IACnE,SAAS,CAAoB;IAEhD,YAAwC,QAAqC;QAC1E,KAAK,CAAC,QAAQ,CAAC,CAAC;QADqB,aAAQ,GAAR,QAAQ,CAA6B;QAE1E,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,SAAS,CAAC,iBAAiB,CAAC;IACzD,CAAC;IA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E,EAAE,CAAC,CAAC,CAAC;IACxE,CAAC;CACH"}
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
import { type MessageDefinition, type ParamsArg, type ResolvedMessage } from '@hydranium/protocol';
|
|
10
|
+
import type { AstNode, DiagnosticData, DiagnosticInfo, Properties, ValidationAcceptor } from '@hydranium/langium';
|
|
11
|
+
import type { Diagnostic } from 'vscode-languageserver-protocol';
|
|
12
|
+
/**
|
|
13
|
+
* Raise a validation diagnostic from a declaration, so the call site never
|
|
14
|
+
* restates the code or the sentence.
|
|
15
|
+
*
|
|
16
|
+
* `code` is omitted from `info` because this owns it — the framework claims LSP
|
|
17
|
+
* `Diagnostic.code` for framework codes, which collides with no adopter today
|
|
18
|
+
* and is a stated rule rather than an accident. `data` is deliberately NOT
|
|
19
|
+
* omitted: Langium owns `data.code` for code-action dispatch, so a caller has to
|
|
20
|
+
* be able to request a quick fix. The identity is merged OVER whatever they
|
|
21
|
+
* pass, which makes the two conventions co-exist rather than compete.
|
|
22
|
+
*
|
|
23
|
+
* The identity lands in both `code` and `data.hydranium` on purpose. `code` is
|
|
24
|
+
* what survives to the editor surface; Theia's converter drops `data` before the
|
|
25
|
+
* squiggle, so a parameterised diagnostic falls back to the server's English
|
|
26
|
+
* there while any adopter-owned surface can still render the parameterised form
|
|
27
|
+
* from the marker store.
|
|
28
|
+
*
|
|
29
|
+
* `DiagnosticInfo` must be Langium's own type: a `Parameters<ValidationAcceptor>[2]`
|
|
30
|
+
* shortcut compiles but loses the `property?: Properties<N>` relation. The `data`
|
|
31
|
+
* re-type has to be an intersection rather than an `Omit` alone, because Langium
|
|
32
|
+
* declares `data?: unknown` and an `unknown` cannot be spread.
|
|
33
|
+
*/
|
|
34
|
+
export declare function acceptMessage<S extends string, N extends AstNode, P extends Properties<N> = Properties<N>>(accept: ValidationAcceptor, severity: 'error' | 'warning' | 'info' | 'hint', message: MessageDefinition<S>, info: Omit<DiagnosticInfo<N, P>, 'code' | 'data'> & {
|
|
35
|
+
data?: Partial<DiagnosticData>;
|
|
36
|
+
}, ...params: ParamsArg<S>): void;
|
|
37
|
+
/**
|
|
38
|
+
* Recover the identity from a published diagnostic, for a surface that renders
|
|
39
|
+
* diagnostics itself.
|
|
40
|
+
*
|
|
41
|
+
* The `MarkupContent` narrowing is not padding: `Diagnostic.message` is
|
|
42
|
+
* `string | MarkupContent` in LSP 3.17+ and this does not compile without it.
|
|
43
|
+
* Only the string form is a resolved English sentence.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolvedFromDiagnostic(diagnostic: Diagnostic): ResolvedMessage | undefined;
|
|
46
|
+
//# sourceMappingURL=carriers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carriers.d.ts","sourceRoot":"","sources":["../../src/messages/carriers.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EAIJ,KAAK,iBAAiB,EACtB,KAAK,SAAS,EACd,KAAK,eAAe,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAClH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,EACvG,MAAM,EAAE,kBAAkB,EAC1B,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,MAAM,EAC/C,OAAO,EAAE,iBAAiB,CAAC,CAAC,CAAC,EAC7B,IAAI,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,CAAA;CAAE,EACtF,GAAG,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC,GACvB,IAAI,CAGN;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,UAAU,GAAG,eAAe,GAAG,SAAS,CAM1F"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
+
import { hasMessageIdentity, messageData } from '@hydranium/protocol';
|
|
10
|
+
/**
|
|
11
|
+
* Raise a validation diagnostic from a declaration, so the call site never
|
|
12
|
+
* restates the code or the sentence.
|
|
13
|
+
*
|
|
14
|
+
* `code` is omitted from `info` because this owns it — the framework claims LSP
|
|
15
|
+
* `Diagnostic.code` for framework codes, which collides with no adopter today
|
|
16
|
+
* and is a stated rule rather than an accident. `data` is deliberately NOT
|
|
17
|
+
* omitted: Langium owns `data.code` for code-action dispatch, so a caller has to
|
|
18
|
+
* be able to request a quick fix. The identity is merged OVER whatever they
|
|
19
|
+
* pass, which makes the two conventions co-exist rather than compete.
|
|
20
|
+
*
|
|
21
|
+
* The identity lands in both `code` and `data.hydranium` on purpose. `code` is
|
|
22
|
+
* what survives to the editor surface; Theia's converter drops `data` before the
|
|
23
|
+
* squiggle, so a parameterised diagnostic falls back to the server's English
|
|
24
|
+
* there while any adopter-owned surface can still render the parameterised form
|
|
25
|
+
* from the marker store.
|
|
26
|
+
*
|
|
27
|
+
* `DiagnosticInfo` must be Langium's own type: a `Parameters<ValidationAcceptor>[2]`
|
|
28
|
+
* shortcut compiles but loses the `property?: Properties<N>` relation. The `data`
|
|
29
|
+
* re-type has to be an intersection rather than an `Omit` alone, because Langium
|
|
30
|
+
* declares `data?: unknown` and an `unknown` cannot be spread.
|
|
31
|
+
*/
|
|
32
|
+
export function acceptMessage(accept, severity, message, info, ...params) {
|
|
33
|
+
const data = { ...info.data, ...messageData(message, ...params) };
|
|
34
|
+
accept(severity, message.format(...params), { ...info, code: message.code, data });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Recover the identity from a published diagnostic, for a surface that renders
|
|
38
|
+
* diagnostics itself.
|
|
39
|
+
*
|
|
40
|
+
* The `MarkupContent` narrowing is not padding: `Diagnostic.message` is
|
|
41
|
+
* `string | MarkupContent` in LSP 3.17+ and this does not compile without it.
|
|
42
|
+
* Only the string form is a resolved English sentence.
|
|
43
|
+
*/
|
|
44
|
+
export function resolvedFromDiagnostic(diagnostic) {
|
|
45
|
+
if (!hasMessageIdentity(diagnostic.data)) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
const text = typeof diagnostic.message === 'string' ? diagnostic.message : diagnostic.message.value;
|
|
49
|
+
return { ...diagnostic.data.hydranium, text };
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=carriers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carriers.js","sourceRoot":"","sources":["../../src/messages/carriers.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF,OAAO,EACJ,kBAAkB,EAClB,WAAW,EAKb,MAAM,qBAAqB,CAAC;AAI7B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,aAAa,CAC1B,MAA0B,EAC1B,QAA+C,EAC/C,OAA6B,EAC7B,IAAsF,EACtF,GAAG,MAAoB;IAEvB,MAAM,IAAI,GAAmD,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,GAAG,WAAW,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;IAClH,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,EAAE,GAAG,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AACtF,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAAsB;IAC1D,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,OAAO,SAAS,CAAC;IACpB,CAAC;IACD,MAAM,IAAI,GAAG,OAAO,UAAU,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,CAAC;IACpG,OAAO,EAAE,GAAG,UAAU,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
* Every user-facing message `@hydranium/core` raises, plus the carrier helpers
|
|
11
|
+
* that attach an identity to one.
|
|
12
|
+
*
|
|
13
|
+
* Declarations stay beside their call sites and are re-exported here, so this is
|
|
14
|
+
* enumeration rather than centralization: a code's package segment has to name
|
|
15
|
+
* the package that raises it. The English is a fallback, not a contract; the
|
|
16
|
+
* code is the contract, and renaming one is a breaking change.
|
|
17
|
+
*/
|
|
18
|
+
export * from './carriers.js';
|
|
19
|
+
export { SEPARATOR_IN_NAME } from '../langium/naming/name-separator-validation.js';
|
|
20
|
+
export { NO_LOADABLE_CONTENT } from '../langium/workspace/langium-documents.js';
|
|
21
|
+
export { NO_SUCH_FILE, NO_SUCH_PATH } from '../langium/workspace/in-memory-file-system-provider.js';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;GAQG;AAEH,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,wDAAwD,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
* Every user-facing message `@hydranium/core` raises, plus the carrier helpers
|
|
11
|
+
* that attach an identity to one.
|
|
12
|
+
*
|
|
13
|
+
* Declarations stay beside their call sites and are re-exported here, so this is
|
|
14
|
+
* enumeration rather than centralization: a code's package segment has to name
|
|
15
|
+
* the package that raises it. The English is a fallback, not a contract; the
|
|
16
|
+
* code is the contract, and renaming one is a breaking change.
|
|
17
|
+
*/
|
|
18
|
+
export * from './carriers.js';
|
|
19
|
+
export { SEPARATOR_IN_NAME } from '../langium/naming/name-separator-validation.js';
|
|
20
|
+
export { NO_LOADABLE_CONTENT } from '../langium/workspace/langium-documents.js';
|
|
21
|
+
export { NO_SUCH_FILE, NO_SUCH_PATH } from '../langium/workspace/in-memory-file-system-provider.js';
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/messages/index.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;;;GAQG;AAEH,cAAc,eAAe,CAAC;AAE9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gDAAgD,CAAC;AACnF,OAAO,EAAE,mBAAmB,EAAE,MAAM,2CAA2C,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,wDAAwD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hydranium/core",
|
|
3
|
-
"version": "1.0.0-next.
|
|
3
|
+
"version": "1.0.0-next.28",
|
|
4
4
|
"description": "Foundational runtime of the hydranium framework: AST coordination layer (services, integrity, AST extension, serialization, multi-client documents) plus the LSP textual head at the /lsp subpath. Consumed by protocol-head packages (@hydranium/data-server, @hydranium/glsp-server).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hydranium",
|
|
@@ -72,6 +72,14 @@
|
|
|
72
72
|
"./lib/testing/playwright": {
|
|
73
73
|
"types": "./lib/testing/playwright/index.d.ts",
|
|
74
74
|
"default": "./lib/testing/playwright/index.js"
|
|
75
|
+
},
|
|
76
|
+
"./messages": {
|
|
77
|
+
"types": "./lib/messages/index.d.ts",
|
|
78
|
+
"default": "./lib/messages/index.js"
|
|
79
|
+
},
|
|
80
|
+
"./lib/messages": {
|
|
81
|
+
"types": "./lib/messages/index.d.ts",
|
|
82
|
+
"default": "./lib/messages/index.js"
|
|
75
83
|
}
|
|
76
84
|
},
|
|
77
85
|
"main": "lib/index.js",
|
|
@@ -96,8 +104,8 @@
|
|
|
96
104
|
"diff": "^5.2.0"
|
|
97
105
|
},
|
|
98
106
|
"devDependencies": {
|
|
99
|
-
"@hydranium/langium": "1.0.0-next.
|
|
100
|
-
"@hydranium/protocol": "1.0.0-next.
|
|
107
|
+
"@hydranium/langium": "1.0.0-next.28",
|
|
108
|
+
"@hydranium/protocol": "1.0.0-next.28",
|
|
101
109
|
"@playwright/test": "^1.40.0",
|
|
102
110
|
"@types/diff": "^5.2.0",
|
|
103
111
|
"rimraf": "^5.0.0",
|
|
@@ -109,8 +117,8 @@
|
|
|
109
117
|
"vscode-languageserver-types": "^3.17.5"
|
|
110
118
|
},
|
|
111
119
|
"peerDependencies": {
|
|
112
|
-
"@hydranium/langium": "1.0.0-next.
|
|
113
|
-
"@hydranium/protocol": "1.0.0-next.
|
|
120
|
+
"@hydranium/langium": "1.0.0-next.28",
|
|
121
|
+
"@hydranium/protocol": "1.0.0-next.28",
|
|
114
122
|
"@playwright/test": "^1.40.0",
|
|
115
123
|
"vscode-jsonrpc": "9.0.1",
|
|
116
124
|
"vscode-languageserver": "~10.0.1",
|
|
@@ -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 ModelService(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
|
/**
|
|
@@ -247,7 +272,9 @@ export function createIntegrationServices<
|
|
|
247
272
|
sharedModules.generated,
|
|
248
273
|
sharedModule,
|
|
249
274
|
...(sharedModules.extra ?? []),
|
|
250
|
-
sharedModules.adopter
|
|
275
|
+
sharedModules.adopter,
|
|
276
|
+
// Last, so an override outranks the adopter too — see `overrides`.
|
|
277
|
+
...((sharedModules.overrides ?? []) as ReadonlyArray<Module<TShared, PartialLangiumSharedServices>>)
|
|
251
278
|
) as unknown as TShared;
|
|
252
279
|
|
|
253
280
|
// Each language gets its OWN `createDefaultModule({ shared })` — the
|
|
@@ -8,6 +8,13 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
10
|
import { type AstNode, type ValidationAcceptor, type ValidationChecks } from '@hydranium/langium';
|
|
11
|
+
import { defineMessage } from '@hydranium/protocol';
|
|
12
|
+
import { acceptMessage } from '../../messages/carriers.js';
|
|
13
|
+
|
|
14
|
+
export const SEPARATOR_IN_NAME = defineMessage(
|
|
15
|
+
'hydranium/core/separator-in-name',
|
|
16
|
+
"Name '{name}' contains the configured name separator '{separator}', which is reserved for qualified-name composition — use a different character."
|
|
17
|
+
);
|
|
11
18
|
import { type ServerLanguageServices } from '../language-module.js';
|
|
12
19
|
import { type ValidationCheckContribution, type ValidationCheckRegistry } from '../validation/validation-contribution.js';
|
|
13
20
|
import type { NameProvider } from './name-provider.js';
|
|
@@ -38,11 +45,11 @@ export function nameSeparatorCheck(nameProvider: NameProvider): (node: AstNode,
|
|
|
38
45
|
}
|
|
39
46
|
const separator = nameProvider.nameSeparator;
|
|
40
47
|
if (ownName.includes(separator)) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
);
|
|
48
|
+
// `{ node }` rather than `{ node, property: 'name' }`: moving the
|
|
49
|
+
// squiggle onto the name property is a behaviour change to the one
|
|
50
|
+
// diagnostic every adopter receives by default, so it is decided on its
|
|
51
|
+
// own merits rather than carried in by a mechanical migration.
|
|
52
|
+
acceptMessage(accept, 'error', SEPARATOR_IN_NAME, { node }, { name: ownName, separator });
|
|
46
53
|
}
|
|
47
54
|
};
|
|
48
55
|
}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
10
|
import {
|
|
11
|
+
hasMessageIdentity,
|
|
11
12
|
type Tracer,
|
|
12
13
|
type TransferDiagnostic,
|
|
13
14
|
type TransferElement,
|
|
@@ -387,7 +388,10 @@ export class TransferEncoder<
|
|
|
387
388
|
* LSP severity enum to the wire string union, discriminates the
|
|
388
389
|
* diagnostic type from Langium's `data.code` (`'lexing-error'` /
|
|
389
390
|
* `'parsing-error'` else `'validation-error'`), passes through
|
|
390
|
-
* message / element / property / code
|
|
391
|
+
* message / element / property / code, and lifts the framework message
|
|
392
|
+
* params out of `data` so a translating surface can render a
|
|
393
|
+
* parameterised diagnostic rather than a template with its placeholders
|
|
394
|
+
* left standing. Adopters whose validator
|
|
391
395
|
* doesn't decorate diagnostics with `element` still get a valid
|
|
392
396
|
* `TransferDiagnostic` — the field falls back to `''`.
|
|
393
397
|
*
|
|
@@ -396,6 +400,12 @@ export class TransferEncoder<
|
|
|
396
400
|
*/
|
|
397
401
|
toTransferDiagnostic(diagnostic: TransferLspDiagnostic): TDiagnostic {
|
|
398
402
|
const langiumCode = (diagnostic.data as { code?: string } | undefined)?.code;
|
|
403
|
+
// The same `data` the Langium code comes out of also carries the framework
|
|
404
|
+
// message identity, under its own key so the two conventions co-exist.
|
|
405
|
+
// Taking the params from there rather than from `code` is what lets a
|
|
406
|
+
// translating surface render a PARAMETERISED diagnostic: `code` survives on
|
|
407
|
+
// its own and yields a template with its placeholders left standing.
|
|
408
|
+
const identity = hasMessageIdentity(diagnostic.data) ? diagnostic.data.hydranium : undefined;
|
|
399
409
|
const result: TransferDiagnostic = {
|
|
400
410
|
type: langiumCode === 'lexing-error' ? 'lexing-error' : langiumCode === 'parsing-error' ? 'parsing-error' : 'validation-error',
|
|
401
411
|
element: diagnostic.element ?? '',
|
|
@@ -408,7 +418,8 @@ export class TransferEncoder<
|
|
|
408
418
|
: diagnostic.severity === DiagnosticSeverity.Warning
|
|
409
419
|
? 'warning'
|
|
410
420
|
: 'info',
|
|
411
|
-
code: typeof diagnostic.code === 'number' || typeof diagnostic.code === 'string' ? diagnostic.code : langiumCode
|
|
421
|
+
code: typeof diagnostic.code === 'number' || typeof diagnostic.code === 'string' ? diagnostic.code : langiumCode,
|
|
422
|
+
params: identity?.params
|
|
412
423
|
};
|
|
413
424
|
return result as TDiagnostic;
|
|
414
425
|
}
|
|
@@ -8,12 +8,22 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
10
|
import { type FileSystemNode, URI } from '@hydranium/langium';
|
|
11
|
-
import { type Tracer } from '@hydranium/protocol';
|
|
11
|
+
import { defineMessage, type Tracer } from '@hydranium/protocol';
|
|
12
12
|
import { type WritableFileSystemProvider } from '../../documents/ast-document-manager.js';
|
|
13
13
|
import { type LogNameOptions } from '../diagnostics/logger.js';
|
|
14
14
|
import { serverSharedFactory, type ServerSharedServicesMinimal } from '../shared-services.js';
|
|
15
15
|
import { serveVirtualDocument } from './virtual-document.js';
|
|
16
16
|
|
|
17
|
+
/**
|
|
18
|
+
* The browser host's spelling of "the document is not there". Its Node
|
|
19
|
+
* counterpart is `NO_LOADABLE_CONTENT`: this provider has no `realpath`, so the
|
|
20
|
+
* URI policy cannot answer the existence question ahead of the read and the miss
|
|
21
|
+
* surfaces here instead.
|
|
22
|
+
*/
|
|
23
|
+
export const NO_SUCH_FILE = defineMessage('hydranium/core/no-such-file', 'No such file: {uri}');
|
|
24
|
+
|
|
25
|
+
export const NO_SUCH_PATH = defineMessage('hydranium/core/no-such-path', 'No such file or directory: {uri}');
|
|
26
|
+
|
|
17
27
|
/**
|
|
18
28
|
* File content keyed by path, for seeding an {@link InMemoryFileSystemProvider}.
|
|
19
29
|
*
|
|
@@ -127,7 +137,7 @@ export class InMemoryFileSystemProvider implements WritableFileSystemProvider {
|
|
|
127
137
|
}
|
|
128
138
|
const content = this.files.get(normalize(uri));
|
|
129
139
|
if (content === undefined) {
|
|
130
|
-
throw new Error(
|
|
140
|
+
throw new Error(NO_SUCH_FILE.format({ uri: uri.toString() }));
|
|
131
141
|
}
|
|
132
142
|
return content;
|
|
133
143
|
}
|
|
@@ -152,7 +162,7 @@ export class InMemoryFileSystemProvider implements WritableFileSystemProvider {
|
|
|
152
162
|
if (this.hasChildren(path)) {
|
|
153
163
|
return { isFile: false, isDirectory: true, uri };
|
|
154
164
|
}
|
|
155
|
-
throw new Error(
|
|
165
|
+
throw new Error(NO_SUCH_PATH.format({ uri: uri.toString() }));
|
|
156
166
|
}
|
|
157
167
|
|
|
158
168
|
exists(uri: URI): Promise<boolean> {
|
|
@@ -8,9 +8,20 @@
|
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
10
|
import { type AstNode, DefaultLangiumDocuments, type LangiumDocument, type LangiumDocuments, type URI } from '@hydranium/langium';
|
|
11
|
+
import { defineMessage } from '@hydranium/protocol';
|
|
11
12
|
import { type ServerSharedServicesMinimal } from '../shared-services.js';
|
|
12
13
|
import { type DocumentUriPolicy } from './document-uri-policy.js';
|
|
13
14
|
|
|
15
|
+
/**
|
|
16
|
+
* The document a caller asked to load is not there.
|
|
17
|
+
*
|
|
18
|
+
* User-facing, and the Node host's spelling of it: `loadUri` returns `undefined`
|
|
19
|
+
* exactly when the URI policy's `realpath` reports the path absent. A host whose
|
|
20
|
+
* provider has no `realpath` never reaches this — the miss surfaces from the
|
|
21
|
+
* provider instead, so the same condition has one declaration per host.
|
|
22
|
+
*/
|
|
23
|
+
export const NO_LOADABLE_CONTENT = defineMessage('hydranium/core/no-loadable-content', 'No loadable content for {uri}');
|
|
24
|
+
|
|
14
25
|
/**
|
|
15
26
|
* The registry surface the framework adds on top of Langium's
|
|
16
27
|
* {@link LangiumDocuments}. Declared separately from the implementing class so
|
|
@@ -111,6 +122,6 @@ export class HydraniumLangiumDocuments extends DefaultLangiumDocuments implement
|
|
|
111
122
|
}
|
|
112
123
|
// The seam reports no loadable content, so there is nothing to read and
|
|
113
124
|
// no error from a read to carry.
|
|
114
|
-
throw new Error(
|
|
125
|
+
throw new Error(NO_LOADABLE_CONTENT.format({ uri: uri.toString() }));
|
|
115
126
|
}
|
|
116
127
|
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
import {
|
|
11
|
+
hasMessageIdentity,
|
|
12
|
+
messageData,
|
|
13
|
+
type HydraniumMessageData,
|
|
14
|
+
type MessageDefinition,
|
|
15
|
+
type ParamsArg,
|
|
16
|
+
type ResolvedMessage
|
|
17
|
+
} from '@hydranium/protocol';
|
|
18
|
+
import type { AstNode, DiagnosticData, DiagnosticInfo, Properties, ValidationAcceptor } from '@hydranium/langium';
|
|
19
|
+
import type { Diagnostic } from 'vscode-languageserver-protocol';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Raise a validation diagnostic from a declaration, so the call site never
|
|
23
|
+
* restates the code or the sentence.
|
|
24
|
+
*
|
|
25
|
+
* `code` is omitted from `info` because this owns it — the framework claims LSP
|
|
26
|
+
* `Diagnostic.code` for framework codes, which collides with no adopter today
|
|
27
|
+
* and is a stated rule rather than an accident. `data` is deliberately NOT
|
|
28
|
+
* omitted: Langium owns `data.code` for code-action dispatch, so a caller has to
|
|
29
|
+
* be able to request a quick fix. The identity is merged OVER whatever they
|
|
30
|
+
* pass, which makes the two conventions co-exist rather than compete.
|
|
31
|
+
*
|
|
32
|
+
* The identity lands in both `code` and `data.hydranium` on purpose. `code` is
|
|
33
|
+
* what survives to the editor surface; Theia's converter drops `data` before the
|
|
34
|
+
* squiggle, so a parameterised diagnostic falls back to the server's English
|
|
35
|
+
* there while any adopter-owned surface can still render the parameterised form
|
|
36
|
+
* from the marker store.
|
|
37
|
+
*
|
|
38
|
+
* `DiagnosticInfo` must be Langium's own type: a `Parameters<ValidationAcceptor>[2]`
|
|
39
|
+
* shortcut compiles but loses the `property?: Properties<N>` relation. The `data`
|
|
40
|
+
* re-type has to be an intersection rather than an `Omit` alone, because Langium
|
|
41
|
+
* declares `data?: unknown` and an `unknown` cannot be spread.
|
|
42
|
+
*/
|
|
43
|
+
export function acceptMessage<S extends string, N extends AstNode, P extends Properties<N> = Properties<N>>(
|
|
44
|
+
accept: ValidationAcceptor,
|
|
45
|
+
severity: 'error' | 'warning' | 'info' | 'hint',
|
|
46
|
+
message: MessageDefinition<S>,
|
|
47
|
+
info: Omit<DiagnosticInfo<N, P>, 'code' | 'data'> & { data?: Partial<DiagnosticData> },
|
|
48
|
+
...params: ParamsArg<S>
|
|
49
|
+
): void {
|
|
50
|
+
const data: HydraniumMessageData & Partial<DiagnosticData> = { ...info.data, ...messageData(message, ...params) };
|
|
51
|
+
accept(severity, message.format(...params), { ...info, code: message.code, data });
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Recover the identity from a published diagnostic, for a surface that renders
|
|
56
|
+
* diagnostics itself.
|
|
57
|
+
*
|
|
58
|
+
* The `MarkupContent` narrowing is not padding: `Diagnostic.message` is
|
|
59
|
+
* `string | MarkupContent` in LSP 3.17+ and this does not compile without it.
|
|
60
|
+
* Only the string form is a resolved English sentence.
|
|
61
|
+
*/
|
|
62
|
+
export function resolvedFromDiagnostic(diagnostic: Diagnostic): ResolvedMessage | undefined {
|
|
63
|
+
if (!hasMessageIdentity(diagnostic.data)) {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
const text = typeof diagnostic.message === 'string' ? diagnostic.message : diagnostic.message.value;
|
|
67
|
+
return { ...diagnostic.data.hydranium, text };
|
|
68
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
* Every user-facing message `@hydranium/core` raises, plus the carrier helpers
|
|
12
|
+
* that attach an identity to one.
|
|
13
|
+
*
|
|
14
|
+
* Declarations stay beside their call sites and are re-exported here, so this is
|
|
15
|
+
* enumeration rather than centralization: a code's package segment has to name
|
|
16
|
+
* the package that raises it. The English is a fallback, not a contract; the
|
|
17
|
+
* code is the contract, and renaming one is a breaking change.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export * from './carriers.js';
|
|
21
|
+
|
|
22
|
+
export { SEPARATOR_IN_NAME } from '../langium/naming/name-separator-validation.js';
|
|
23
|
+
export { NO_LOADABLE_CONTENT } from '../langium/workspace/langium-documents.js';
|
|
24
|
+
export { NO_SUCH_FILE, NO_SUCH_PATH } from '../langium/workspace/in-memory-file-system-provider.js';
|