@hydranium/protocol 1.0.0-next.27 → 1.0.0-next.29
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.
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
|
+
import { type MessageParams, type ResolvedMessage } from './messages/primitives';
|
|
9
10
|
/**
|
|
10
11
|
* Generic, transport-friendly diagnostic shape used by the model-server protocol.
|
|
11
12
|
*
|
|
@@ -55,6 +56,21 @@ export interface TransferDiagnostic {
|
|
|
55
56
|
* is not usable as a rule identity on its own.
|
|
56
57
|
*/
|
|
57
58
|
code?: number | string;
|
|
59
|
+
/**
|
|
60
|
+
* Substitutions for the placeholders in the message this {@link code} names,
|
|
61
|
+
* present only for a diagnostic raised from a framework message declaration.
|
|
62
|
+
*
|
|
63
|
+
* Without them a translated template renders with its `{name}` tokens left
|
|
64
|
+
* standing, because substitution leaves an unmatched token in place rather
|
|
65
|
+
* than raising — so a surface that translates from {@link code} alone is
|
|
66
|
+
* correct for a parameterless sentence and visibly wrong for a parameterised
|
|
67
|
+
* one. This is the field that makes the second case work; the LSP carrier has
|
|
68
|
+
* always moved the params, and no carrier below it did.
|
|
69
|
+
*
|
|
70
|
+
* Prefer {@link TransferDiagnostic.resolved} over reading this: it decides
|
|
71
|
+
* whether an identity is present at all, which a lone `params` cannot.
|
|
72
|
+
*/
|
|
73
|
+
params?: MessageParams;
|
|
58
74
|
}
|
|
59
75
|
export declare namespace TransferDiagnostic {
|
|
60
76
|
/** Path separator between AST nodes within an element location. */
|
|
@@ -65,6 +81,23 @@ export declare namespace TransferDiagnostic {
|
|
|
65
81
|
const ELEMENT_PROPERTY_SEPARATOR = "^";
|
|
66
82
|
function isError(diagnostic: TransferDiagnostic): boolean;
|
|
67
83
|
function isParseError(diagnostic: TransferDiagnostic): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The diagnostic as a renderable message, for a surface that translates.
|
|
86
|
+
* `undefined` when it carries no framework identity — a syntactic error, an
|
|
87
|
+
* adopter's own check, a linker failure — which is the case a caller must
|
|
88
|
+
* distinguish rather than render.
|
|
89
|
+
*
|
|
90
|
+
* Hand the result to `renderFrameworkMessage` with whatever catalogue the
|
|
91
|
+
* host has loaded. The `text` is the server's English, so a code the
|
|
92
|
+
* catalogue does not carry still yields a complete sentence.
|
|
93
|
+
*
|
|
94
|
+
* `code` alone does not establish an identity: it also holds Langium's
|
|
95
|
+
* internal code and an adopter's own, and either would be looked up against a
|
|
96
|
+
* catalogue that cannot have it. Requiring `params` is what discriminates,
|
|
97
|
+
* and it is why a parameterless framework message still populates the field
|
|
98
|
+
* with an empty object rather than omitting it.
|
|
99
|
+
*/
|
|
100
|
+
function resolved(diagnostic: TransferDiagnostic): ResolvedMessage | undefined;
|
|
68
101
|
function getPath(diagnostic: TransferDiagnostic): string;
|
|
69
102
|
function errors(diagnostics: TransferDiagnostic[]): TransferDiagnostic[];
|
|
70
103
|
function hasErrors(diagnostics: TransferDiagnostic[]): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer-diagnostic.d.ts","sourceRoot":"","sources":["../src/transfer-diagnostic.ts"],"names":[],"mappings":"AAAA;;;;;;;kFAOkF;AAElF;;;;;;GAMG;AACH,MAAM,WAAW,kBAAkB;IAChC;;;;;OAKG;IACH,IAAI,EAAE,cAAc,GAAG,eAAe,GAAG,kBAAkB,CAAC;IAC5D;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;OAKG;IACH,QAAQ,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,CAAC;IACvC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,yBAAiB,kBAAkB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iB,kBAAkB,CAAC;IACjC,mEAAmE;IAC5D,MAAM,yBAAyB,MAAM,CAAC;IAC7C,wDAAwD;IACjD,MAAM,uBAAuB,MAAM,CAAC;IAC3C,sFAAsF;IAC/E,MAAM,0BAA0B,MAAM,CAAC;IAE9C,SAAgB,OAAO,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAE/D;IAED,SAAgB,YAAY,CAAC,UAAU,EAAE,kBAAkB,GAAG,OAAO,CAEpE;IAED;;;;;;;;;;;;;;;OAeG;IACH,SAAgB,QAAQ,CAAC,UAAU,EAAE,kBAAkB,GAAG,eAAe,GAAG,SAAS,CAKpF;IAED,SAAgB,OAAO,CAAC,UAAU,EAAE,kBAAkB,GAAG,MAAM,CAE9D;IAED,SAAgB,MAAM,CAAC,WAAW,EAAE,kBAAkB,EAAE,GAAG,kBAAkB,EAAE,CAE9E;IAED,SAAgB,SAAS,CAAC,WAAW,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAEpE;IAED,SAAgB,cAAc,CAAC,WAAW,EAAE,kBAAkB,EAAE,GAAG,OAAO,CAEzE;CACH"}
|
|
@@ -25,6 +25,29 @@ var TransferDiagnostic;
|
|
|
25
25
|
return diagnostic.type === 'parsing-error';
|
|
26
26
|
}
|
|
27
27
|
TransferDiagnostic.isParseError = isParseError;
|
|
28
|
+
/**
|
|
29
|
+
* The diagnostic as a renderable message, for a surface that translates.
|
|
30
|
+
* `undefined` when it carries no framework identity — a syntactic error, an
|
|
31
|
+
* adopter's own check, a linker failure — which is the case a caller must
|
|
32
|
+
* distinguish rather than render.
|
|
33
|
+
*
|
|
34
|
+
* Hand the result to `renderFrameworkMessage` with whatever catalogue the
|
|
35
|
+
* host has loaded. The `text` is the server's English, so a code the
|
|
36
|
+
* catalogue does not carry still yields a complete sentence.
|
|
37
|
+
*
|
|
38
|
+
* `code` alone does not establish an identity: it also holds Langium's
|
|
39
|
+
* internal code and an adopter's own, and either would be looked up against a
|
|
40
|
+
* catalogue that cannot have it. Requiring `params` is what discriminates,
|
|
41
|
+
* and it is why a parameterless framework message still populates the field
|
|
42
|
+
* with an empty object rather than omitting it.
|
|
43
|
+
*/
|
|
44
|
+
function resolved(diagnostic) {
|
|
45
|
+
if (typeof diagnostic.code !== 'string' || diagnostic.params === undefined) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
return { code: diagnostic.code, params: diagnostic.params, text: diagnostic.message };
|
|
49
|
+
}
|
|
50
|
+
TransferDiagnostic.resolved = resolved;
|
|
28
51
|
function getPath(diagnostic) {
|
|
29
52
|
return diagnostic.property ? `${diagnostic.element}${TransferDiagnostic.ELEMENT_PROPERTY_SEPARATOR}${diagnostic.property}` : diagnostic.element;
|
|
30
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transfer-diagnostic.js","sourceRoot":"","sources":["../src/transfer-diagnostic.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;
|
|
1
|
+
{"version":3,"file":"transfer-diagnostic.js","sourceRoot":"","sources":["../src/transfer-diagnostic.ts"],"names":[],"mappings":";AAAA;;;;;;;kFAOkF;;;AAsElF,IAAiB,kBAAkB,CAsDlC;AAtDD,WAAiB,kBAAkB;IAChC,mEAAmE;IACtD,4CAAyB,GAAG,GAAG,CAAC;IAC7C,wDAAwD;IAC3C,0CAAuB,GAAG,GAAG,CAAC;IAC3C,sFAAsF;IACzE,6CAA0B,GAAG,GAAG,CAAC;IAE9C,SAAgB,OAAO,CAAC,UAA8B;QACnD,OAAO,UAAU,CAAC,QAAQ,KAAK,OAAO,CAAC;IAC1C,CAAC;IAFe,0BAAO,UAEtB,CAAA;IAED,SAAgB,YAAY,CAAC,UAA8B;QACxD,OAAO,UAAU,CAAC,IAAI,KAAK,eAAe,CAAC;IAC9C,CAAC;IAFe,+BAAY,eAE3B,CAAA;IAED;;;;;;;;;;;;;;;OAeG;IACH,SAAgB,QAAQ,CAAC,UAA8B;QACpD,IAAI,OAAO,UAAU,CAAC,IAAI,KAAK,QAAQ,IAAI,UAAU,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC1E,OAAO,SAAS,CAAC;QACpB,CAAC;QACD,OAAO,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,CAAC,OAAO,EAAE,CAAC;IACzF,CAAC;IALe,2BAAQ,WAKvB,CAAA;IAED,SAAgB,OAAO,CAAC,UAA8B;QACnD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,OAAO,GAAG,mBAAA,0BAA0B,GAAG,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC;IAChI,CAAC;IAFe,0BAAO,UAEtB,CAAA;IAED,SAAgB,MAAM,CAAC,WAAiC;QACrD,OAAO,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAFe,yBAAM,SAErB,CAAA;IAED,SAAgB,SAAS,CAAC,WAAiC;QACxD,OAAO,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACpC,CAAC;IAFe,4BAAS,YAExB,CAAA;IAED,SAAgB,cAAc,CAAC,WAAiC;QAC7D,OAAO,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACzC,CAAC;IAFe,iCAAc,iBAE7B,CAAA;AACJ,CAAC,EAtDgB,kBAAkB,kCAAlB,kBAAkB,QAsDlC"}
|
package/package.json
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
* SPDX-License-Identifier: MIT
|
|
8
8
|
********************************************************************************/
|
|
9
9
|
|
|
10
|
+
import { type MessageParams, type ResolvedMessage } from './messages/primitives';
|
|
11
|
+
|
|
10
12
|
/**
|
|
11
13
|
* Generic, transport-friendly diagnostic shape used by the model-server protocol.
|
|
12
14
|
*
|
|
@@ -56,6 +58,21 @@ export interface TransferDiagnostic {
|
|
|
56
58
|
* is not usable as a rule identity on its own.
|
|
57
59
|
*/
|
|
58
60
|
code?: number | string;
|
|
61
|
+
/**
|
|
62
|
+
* Substitutions for the placeholders in the message this {@link code} names,
|
|
63
|
+
* present only for a diagnostic raised from a framework message declaration.
|
|
64
|
+
*
|
|
65
|
+
* Without them a translated template renders with its `{name}` tokens left
|
|
66
|
+
* standing, because substitution leaves an unmatched token in place rather
|
|
67
|
+
* than raising — so a surface that translates from {@link code} alone is
|
|
68
|
+
* correct for a parameterless sentence and visibly wrong for a parameterised
|
|
69
|
+
* one. This is the field that makes the second case work; the LSP carrier has
|
|
70
|
+
* always moved the params, and no carrier below it did.
|
|
71
|
+
*
|
|
72
|
+
* Prefer {@link TransferDiagnostic.resolved} over reading this: it decides
|
|
73
|
+
* whether an identity is present at all, which a lone `params` cannot.
|
|
74
|
+
*/
|
|
75
|
+
params?: MessageParams;
|
|
59
76
|
}
|
|
60
77
|
|
|
61
78
|
export namespace TransferDiagnostic {
|
|
@@ -74,6 +91,29 @@ export namespace TransferDiagnostic {
|
|
|
74
91
|
return diagnostic.type === 'parsing-error';
|
|
75
92
|
}
|
|
76
93
|
|
|
94
|
+
/**
|
|
95
|
+
* The diagnostic as a renderable message, for a surface that translates.
|
|
96
|
+
* `undefined` when it carries no framework identity — a syntactic error, an
|
|
97
|
+
* adopter's own check, a linker failure — which is the case a caller must
|
|
98
|
+
* distinguish rather than render.
|
|
99
|
+
*
|
|
100
|
+
* Hand the result to `renderFrameworkMessage` with whatever catalogue the
|
|
101
|
+
* host has loaded. The `text` is the server's English, so a code the
|
|
102
|
+
* catalogue does not carry still yields a complete sentence.
|
|
103
|
+
*
|
|
104
|
+
* `code` alone does not establish an identity: it also holds Langium's
|
|
105
|
+
* internal code and an adopter's own, and either would be looked up against a
|
|
106
|
+
* catalogue that cannot have it. Requiring `params` is what discriminates,
|
|
107
|
+
* and it is why a parameterless framework message still populates the field
|
|
108
|
+
* with an empty object rather than omitting it.
|
|
109
|
+
*/
|
|
110
|
+
export function resolved(diagnostic: TransferDiagnostic): ResolvedMessage | undefined {
|
|
111
|
+
if (typeof diagnostic.code !== 'string' || diagnostic.params === undefined) {
|
|
112
|
+
return undefined;
|
|
113
|
+
}
|
|
114
|
+
return { code: diagnostic.code, params: diagnostic.params, text: diagnostic.message };
|
|
115
|
+
}
|
|
116
|
+
|
|
77
117
|
export function getPath(diagnostic: TransferDiagnostic): string {
|
|
78
118
|
return diagnostic.property ? `${diagnostic.element}${ELEMENT_PROPERTY_SEPARATOR}${diagnostic.property}` : diagnostic.element;
|
|
79
119
|
}
|